Further Drupal 8.6.4 changes. Some core files were not committed before a commit...
[yaffs-website] / web / core / modules / system / src / Access / DbUpdateAccessCheck.php
1 <?php
2
3 namespace Drupal\system\Access;
4
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;
9
10 /**
11  * Access check for database update routes.
12  */
13 class DbUpdateAccessCheck implements AccessInterface {
14
15   /**
16    * Checks access for update routes.
17    *
18    * @param \Drupal\Core\Session\AccountInterface $account
19    *   The currently logged in account.
20    *
21    * @return string
22    *   A \Drupal\Core\Access\AccessInterface constant value.
23    */
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);
28     }
29
30     if ($account->hasPermission('administer software updates')) {
31       return AccessResult::allowed()->cachePerPermissions();
32     }
33     else {
34       return AccessResult::forbidden()->cachePerPermissions();
35     }
36   }
37
38 }