diff --git a/modules/os2forms_nemid/os2forms_nemid.module b/modules/os2forms_nemid/os2forms_nemid.module index 39520843..84d8477f 100644 --- a/modules/os2forms_nemid/os2forms_nemid.module +++ b/modules/os2forms_nemid/os2forms_nemid.module @@ -84,7 +84,6 @@ function os2forms_nemid_webform_third_party_settings_form_alter(&$form, FormStat '#description' => t('Redirection will happen right after user has is accessing the form, if user is already authenticated via NemID, redirection will not happen.'), ]; - $nemloginProtectionSettings = $webform->getThirdPartySetting('os2forms', 'os2forms_nemid_address_protection'); // OS2Forms NemID. @@ -94,7 +93,6 @@ function os2forms_nemid_webform_third_party_settings_form_alter(&$form, FormStat '#open' => TRUE, ]; - // Nemlogin auto redirect. $form['third_party_settings']['os2forms']['os2forms_nemid_address_protection']['nemlogin_hide_form'] = [ '#type' => 'select', @@ -119,7 +117,7 @@ function os2forms_nemid_webform_third_party_settings_form_alter(&$form, FormStat ], 'required' => [ [':input[name="third_party_settings[os2forms][os2forms_nemid_address_protection][nemlogin_hide_form]"]' => ['value' => FormsHelper::WEBFORM_NEM_LOGIN_ADDRESS_PROTECTION_DISPLAY_ERROR]], - ] + ], ], ]; } @@ -129,7 +127,7 @@ function os2forms_nemid_webform_third_party_settings_form_alter(&$form, FormStat */ function os2forms_nemid_webform_submission_form_alter(array &$form, FormStateInterface $form_state, $form_id) { - // Handle address protection + // Handle address protection. if ($tempValue = $form_state->getTemporaryValue(FormsHelper::TEMPORARY_KEY)) { if (FALSE === ($tempValue['access'] ?? TRUE)) { // Flattening the elements makes it much easier to access nested elements. diff --git a/modules/os2forms_nemid/src/Service/FormsHelper.php b/modules/os2forms_nemid/src/Service/FormsHelper.php index b7b21d18..d67723e8 100644 --- a/modules/os2forms_nemid/src/Service/FormsHelper.php +++ b/modules/os2forms_nemid/src/Service/FormsHelper.php @@ -46,7 +46,7 @@ class FormsHelper { 'os2forms_nemid_postal_code', 'os2forms_nemid_city', 'os2forms_nemid_kommunekode', - 'os2forms_nemid_coaddress' + 'os2forms_nemid_coaddress', ]; /** @@ -77,6 +77,8 @@ class FormsHelper { * Auth provider service. * @param \Drupal\os2web_datalookup\Plugin\DataLookupManager $dataLookPluginManager * Datalookup plugin manager. + * @param \Drupal\Core\Routing\RouteMatchInterface $routeMatch + * Route match service. */ public function __construct(AuthProviderService $authProviderService, DataLookupManager $dataLookPluginManager, RouteMatchInterface $routeMatch) { $this->authProviderService = $authProviderService; @@ -361,7 +363,7 @@ public function webformSubmissionPrepareForm(WebformSubmissionInterface $webform return; } - // Check if hide address protection is selected + // Check if hide address protection is selected. $hideForm = $webformSubmission->getWebform()->getThirdPartySettings('os2forms')['os2forms_nemid_address_protection']['nemlogin_hide_form'] ?? NULL; if ($hideForm === self::WEBFORM_NEM_LOGIN_ADDRESS_PROTECTION_DISPLAY_ERROR) { @@ -369,19 +371,21 @@ public function webformSubmissionPrepareForm(WebformSubmissionInterface $webform if ($cprResult && $cprResult->isNameAddressProtected()) { - // Check if any element violating address protection is present in webform. - $elements = $webformSubmission->getWebform()->getElementsDecodedAndFlattened(); + // Check if any element violating address + // protection is present in webform. + $elements = $webformSubmission->getWebform()->getElementsDecodedAndFlattened(); foreach ($elements as $element) { - if(in_array($element['#type'], self::WEBFORM_NEM_LOGIN_ADDRESS_PROTECTION_ELEMENT_TYPES)) { + if (in_array($element['#type'], self::WEBFORM_NEM_LOGIN_ADDRESS_PROTECTION_ELEMENT_TYPES)) { - // Violation detected, mark form state with temporary key and return. + // Violation detected, + // mark form state with temporary key and return. $message = $webformSubmission->getWebform()->getThirdPartySettings('os2forms')['os2forms_nemid_address_protection']['nemlogin_hide_message']; $formState->setTemporaryValue(self::TEMPORARY_KEY, [ 'access' => FALSE, - 'message' => $message + 'message' => $message, ]); return; @@ -390,4 +394,5 @@ public function webformSubmissionPrepareForm(WebformSubmissionInterface $webform } } } + }