Skip to content
Snippets Groups Projects
Commit abf2b02b authored by Liam Morland's avatar Liam Morland
Browse files

ISTWCMS-5253: Use hook_preprocess_HOOK() to set custom "access denied" message

Replace uw_cfg_common_webform_build_access_denied_alter() with
uw_cfg_common_preprocess_webform_access_denied().
parent 923665db
No related branches found
No related tags found
1 merge request!194ISTWCMS-5253: Use hook_preprocess_HOOK() to set custom "access denied" message
...@@ -1037,11 +1037,13 @@ function uw_cfg_common_get_user_ad_groups(): ?array { ...@@ -1037,11 +1037,13 @@ function uw_cfg_common_get_user_ad_groups(): ?array {
} }
/** /**
* Implements hook_webform_build_access_denied_alter(). * Implements hook_preprocess_HOOK().
* *
* Custom access denied messages with login/logout links. * Custom access denied messages with login/logout links.
*/ */
function uw_cfg_common_webform_build_access_denied_alter(array &$build, WebformInterface $webform): void { function uw_cfg_common_preprocess_webform_access_denied(array &$variables): void {
$webform = $variables['webform'];
$message = NULL; $message = NULL;
switch ($webform->getThirdPartySetting('uw_cfg_common', 'access_control_method')) { switch ($webform->getThirdPartySetting('uw_cfg_common', 'access_control_method')) {
case 'auth': case 'auth':
...@@ -1070,9 +1072,7 @@ function uw_cfg_common_webform_build_access_denied_alter(array &$build, WebformI ...@@ -1070,9 +1072,7 @@ function uw_cfg_common_webform_build_access_denied_alter(array &$build, WebformI
// phpcs:ignore Drupal.Semantics.FunctionT.NotLiteralString // phpcs:ignore Drupal.Semantics.FunctionT.NotLiteralString
$message = '<p>' . t($message, ['@url' => $url->toString()]) . '</p>'; $message = '<p>' . t($message, ['@url' => $url->toString()]) . '</p>';
$build['message'] = [ $variables['message']['#markup'] = $message;
'#markup' => $message,
];
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment