function DbUpdateAccessCheck::access

Checks access to update.php.

Grants access if 'update_free_access' is set in settings.php. Otherwise, requires the 'administer software updates' permission.

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 27

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();
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.