You are here

public static function WebformOptionsLimitController::checkNodeAccess in Webform 8.5

Check whether the user can access a node's webform options limits summary.

Parameters

string $operation: Operation being performed.

string $entity_access: Entity access rule that needs to be checked.

\Drupal\node\NodeInterface $node: A node.

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

Return value

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

1 string reference to 'WebformOptionsLimitController::checkNodeAccess'
webform_options_limit.routing.yml in modules/webform_options_limit/webform_options_limit.routing.yml
modules/webform_options_limit/webform_options_limit.routing.yml

File

modules/webform_options_limit/src/Controller/WebformOptionsLimitController.php, line 101

Class

WebformOptionsLimitController
Provides route responses for webform options limit.

Namespace

Drupal\webform_options_limit\Controller

Code

public static function checkNodeAccess($operation, $entity_access, NodeInterface $node, AccountInterface $account) {

  /** @var \Drupal\webform\WebformEntityReferenceManagerInterface $entity_reference_manager */
  $entity_reference_manager = \Drupal::service('webform.entity_reference_manager');
  $webform = $entity_reference_manager
    ->getWebform($node);

  // Check that the node has a valid webform reference.
  if (!$webform) {
    return AccessResult::forbidden()
      ->addCacheableDependency($node);
  }
  if (!static::hasOptionsLimit($webform)) {
    return AccessResult::forbidden()
      ->addCacheableDependency($webform);
  }
  return WebformNodeAccess::checkWebformResultsAccess($operation, $entity_access, $node, $account);
}