From 1ae74d01f7e0e1df3021fe73251bf7bbf0b25321 Mon Sep 17 00:00:00 2001 From: Liam Morland <lkmorlan@uwaterloo.ca> Date: Wed, 15 Dec 2021 11:09:53 -0500 Subject: [PATCH] ISTWCMS-5252: Set all Webforms to use the access denied page Create uw_cfg_common_update_9102(). --- uw_cfg_common.install | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/uw_cfg_common.install b/uw_cfg_common.install index 9c8f3145..76100b58 100644 --- a/uw_cfg_common.install +++ b/uw_cfg_common.install @@ -11,6 +11,7 @@ use Drupal\taxonomy\Entity\Term; use Drupal\user\Entity\Role; use Drupal\uw_cfg_common\UwPermissions\UwPermissions; use Drupal\uw_cfg_common\UwRoles\UwRoles; +use Drupal\webform\WebformInterface; /** * Implements hook_install(). @@ -565,3 +566,15 @@ function uw_cfg_common_update_9101() { } } } + +/** + * Set all Webforms to use the access denied page. + */ +function uw_cfg_common_update_9102() { + $webforms = \Drupal::entityTypeManager()->getStorage('webform')->loadMultiple(); + foreach ($webforms as $webform) { + // This is set as the default in uw_cfg_common_webform_create(). + $webform->setSetting('form_access_denied', WebformInterface::ACCESS_DENIED_PAGE); + $webform->save(); + } +} -- GitLab