3 namespace Drupal\system\Access;
5 use Drupal\Core\Routing\Access\AccessInterface;
6 use Drupal\Core\Access\AccessResult;
7 use Drupal\Core\Session\AccountInterface;
8 use Drupal\Core\Site\Settings;
11 * Access check for database update routes.
13 class DbUpdateAccessCheck implements AccessInterface {
16 * Checks access for update routes.
18 * @param \Drupal\Core\Session\AccountInterface $account
19 * The currently logged in account.
22 * A \Drupal\Core\Access\AccessInterface constant value.
24 public function access(AccountInterface $account) {
25 // Allow the global variable in settings.php to override the access check.
26 if (Settings::get('update_free_access')) {
27 return AccessResult::allowed()->setCacheMaxAge(0);
30 if ($account->hasPermission('administer software updates')) {
31 return AccessResult::allowed()->cachePerPermissions();
34 return AccessResult::forbidden()->cachePerPermissions();