public function CronForm::buildForm

Implements \Drupal\Core\Form\FormInterface::buildForm().

Overrides SystemConfigFormBase::buildForm

File

drupal/core/modules/system/lib/Drupal/system/Form/CronForm.php, line 65
Contains \Drupal\system\Form\CronForm.

Class

CronForm
Configure cron settings for this site.

Namespace

Drupal\system\Form

Code

public function buildForm(array $form, array &$form_state) {
  $config = $this->configFactory
    ->get('system.cron');
  $form['description'] = array(
    '#markup' => '<p>' . t('Cron takes care of running periodic tasks like checking for updates and indexing content for search.') . '</p>',
  );
  $form['run'] = array(
    '#type' => 'submit',
    '#value' => t('Run cron'),
    '#submit' => array(
      array(
        $this,
        'submitCron',
      ),
    ),
  );
  $status = '<p>' . t('Last run: %cron-last ago.', array(
    '%cron-last' => format_interval(REQUEST_TIME - $this->state
      ->get('system.cron_last')),
  )) . '</p>';
  $form['status'] = array(
    '#markup' => $status,
  );
  $form['cron_url'] = array(
    '#markup' => '<p>' . t('To run cron from outside the site, go to <a href="!cron">!cron</a>', array(
      '!cron' => url('cron/' . $this->state
        ->get('system.cron_key'), array(
        'absolute' => TRUE,
      )),
    )) . '</p>',
  );
  $form['cron'] = array(
    '#type' => 'details',
  );
  $form['cron']['cron_safe_threshold'] = array(
    '#type' => 'select',
    '#title' => t('Run cron every'),
    '#default_value' => $config
      ->get('threshold.autorun'),
    '#options' => array(
      0 => t('Never'),
    ) + drupal_map_assoc(array(
      3600,
      10800,
      21600,
      43200,
      86400,
      604800,
    ), 'format_interval'),
  );
  return parent::buildForm($form, $form_state);
}