You are here

public function DbUpdateAccessCheck::access in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/system/src/Access/DbUpdateAccessCheck.php \Drupal\system\Access\DbUpdateAccessCheck::access()
  2. 10 core/modules/system/src/Access/DbUpdateAccessCheck.php \Drupal\system\Access\DbUpdateAccessCheck::access()

Checks access for update routes.

Parameters

\Drupal\Core\Session\AccountInterface $account: The currently logged in account.

Return value

\Drupal\Core\Access\AccessResultInterface The access result.

File

core/modules/system/src/Access/DbUpdateAccessCheck.php, line 24

Class

DbUpdateAccessCheck
Access check for database update routes.

Namespace

Drupal\system\Access

Code

public function access(AccountInterface $account) {

  // Allow the global variable in settings.php to override the access check.
  if (Settings::get('update_free_access')) {
    return AccessResult::allowed()
      ->setCacheMaxAge(0);
  }
  if ($account
    ->hasPermission('administer software updates')) {
    return AccessResult::allowed()
      ->cachePerPermissions();
  }
  else {
    return AccessResult::forbidden()
      ->cachePerPermissions();
  }
}