function EntityAccessControlHandler::processAccessHookResults

Same name in other branches
  1. 9 core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php \Drupal\Core\Entity\EntityAccessControlHandler::processAccessHookResults()
  2. 8.9.x core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php \Drupal\Core\Entity\EntityAccessControlHandler::processAccessHookResults()
  3. 10 core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php \Drupal\Core\Entity\EntityAccessControlHandler::processAccessHookResults()

Determines entity access.

We grant access to the entity if both of these conditions are met:

  • No modules say to deny access.
  • At least one module says to grant access.

Parameters

\Drupal\Core\Access\AccessResultInterface[] $access: An array of access results of the fired access hook.

Return value

\Drupal\Core\Access\AccessResultInterface The combined result of the various access checks' results. All their cacheability metadata is merged as well.

See also

\Drupal\Core\Access\AccessResultInterface::orIf()

3 calls to EntityAccessControlHandler::processAccessHookResults()
EntityAccessControlHandler::access in core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php
Checks access to an operation on a given entity or entity translation.
EntityAccessControlHandler::createAccess in core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php
Checks access to create an entity.
EntityAccessControlHandler::fieldAccess in core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php
Checks access to an operation on a given entity field.

File

core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php, line 131

Class

EntityAccessControlHandler
Defines a default implementation for entity access control handler.

Namespace

Drupal\Core\Entity

Code

protected function processAccessHookResults(array $access) {
    // No results means no opinion.
    if (empty($access)) {
        return AccessResult::neutral();
    }
    
    /** @var \Drupal\Core\Access\AccessResultInterface $result */
    $result = array_shift($access);
    foreach ($access as $other) {
        $result = $result->orIf($other);
    }
    return $result;
}

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