class CronAccessCheck in Drupal 8
Same name and namespace in other branches
- 9 core/modules/system/src/Access/CronAccessCheck.php \Drupal\system\Access\CronAccessCheck
Access check for cron routes.
Hierarchy
- class \Drupal\system\Access\CronAccessCheck implements AccessInterface
Expanded class hierarchy of CronAccessCheck
1 string reference to 'CronAccessCheck'
- system.services.yml in core/
modules/ system/ system.services.yml - core/modules/system/system.services.yml
1 service uses CronAccessCheck
- access_check.cron in core/
modules/ system/ system.services.yml - Drupal\system\Access\CronAccessCheck
File
- core/
modules/ system/ src/ Access/ CronAccessCheck.php, line 11
Namespace
Drupal\system\AccessView source
class CronAccessCheck implements AccessInterface {
/**
* Checks access.
*
* @param string $key
* The cron key.
*
* @return \Drupal\Core\Access\AccessResultInterface
* The access result.
*/
public function access($key) {
if ($key != \Drupal::state()
->get('system.cron_key')) {
\Drupal::logger('cron')
->notice('Cron could not run because an invalid key was used.');
return AccessResult::forbidden()
->setCacheMaxAge(0);
}
elseif (\Drupal::state()
->get('system.maintenance_mode')) {
\Drupal::logger('cron')
->notice('Cron could not run because the site is in maintenance mode.');
return AccessResult::forbidden()
->setCacheMaxAge(0);
}
return AccessResult::allowed()
->setCacheMaxAge(0);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CronAccessCheck:: |
public | function | Checks access. |