comparison core/modules/block_content/src/Access/RefinableDependentAccessTrait.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
7 /**
8 * Trait for \Drupal\block_content\Access\RefinableDependentAccessInterface.
9 *
10 * @internal
11 */
12 trait RefinableDependentAccessTrait {
13
14 /**
15 * The access dependency.
16 *
17 * @var \Drupal\Core\Access\AccessibleInterface
18 */
19 protected $accessDependency;
20
21 /**
22 * {@inheritdoc}
23 */
24 public function setAccessDependency(AccessibleInterface $access_dependency) {
25 $this->accessDependency = $access_dependency;
26 return $this;
27 }
28
29 /**
30 * {@inheritdoc}
31 */
32 public function getAccessDependency() {
33 return $this->accessDependency;
34 }
35
36 /**
37 * {@inheritdoc}
38 */
39 public function addAccessDependency(AccessibleInterface $access_dependency) {
40 if (empty($this->accessDependency)) {
41 $this->accessDependency = $access_dependency;
42 return $this;
43 }
44 if (!$this->accessDependency instanceof AccessGroupAnd) {
45 $accessGroup = new AccessGroupAnd();
46 $this->accessDependency = $accessGroup->addDependency($this->accessDependency);
47 }
48 $this->accessDependency->addDependency($access_dependency);
49 return $this;
50 }
51
52 }