Mercurial > hg > isophonics-drupal-site
diff core/modules/system/src/Access/DbUpdateAccessCheck.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core/modules/system/src/Access/DbUpdateAccessCheck.php Wed Nov 29 16:09:58 2017 +0000 @@ -0,0 +1,38 @@ +<?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 string + * A \Drupal\Core\Access\AccessInterface constant value. + */ + 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(); + } + } + +}