You are here

public function WebformSubmissionController::accessDenied in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/Controller/WebformSubmissionController.php \Drupal\webform\Controller\WebformSubmissionController::accessDenied()

Returns a webform submissions's access denied page.

Parameters

\Drupal\webform\WebformInterface $webform: The webform.

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

Return value

array A renderable array containing an access denied page.

1 string reference to 'WebformSubmissionController::accessDenied'
webform.routing.yml in ./webform.routing.yml
webform.routing.yml

File

src/Controller/WebformSubmissionController.php, line 175

Class

WebformSubmissionController
Provides route responses for Webform submissions.

Namespace

Drupal\webform\Controller

Code

public function accessDenied(WebformInterface $webform, WebformSubmissionInterface $webform_submission) {

  // Message.
  $config = $this
    ->config('webform.settings');
  $message = $webform
    ->getSetting('submission_access_denied_message') ?: $config
    ->get('settings.default_submission_access_denied_message');
  $message = $this->tokenManager
    ->replace($message, $webform_submission);

  // Attributes.
  $attributes = $webform
    ->getSetting('submission_access_denied_attributes');
  $attributes['class'][] = 'webform-submission-access-denied';

  // Build message.
  $build = [
    '#type' => 'container',
    '#attributes' => $attributes,
    'message' => WebformHtmlEditor::checkMarkup($message),
  ];

  // Add config and webform to cache contexts.
  $this->renderer
    ->addCacheableDependency($build, $config);
  $this->renderer
    ->addCacheableDependency($build, $webform);
  return $build;
}