DbUpdateAccessCheck.php

Same filename in other branches
  1. 8.9.x core/modules/system/src/Access/DbUpdateAccessCheck.php
  2. 10 core/modules/system/src/Access/DbUpdateAccessCheck.php
  3. 11.x core/modules/system/src/Access/DbUpdateAccessCheck.php

Namespace

Drupal\system\Access

File

core/modules/system/src/Access/DbUpdateAccessCheck.php

View source
<?php

namespace Drupal\system\Access;

use Drupal\Core\Routing\Access\AccessInterface;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Site\Settings;

/**
 * Access check for database update routes.
 */
class DbUpdateAccessCheck implements AccessInterface {
    
    /**
     * Checks access for update routes.
     *
     * @param \Drupal\Core\Session\AccountInterface $account
     *   The currently logged in account.
     *
     * @return \Drupal\Core\Access\AccessResultInterface
     *   The access result.
     */
    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();
        }
    }

}

Classes

Title Deprecated Summary
DbUpdateAccessCheck Access check for database update routes.

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