You are here

class WebformSourceEntityAccess in Webform 6.x

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

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

Hierarchy

Expanded class hierarchy of WebformSourceEntityAccess

1 file declares its use of WebformSourceEntityAccess
WebformSourceEntityAccessTest.php in tests/src/Unit/Access/WebformSourceEntityAccessTest.php

File

src/Access/WebformSourceEntityAccess.php, line 12

Namespace

Drupal\webform\Access
View source
class WebformSourceEntityAccess {

  /**
   * Check whether the user can access an entity's webform results.
   *
   * @param \Drupal\Core\Entity\EntityInterface $entity
   *   An entity.
   * @param \Drupal\Core\Session\AccountInterface $account
   *   Run access checks for this account.
   *
   * @return \Drupal\Core\Access\AccessResultInterface
   *   The access result.
   */
  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;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
WebformSourceEntityAccess::checkEntityResultsAccess public static function Check whether the user can access an entity's webform results.