You are here

public static function WebformSourceEntityAccess::checkEntityResultsAccess in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Access/WebformSourceEntityAccess.php \Drupal\webform\Access\WebformSourceEntityAccess::checkEntityResultsAccess()

Check whether the user can access an entity's webform results.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: An entity.

\Drupal\Core\Session\AccountInterface $account: Run access checks for this account.

Return value

\Drupal\Core\Access\AccessResultInterface The access result.

1 call to WebformSourceEntityAccess::checkEntityResultsAccess()
WebformSourceEntityAccessTest::testWebformSourceEntityAccess in tests/src/Unit/Access/WebformSourceEntityAccessTest.php
Tests the check webform source entity access.

File

src/Access/WebformSourceEntityAccess.php, line 25

Class

WebformSourceEntityAccess
Defines the custom access control handler for the webform source entities.

Namespace

Drupal\webform\Access

Code

public static function checkEntityResultsAccess(EntityInterface $entity, AccountInterface $account) {

  /** @var \Drupal\webform\WebformEntityReferenceManagerInterface $entity_reference_manager */
  $entity_reference_manager = \Drupal::service('webform.entity_reference_manager');
  $access = $entity
    ->access('update', $account, TRUE);
  $access
    ->andIf(AccessResult::allowedIf($entity_reference_manager
    ->getWebform($entity)));
  return $access;
}