function RefinableDependentAccessTrait::addAccessDependency

Same name in other branches
  1. 9 core/modules/block_content/src/Access/RefinableDependentAccessTrait.php \Drupal\block_content\Access\RefinableDependentAccessTrait::addAccessDependency()
  2. 8.9.x core/modules/block_content/src/Access/RefinableDependentAccessTrait.php \Drupal\block_content\Access\RefinableDependentAccessTrait::addAccessDependency()
  3. 11.x core/modules/block_content/src/Access/RefinableDependentAccessTrait.php \Drupal\block_content\Access\RefinableDependentAccessTrait::addAccessDependency()

File

core/modules/block_content/src/Access/RefinableDependentAccessTrait.php, line 39

Class

RefinableDependentAccessTrait
Trait for \Drupal\block_content\Access\RefinableDependentAccessInterface.

Namespace

Drupal\block_content\Access

Code

public function addAccessDependency(AccessibleInterface $access_dependency) {
    if (empty($this->accessDependency)) {
        $this->accessDependency = $access_dependency;
        return $this;
    }
    if (!$this->accessDependency instanceof AccessGroupAnd) {
        $accessGroup = new AccessGroupAnd();
        $this->accessDependency = $accessGroup->addDependency($this->accessDependency);
    }
    $this->accessDependency
        ->addDependency($access_dependency);
    return $this;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.