public function CronForm::buildForm in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Form/CronForm.php \Drupal\system\Form\CronForm::buildForm()
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides FormInterface::buildForm
File
- core/
modules/ system/ src/ Form/ CronForm.php, line 97 - Contains \Drupal\system\Form\CronForm.
Class
- CronForm
- Configure cron settings for this site.
Namespace
Drupal\system\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$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'),
);
$status = '<p>' . $this
->t('Last run: %time ago.', array(
'%time' => $this->dateFormatter
->formatTimeDiffSince($this->state
->get('system.cron_last')),
)) . '</p>';
$form['status'] = array(
'#markup' => $status,
);
$cron_url = $this
->url('system.cron', array(
'key' => $this->state
->get('system.cron_key'),
), array(
'absolute' => TRUE,
));
$form['cron_url'] = array(
'#markup' => '<p>' . t('To run cron from outside the site, go to <a href=":cron">@cron</a>', array(
':cron' => $cron_url,
'@cron' => $cron_url,
)) . '</p>',
);
if (!$this->moduleHandler
->moduleExists('automated_cron')) {
$form['cron'] = array(
'#markup' => $this
->t('Enable the <em>Automated Cron</em> module to allow cron execution at the end of a server response.'),
);
}
return $form;
}