You are here

public static function WebformNodeAccess::checkWebformSubmissionAccess 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::checkWebformSubmissionAccess()

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

Parameters

string $operation: Operation being performed.

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

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

\Drupal\webform\WebformSubmissionInterface $webform_submission: A webform submission.

\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::checkWebformSubmissionAccess'
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 140

Class

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

Namespace

Drupal\webform_node\Access

Code

public static function checkWebformSubmissionAccess($operation, $entity_access, NodeInterface $node, WebformSubmissionInterface $webform_submission, AccountInterface $account) {
  $access_result = static::checkAccess($operation, $entity_access, $node, $webform_submission, $account);
  if ($access_result
    ->isForbidden()) {
    return $access_result;
  }
  switch ($operation) {
    case 'webform_submission_edit_all':
      return WebformSubmissionAccess::checkWizardPagesAccess($webform_submission);
    case 'webform_submission_resend':
      return WebformSubmissionAccess::checkResendAccess($webform_submission, $account);
    case 'webform_submission_duplicate':

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