You are here

public static function WebformAccessResult::addDependencies in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/Access/WebformAccessResult.php \Drupal\webform\Access\WebformAccessResult::addDependencies()

Adds dependencies to an access result.

Parameters

\Drupal\Core\Access\AccessResult $access_result: The access result.

\Drupal\Core\Entity\EntityInterface|null $webform_entity: A webform or webform submission.

bool $cache_per_user: Cache per user.

Return value

\Drupal\Core\Access\AccessResult The access result with dependencies.

3 calls to WebformAccessResult::addDependencies()
WebformAccessResult::allowed in src/Access/WebformAccessResult.php
Creates an AccessResultInterface object with isAllowed() === TRUE.
WebformAccessResult::forbidden in src/Access/WebformAccessResult.php
Creates an AccessResultInterface object with isForbidden() === TRUE.
WebformAccessResult::neutral in src/Access/WebformAccessResult.php
Creates an AccessResultInterface object with isNeutral() === TRUE.

File

src/Access/WebformAccessResult.php, line 90

Class

WebformAccessResult
Value object indicating an allowed access result, with cacheability metadata.

Namespace

Drupal\webform\Access

Code

public static function addDependencies(AccessResult $access_result, EntityInterface $webform_entity = NULL, $cache_per_user = FALSE) {
  $access_result
    ->cachePerPermissions();
  if ($cache_per_user) {
    $access_result
      ->cachePerUser();
  }
  if ($webform_entity) {
    if ($webform_entity instanceof WebformSubmissionInterface) {
      $access_result
        ->addCacheableDependency($webform_entity
        ->getWebform());
    }
    $access_result
      ->addCacheableDependency($webform_entity);
  }
  return $access_result;
}