public static function Webform::buildAccessDenied in Webform 8.5
Same name and namespace in other branches
- 6.x src/Element/Webform.php \Drupal\webform\Element\Webform::buildAccessDenied()
Build access denied message for a webform.
Parameters
\Drupal\webform\WebformInterface $webform: A webform.
Return value
array A renderable array containing thea access denied message for a webform.
2 calls to Webform::buildAccessDenied()
- Webform::preRenderWebformElement in src/
Element/ Webform.php - Webform element pre render callback.
- WebformEntityController::accessDenied in src/
Controller/ WebformEntityController.php - Returns a webform's access denied page.
File
- src/
Element/ Webform.php, line 126
Class
- Webform
- Provides a render element to display a webform.
Namespace
Drupal\webform\ElementCode
public static function buildAccessDenied(WebformInterface $webform) {
/** @var \Drupal\webform\WebformTokenManagerInterface $webform_token_manager */
$webform_token_manager = \Drupal::service('webform.token_manager');
// Message.
$config = \Drupal::configFactory()
->get('webform.settings');
$message = $webform
->getSetting('form_access_denied_message') ?: $config
->get('settings.default_form_access_denied_message');
$message = $webform_token_manager
->replace($message, $webform);
// Attributes.
$attributes = $webform
->getSetting('form_access_denied_attributes');
$attributes['class'][] = 'webform-access-denied';
$build = [
'#type' => 'container',
'#attributes' => $attributes,
'message' => WebformHtmlEditor::checkMarkup($message),
];
return static::addCacheableDependency($build, $webform);
}