Esempio n. 1
0
 /**
  * Run cron manually.
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  *   A Symfony direct response object.
  */
 public function runManually()
 {
     if ($this->cron->run()) {
         drupal_set_message($this->t('Cron ran successfully.'));
     } else {
         drupal_set_message($this->t('Cron run failed.'), 'error');
     }
     return $this->redirect('system.status');
 }
Esempio n. 2
0
 /**
  * Run the automated cron if enabled.
  *
  * @param \Symfony\Component\HttpKernel\Event\PostResponseEvent $event
  *   The Event to process.
  */
 public function onTerminate(PostResponseEvent $event)
 {
     $interval = $this->config->get('interval');
     if ($interval > 0) {
         $cron_next = $this->state->get('system.cron_last', 0) + $interval;
         if ((int) $event->getRequest()->server->get('REQUEST_TIME') > $cron_next) {
             $this->cron->run();
         }
     }
 }
Esempio n. 3
0
 /**
  * Run the automated cron if enabled.
  *
  * @param Symfony\Component\HttpKernel\Event\PostResponseEvent $event
  *   The Event to process.
  */
 public function onTerminate(PostResponseEvent $event)
 {
     // If the site is not fully installed, suppress the automated cron run.
     // Otherwise it could be triggered prematurely by Ajax requests during
     // installation.
     if ($this->state->get('install_task') == 'done') {
         $threshold = $this->config->get('threshold.autorun');
         if ($threshold > 0) {
             $cron_next = $this->state->get('system.cron_last', 0) + $threshold;
             if (REQUEST_TIME > $cron_next) {
                 $this->cron->run();
             }
         }
     }
 }
Esempio n. 4
0
 /**
  * Runs cron and reloads the page.
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     // Run cron manually from Cron form.
     if ($this->cron->run()) {
         drupal_set_message(t('Cron ran successfully.'));
     } else {
         drupal_set_message(t('Cron run failed.'), 'error');
     }
 }
Esempio n. 5
0
 /**
  * Runs cron and reloads the page.
  */
 public function submitCron(array &$form, FormStateInterface $form_state)
 {
     // Run cron manually from Cron form.
     if ($this->cron->run()) {
         drupal_set_message(t('Cron run successfully.'));
     } else {
         drupal_set_message(t('Cron run failed.'), 'error');
     }
     return new RedirectResponse($this->url('system.cron_settings', array(), array('absolute' => TRUE)));
 }
Esempio n. 6
0
 /**
  * Runs cron and reloads the page.
  */
 public function submitCron(array &$form, array &$form_state)
 {
     // Run cron manually from Cron form.
     if ($this->cron->run()) {
         drupal_set_message(t('Cron run successfully.'));
     } else {
         drupal_set_message(t('Cron run failed.'), 'error');
     }
     return new RedirectResponse(url('admin/config/system/cron', array('absolute' => TRUE)));
 }
 /**
  * Allow user to directly execute cron, optionally forcing it.
  */
 public function cronRun(array &$form, FormStateInterface &$form_state)
 {
     $config = $this->configFactory->getEditable('examples.cron');
     $cron_reset = $form_state->getValue('cron_reset');
     if (!empty($cron_reset)) {
         $config->set('next_execution', 0);
     }
     // Use a state variable to signal that cron was run manually from this form.
     $this->state->set('cron_example_show_status_message', TRUE);
     if ($this->cron->run()) {
         drupal_set_message($this->t('Cron ran successfully.'));
     } else {
         drupal_set_message($this->t('Cron run failed.'), 'error');
     }
 }
Esempio n. 8
0
 public function runCron()
 {
     $this->cron->run();
     drupal_set_message($this->t('Cron ran successfully.'));
     return new RedirectResponse($this->reload_page());
 }