comparison core/modules/update/src/Access/UpdateManagerAccessCheck.php @ 0:c75dbcec494b

Initial commit from drush-created site
author Chris Cannam
date Thu, 05 Jul 2018 14:24:15 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:c75dbcec494b
1 <?php
2
3 namespace Drupal\update\Access;
4
5 use Drupal\Core\Access\AccessResult;
6 use Drupal\Core\Routing\Access\AccessInterface;
7 use Drupal\Core\Site\Settings;
8
9 /**
10 * Determines whether allow authorized operations is set.
11 */
12 class UpdateManagerAccessCheck implements AccessInterface {
13
14 /**
15 * Settings Service.
16 *
17 * @var \Drupal\Core\Site\Settings
18 */
19 protected $settings;
20
21 /**
22 * Constructs a UpdateManagerAccessCheck object.
23 *
24 * @param \Drupal\Core\Site\Settings $settings
25 * The read-only settings container.
26 */
27 public function __construct(Settings $settings) {
28 $this->settings = $settings;
29 }
30
31 /**
32 * Checks access.
33 *
34 * @return \Drupal\Core\Access\AccessResultInterface
35 * The access result.
36 */
37 public function access() {
38 // Uncacheable because the access result depends on a Settings key-value
39 // pair, and can therefore change at any time.
40 return AccessResult::allowedIf($this->settings->get('allow_authorize_operations', TRUE))->setCacheMaxAge(0);
41 }
42
43 }