Mercurial > hg > isophonics-drupal-site
comparison core/modules/block_content/src/Access/AccessGroupAnd.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\block_content\Access; | |
4 | |
5 use Drupal\Core\Access\AccessibleInterface; | |
6 use Drupal\Core\Access\AccessResult; | |
7 use Drupal\Core\Session\AccountInterface; | |
8 | |
9 /** | |
10 * An access group where all the dependencies must be allowed. | |
11 * | |
12 * @internal | |
13 */ | |
14 class AccessGroupAnd implements AccessibleInterface { | |
15 | |
16 /** | |
17 * The access dependencies. | |
18 * | |
19 * @var \Drupal\Core\Access\AccessibleInterface[] | |
20 */ | |
21 protected $dependencies = []; | |
22 | |
23 /** | |
24 * {@inheritdoc} | |
25 */ | |
26 public function addDependency(AccessibleInterface $dependency) { | |
27 $this->dependencies[] = $dependency; | |
28 return $this; | |
29 } | |
30 | |
31 /** | |
32 * {@inheritdoc} | |
33 */ | |
34 public function access($operation, AccountInterface $account = NULL, $return_as_object = FALSE) { | |
35 $access_result = AccessResult::neutral(); | |
36 foreach (array_slice($this->dependencies, 1) as $dependency) { | |
37 $access_result = $access_result->andIf($dependency->access($operation, $account, TRUE)); | |
38 } | |
39 return $return_as_object ? $access_result : $access_result->isAllowed(); | |
40 } | |
41 | |
42 /** | |
43 * {@inheritdoc} | |
44 */ | |
45 public function getDependencies() { | |
46 return $this->dependencies; | |
47 } | |
48 | |
49 } |