class AccessGroupAnd

Same name in other branches
  1. 8.9.x core/modules/block_content/src/Access/AccessGroupAnd.php \Drupal\block_content\Access\AccessGroupAnd
  2. 10 core/modules/block_content/src/Access/AccessGroupAnd.php \Drupal\block_content\Access\AccessGroupAnd
  3. 11.x core/modules/block_content/src/Access/AccessGroupAnd.php \Drupal\block_content\Access\AccessGroupAnd

An access group where all the dependencies must be allowed.

@internal

Hierarchy

Expanded class hierarchy of AccessGroupAnd

2 files declare their use of AccessGroupAnd
AccessGroupAndTest.php in core/modules/block_content/tests/src/Unit/Access/AccessGroupAndTest.php
DependentAccessTest.php in core/modules/block_content/tests/src/Unit/Access/DependentAccessTest.php

File

core/modules/block_content/src/Access/AccessGroupAnd.php, line 14

Namespace

Drupal\block_content\Access
View source
class AccessGroupAnd implements AccessibleInterface {
    
    /**
     * The access dependencies.
     *
     * @var \Drupal\Core\Access\AccessibleInterface[]
     */
    protected $dependencies = [];
    
    /**
     * {@inheritdoc}
     */
    public function addDependency(AccessibleInterface $dependency) {
        $this->dependencies[] = $dependency;
        return $this;
    }
    
    /**
     * {@inheritdoc}
     */
    public function access($operation, AccountInterface $account = NULL, $return_as_object = FALSE) {
        $access_result = AccessResult::neutral();
        foreach (array_slice($this->dependencies, 1) as $dependency) {
            $access_result = $access_result->andIf($dependency->access($operation, $account, TRUE));
        }
        return $return_as_object ? $access_result : $access_result->isAllowed();
    }
    
    /**
     * {@inheritdoc}
     */
    public function getDependencies() {
        return $this->dependencies;
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
AccessGroupAnd::$dependencies protected property The access dependencies.
AccessGroupAnd::access public function Checks data value access. Overrides AccessibleInterface::access
AccessGroupAnd::addDependency public function
AccessGroupAnd::getDependencies public function

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