You are here

public function TestWebformHandler::accessElement in Webform 6.x

Same name and namespace in other branches
  1. 8.5 tests/modules/webform_test_handler/src/Plugin/WebformHandler/TestWebformHandler.php \Drupal\webform_test_handler\Plugin\WebformHandler\TestWebformHandler::accessElement()

Controls entity operation access to webform submission element.

Parameters

array $element: The element's properties.

string $operation: The operation that is to be performed on $entity.

\Drupal\Core\Session\AccountInterface $account: The account trying to access the entity.

Return value

\Drupal\Core\Access\AccessResultInterface The result of the access check. Defaults to neutral.

Overrides WebformHandlerBase::accessElement

File

tests/modules/webform_test_handler/src/Plugin/WebformHandler/TestWebformHandler.php, line 208

Class

TestWebformHandler
Webform submission test handler.

Namespace

Drupal\webform_test_handler\Plugin\WebformHandler

Code

public function accessElement(array &$element, $operation, AccountInterface $account = NULL) {
  $this
    ->displayMessage(__FUNCTION__);
  $webform_submission = $this
    ->getWebformSubmission();
  if ($webform_submission && $webform_submission
    ->getElementData('element') === 'element_access_denied') {
    $access_result = AccessResult::forbidden();
  }
  else {
    $access_result = parent::accessElement($element, $operation, $account);
  }
  return $access_result
    ->setCacheMaxAge(0);
}