You are here

public static function WebformNodeAccess::checkWebformDraftsAccess in Webform 6.x

Same name and namespace in other branches
  1. 8.5 modules/webform_node/src/Access/WebformNodeAccess.php \Drupal\webform_node\Access\WebformNodeAccess::checkWebformDraftsAccess()

Check whether the user can access a node's webform drafts.

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 'WebformNodeAccess::checkWebformDraftsAccess'
webform_node.routing.yml in modules/webform_node/webform_node.routing.yml
modules/webform_node/webform_node.routing.yml

File

modules/webform_node/src/Access/WebformNodeAccess.php, line 32

Class

WebformNodeAccess
Defines the custom access control handler for the webform node.

Namespace

Drupal\webform_node\Access

Code

public static function checkWebformDraftsAccess($operation, $entity_access, NodeInterface $node, AccountInterface $account) {
  $access_result = static::checkAccess($operation, $entity_access, $node, NULL, $account);
  if ($access_result
    ->isAllowed()) {

    /** @var \Drupal\webform\WebformEntityReferenceManagerInterface $entity_reference_manager */
    $entity_reference_manager = \Drupal::service('webform.entity_reference_manager');
    $webform = $entity_reference_manager
      ->getWebform($node);
    return WebformEntityAccess::checkDraftsAccess($webform, $node);
  }
  else {
    return $access_result;
  }
}