class CronAccessCheck

Access check for cron routes.

Hierarchy

Expanded class hierarchy of CronAccessCheck

1 string reference to 'CronAccessCheck'
system.services.yml in drupal/core/modules/system/system.services.yml
drupal/core/modules/system/system.services.yml
1 service uses CronAccessCheck

File

drupal/core/modules/system/lib/Drupal/system/Access/CronAccessCheck.php, line 17
Contains Drupal\system\Access\CronAccessCheck.

Namespace

Drupal\system\Access
View source
class CronAccessCheck implements AccessCheckInterface {

  /**
   * Implements AccessCheckInterface::applies().
   */
  public function applies(Route $route) {
    return array_key_exists('_access_system_cron', $route
      ->getRequirements());
  }

  /**
   * Implements AccessCheckInterface::access().
   */
  public function access(Route $route, Request $request) {
    $key = $request->attributes
      ->get('key');
    if ($key != \Drupal::state()
      ->get('system.cron_key')) {
      watchdog('cron', 'Cron could not run because an invalid key was used.', array(), WATCHDOG_NOTICE);
      return FALSE;
    }
    elseif (config('system.maintenance')
      ->get('enabled')) {
      watchdog('cron', 'Cron could not run because the site is in maintenance mode.', array(), WATCHDOG_NOTICE);
      return FALSE;
    }
    return TRUE;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AccessCheckInterface::ALLOW constant Grant access.
AccessCheckInterface::DENY constant Deny access.
AccessCheckInterface::KILL constant Block access.
CronAccessCheck::access public function Implements AccessCheckInterface::access(). Overrides AccessCheckInterface::access
CronAccessCheck::applies public function Implements AccessCheckInterface::applies(). Overrides AccessCheckInterface::applies