diff --git a/modules/os2forms_nemid/src/Element/MitidChildAddress.php b/modules/os2forms_nemid/src/Element/MitidChildAddress.php index f8daa7a6..04850006 100644 --- a/modules/os2forms_nemid/src/Element/MitidChildAddress.php +++ b/modules/os2forms_nemid/src/Element/MitidChildAddress.php @@ -46,7 +46,7 @@ public static function processMitidChildAddress(&$element, FormStateInterface $f } /** - * Webform element validation handler for #type 'os2forms_mitid_child_address'. + * Webform element validation handler for 'os2forms_mitid_child_address'. */ public static function validateMitidChildAddress(&$element, FormStateInterface $form_state, &$complete_form) { // Here you can add custom validation logic. diff --git a/modules/os2forms_nemid/src/Element/MitidChildApartmentNr.php b/modules/os2forms_nemid/src/Element/MitidChildApartmentNr.php index 65cecc7b..82690966 100644 --- a/modules/os2forms_nemid/src/Element/MitidChildApartmentNr.php +++ b/modules/os2forms_nemid/src/Element/MitidChildApartmentNr.php @@ -46,7 +46,7 @@ public static function processMitidChildApartmentNr(&$element, FormStateInterfac } /** - * Webform element validation handler for #type 'os2forms_mitid_child_apartmentNr'. + * Webform element validation handler 'os2forms_mitid_child_apartmentNr'. */ public static function validateMitidChildApartmentNr(&$element, FormStateInterface $form_state, &$complete_form) { // Here you can add custom validation logic. diff --git a/modules/os2forms_nemid/src/Element/MitidChildCoaddress.php b/modules/os2forms_nemid/src/Element/MitidChildCoaddress.php index 87fd6be0..eb208774 100644 --- a/modules/os2forms_nemid/src/Element/MitidChildCoaddress.php +++ b/modules/os2forms_nemid/src/Element/MitidChildCoaddress.php @@ -46,7 +46,7 @@ public static function processMitidChildCoaddress(&$element, FormStateInterface } /** - * Webform element validation handler for #type 'os2forms_mitid_child_coaddress'. + * Webform element validation handler for 'os2forms_mitid_child_coaddress'. */ public static function validateMitidChildCoaddress(&$element, FormStateInterface $form_state, &$complete_form) { // Here you can add custom validation logic. diff --git a/modules/os2forms_nemid/src/Element/MitidChildHouseNr.php b/modules/os2forms_nemid/src/Element/MitidChildHouseNr.php index f07e3d6a..68ff9e57 100644 --- a/modules/os2forms_nemid/src/Element/MitidChildHouseNr.php +++ b/modules/os2forms_nemid/src/Element/MitidChildHouseNr.php @@ -46,7 +46,7 @@ public static function processMitidChildHouseNr(&$element, FormStateInterface $f } /** - * Webform element validation handler for #type 'os2forms_mitid_child_house_nr'. + * Webform element validation handler for 'os2forms_mitid_child_house_nr'. */ public static function validateMitidChildHouseNr(&$element, FormStateInterface $form_state, &$complete_form) { // Here you can add custom validation logic. diff --git a/modules/os2forms_nemid/src/Element/MitidChildKommunekode.php b/modules/os2forms_nemid/src/Element/MitidChildKommunekode.php index 9b773624..1fc3312f 100644 --- a/modules/os2forms_nemid/src/Element/MitidChildKommunekode.php +++ b/modules/os2forms_nemid/src/Element/MitidChildKommunekode.php @@ -46,7 +46,7 @@ public static function processMitidChildKommunekode(&$element, FormStateInterfac } /** - * Webform element validation handler for #type 'os2forms_mitid_child_kommunekode'. + * Webform element validation handler for 'os2forms_mitid_child_kommunekode'. */ public static function validateMitidChildKommunekode(&$element, FormStateInterface $form_state, &$complete_form) { // Here you can add custom validation logic. diff --git a/modules/os2forms_nemid/src/Element/MitidChildOtherGuardian.php b/modules/os2forms_nemid/src/Element/MitidChildOtherGuardian.php index 31e99f9c..b8b54d99 100644 --- a/modules/os2forms_nemid/src/Element/MitidChildOtherGuardian.php +++ b/modules/os2forms_nemid/src/Element/MitidChildOtherGuardian.php @@ -24,21 +24,21 @@ public function getInfo() { $class = static::class; $parentInfo = parent::getInfo() + [ - '#element_validate' => [ - [$class, 'validateMitidChildOtherGuardian'], - ], - ]; + '#element_validate' => [ + [$class, 'validateMitidChildOtherGuardian'], + ], + ]; // Adding custom #pre_render. $parentInfo['#pre_render'] = [ - [$class, 'preRenderMitidChildOtherGuardian'] + [$class, 'preRenderMitidChildOtherGuardian'], ]; return $parentInfo; } /** - * Webform element validation handler for #type 'os2forms_mitid_child_other_guardian'. + * Webform element validation handler 'os2forms_mitid_child_other_guardian'. */ public static function validateMitidChildOtherGuardian(&$element, FormStateInterface $form_state, &$complete_form) { // Here you can add custom validation logic. @@ -49,7 +49,10 @@ public static function validateMitidChildOtherGuardian(&$element, FormStateInter */ public static function preRenderMitidChildOtherGuardian($element) { $element = parent::preRenderHidden($element); - static::setAttributes($element, ['os2forms-mitid-child-other-guardian', 'js-form-type-os2forms-mitid-child-other-guardian']); + static::setAttributes($element, [ + 'os2forms-mitid-child-other-guardian', + 'js-form-type-os2forms-mitid-child-other-guardian', + ]); return $element; } diff --git a/modules/os2forms_nemid/src/Element/MitidChildPostalCode.php b/modules/os2forms_nemid/src/Element/MitidChildPostalCode.php index d78da623..9c6db66c 100644 --- a/modules/os2forms_nemid/src/Element/MitidChildPostalCode.php +++ b/modules/os2forms_nemid/src/Element/MitidChildPostalCode.php @@ -46,7 +46,7 @@ public static function processMitidChildPostalCode(&$element, FormStateInterface } /** - * Webform element validation handler for #type 'os2forms_mitid_child_postal_code'. + * Webform element validation handler for 'os2forms_mitid_child_postal_code'. */ public static function validateMitidChildPostalCode(&$element, FormStateInterface $form_state, &$complete_form) { // Here you can add custom validation logic. diff --git a/modules/os2forms_nemid/src/Element/MitidChildrenSelectAjaxBehaviour.php b/modules/os2forms_nemid/src/Element/MitidChildrenSelectAjaxBehaviour.php index 31570084..2badc955 100644 --- a/modules/os2forms_nemid/src/Element/MitidChildrenSelectAjaxBehaviour.php +++ b/modules/os2forms_nemid/src/Element/MitidChildrenSelectAjaxBehaviour.php @@ -9,10 +9,25 @@ use Drupal\os2forms_nemid\Service\FormsHelper; /** - * Provides a children select ajax behaviour for MitidChildrenSelect and MitidChildrenRadios. + * Provides a children select ajax behaviour. + * + * User in MitidChildrenSelect and MitidChildrenRadios. */ class MitidChildrenSelectAjaxBehaviour { + /** + * Ajax function to update fields after child select. + * + * @param array $form + * Form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * Form state. + * + * @return \Drupal\Core\Ajax\AjaxResponse + * Ajax response + * + * @throws \Drupal\Component\Plugin\Exception\PluginException + */ public static function mitidChildrenSelectAjax(array &$form, FormStateInterface $form_state) { $response = new AjaxResponse(); @@ -47,46 +62,57 @@ public static function mitidChildrenSelectAjax(array &$form, FormStateInterface $element['#value'] = !$cprLookupResult->isNameAddressProtected() ? $cprLookupResult->getName() : 'Navne- og adressebeskyttet'; $response->addCommand(new ReplaceCommand('.js-form-type-os2forms-mitid-child-name', $element)); break; + case 'os2forms_mitid_child_cpr': $element['#value'] = $cprLookupResult->getCpr(); $response->addCommand(new ReplaceCommand('.js-form-type-os2forms-mitid-child-cpr', $element)); break; + case 'os2forms_mitid_child_address': $element['#value'] = !$cprLookupResult->isNameAddressProtected() ? $cprLookupResult->getAddress() : 'Navne- og adressebeskyttet'; $response->addCommand(new ReplaceCommand('.js-form-type-os2forms-mitid-child-address', $element)); break; + case 'os2forms_mitid_child_apartment_nr': $element['#value'] = !$cprLookupResult->isNameAddressProtected() ? $cprLookupResult->getApartmentNr() : 'Navne- og adressebeskyttet'; $response->addCommand(new ReplaceCommand('.js-form-type-os2forms-mitid-child-apartment-nr', $element)); break; + case 'os2forms_mitid_child_city': $element['#value'] = !$cprLookupResult->isNameAddressProtected() ? $cprLookupResult->getCity() : 'Navne- og adressebeskyttet'; $response->addCommand(new ReplaceCommand('.js-form-type-os2forms-mitid-child-city', $element)); break; + case 'os2forms_mitid_child_coaddress': $element['#value'] = !$cprLookupResult->isNameAddressProtected() ? $cprLookupResult->getCoName() : 'Navne- og adressebeskyttet'; $response->addCommand(new ReplaceCommand('.js-form-type-os2forms-mitid-child-coaddress', $element)); break; + case 'os2forms_mitid_child_floor': $element['#value'] = !$cprLookupResult->isNameAddressProtected() ? $cprLookupResult->getFloor() : 'Navne- og adressebeskyttet'; $response->addCommand(new ReplaceCommand('.js-form-type-os2forms-mitid-child-floor', $element)); break; + case 'os2forms_mitid_child_house_nr': $element['#value'] = !$cprLookupResult->isNameAddressProtected() ? $cprLookupResult->getHouseNr() : 'Navne- og adressebeskyttet'; $response->addCommand(new ReplaceCommand('.js-form-type-os2forms-mitid-child-house-nr', $element)); break; + case 'os2forms_mitid_child_kommunekode': $element['#value'] = !$cprLookupResult->isNameAddressProtected() ? $cprLookupResult->getMunicipalityCode() : 'Navne- og adressebeskyttet'; $response->addCommand(new ReplaceCommand('.js-form-type-os2forms-mitid-child-kommunekode', $element)); break; + case 'os2forms_mitid_child_postal_code': $element['#value'] = !$cprLookupResult->isNameAddressProtected() ? $cprLookupResult->getPostalCode() : 'Navne- og adressebeskyttet'; $response->addCommand(new ReplaceCommand('.js-form-type-os2forms-mitid-child-postal-code', $element)); break; + case 'os2forms_mitid_child_street': $element['#value'] = !$cprLookupResult->isNameAddressProtected() ? $cprLookupResult->getStreet() : 'Navne- og adressebeskyttet'; $response->addCommand(new ReplaceCommand('.js-form-type-os2forms-mitid-child-street', $element)); break; + case 'os2forms_mitid_child_other_guardian': $otherGuardianCpr = NULL; $allGuardians = $cprLookupResult->getGuardians(); @@ -115,4 +141,5 @@ public static function mitidChildrenSelectAjax(array &$form, FormStateInterface return $response; } + } diff --git a/modules/os2forms_nemid/src/Element/NemidChildrenRadios.php b/modules/os2forms_nemid/src/Element/NemidChildrenRadios.php index bf188756..7545f5bb 100644 --- a/modules/os2forms_nemid/src/Element/NemidChildrenRadios.php +++ b/modules/os2forms_nemid/src/Element/NemidChildrenRadios.php @@ -2,7 +2,6 @@ namespace Drupal\os2forms_nemid\Element; -use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\Element\Radios; /** @@ -23,14 +22,15 @@ class NemidChildrenRadios extends Radios { */ public function getInfo() { return parent::getInfo() + [ - '#ajax' => [ - 'callback' => [MitidChildrenSelectAjaxBehaviour::class, 'mitidChildrenSelectAjax'], - 'event' => 'change', - 'progress' => [ - 'type' => 'throbber', - 'message' => $this->t('Please wait...'), - ], + '#ajax' => [ + 'callback' => [MitidChildrenSelectAjaxBehaviour::class, 'mitidChildrenSelectAjax'], + 'event' => 'change', + 'progress' => [ + 'type' => 'throbber', + 'message' => $this->t('Please wait...'), ], - ]; + ], + ]; } + } diff --git a/modules/os2forms_nemid/src/Element/NemidChildrenSelect.php b/modules/os2forms_nemid/src/Element/NemidChildrenSelect.php index 567021f4..bc0382d2 100644 --- a/modules/os2forms_nemid/src/Element/NemidChildrenSelect.php +++ b/modules/os2forms_nemid/src/Element/NemidChildrenSelect.php @@ -22,15 +22,15 @@ class NemidChildrenSelect extends Select { */ public function getInfo() { return parent::getInfo() + [ - '#ajax' => [ - 'callback' => [MitidChildrenSelectAjaxBehaviour::class, 'mitidChildrenSelectAjax'], - 'event' => 'change', - 'progress' => [ - 'type' => 'throbber', - 'message' => $this->t('Please wait...'), - ], + '#ajax' => [ + 'callback' => [MitidChildrenSelectAjaxBehaviour::class, 'mitidChildrenSelectAjax'], + 'event' => 'change', + 'progress' => [ + 'type' => 'throbber', + 'message' => $this->t('Please wait...'), ], - ]; + ], + ]; } } diff --git a/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildAddress.php b/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildAddress.php index ace06e71..d1e512ba 100644 --- a/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildAddress.php +++ b/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildAddress.php @@ -2,8 +2,6 @@ namespace Drupal\os2forms_nemid\Plugin\WebformElement; -use Drupal\webform\Plugin\WebformElementBase; - /** * Provides a 'os2forms_mitid_child_address' element. * diff --git a/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildApartmentNr.php b/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildApartmentNr.php index 2abcc654..e8b1ac97 100644 --- a/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildApartmentNr.php +++ b/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildApartmentNr.php @@ -2,8 +2,6 @@ namespace Drupal\os2forms_nemid\Plugin\WebformElement; -use Drupal\webform\Plugin\WebformElementBase; - /** * Provides a 'os2forms_mitid_child_apartment_nr' element. * diff --git a/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildCity.php b/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildCity.php index e99fd58c..002a0962 100644 --- a/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildCity.php +++ b/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildCity.php @@ -2,8 +2,6 @@ namespace Drupal\os2forms_nemid\Plugin\WebformElement; -use Drupal\webform\Plugin\WebformElementBase; - /** * Provides a 'os2forms_mitid_child_city' element. * diff --git a/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildCoaddress.php b/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildCoaddress.php index 35ea0b75..ccb1f535 100644 --- a/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildCoaddress.php +++ b/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildCoaddress.php @@ -2,8 +2,6 @@ namespace Drupal\os2forms_nemid\Plugin\WebformElement; -use Drupal\webform\Plugin\WebformElementBase; - /** * Provides a 'os2forms_mitid_child_coadress' element. * diff --git a/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildCpr.php b/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildCpr.php index 9d26dc05..b16e511f 100644 --- a/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildCpr.php +++ b/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildCpr.php @@ -2,8 +2,6 @@ namespace Drupal\os2forms_nemid\Plugin\WebformElement; -use Drupal\webform\Plugin\WebformElementBase; - /** * Provides a 'os2forms_mitid_child_cpr' element. * diff --git a/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildElementBase.php b/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildElementBase.php index bfe9a630..fbdd7dca 100644 --- a/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildElementBase.php +++ b/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildElementBase.php @@ -24,13 +24,13 @@ public function getDefaultProperties() { // @see \Drupal\webform\Plugin\WebformElementBase::getDefaultProperties // @see \Drupal\webform\Plugin\WebformElementBase::getDefaultBaseProperties $properties = parent::getDefaultProperties() + [ - 'multiple' => '', - 'size' => '', - 'minlength' => '', - 'maxlength' => '', - 'placeholder' => '', - 'readonly' => '', - ]; + 'multiple' => '', + 'size' => '', + 'minlength' => '', + 'maxlength' => '', + 'placeholder' => '', + 'readonly' => '', + ]; return $properties; } diff --git a/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildFloor.php b/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildFloor.php index ec8371b6..c9ac4725 100644 --- a/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildFloor.php +++ b/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildFloor.php @@ -2,8 +2,6 @@ namespace Drupal\os2forms_nemid\Plugin\WebformElement; -use Drupal\webform\Plugin\WebformElementBase; - /** * Provides a 'os2forms_mitid_child_floor' element. * diff --git a/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildHouseNr.php b/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildHouseNr.php index 5f94d38c..62eb97c3 100644 --- a/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildHouseNr.php +++ b/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildHouseNr.php @@ -2,8 +2,6 @@ namespace Drupal\os2forms_nemid\Plugin\WebformElement; -use Drupal\webform\Plugin\WebformElementBase; - /** * Provides a 'os2forms_mitid_child_house_nr' element. * diff --git a/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildKommunekode.php b/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildKommunekode.php index 1413727a..60940db4 100644 --- a/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildKommunekode.php +++ b/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildKommunekode.php @@ -2,8 +2,6 @@ namespace Drupal\os2forms_nemid\Plugin\WebformElement; -use Drupal\webform\Plugin\WebformElementBase; - /** * Provides a 'os2forms_mitid_child_kommunekode' element. * diff --git a/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildName.php b/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildName.php index e5d436f6..d9971f9b 100644 --- a/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildName.php +++ b/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildName.php @@ -2,8 +2,6 @@ namespace Drupal\os2forms_nemid\Plugin\WebformElement; -use Drupal\webform\Plugin\WebformElementBase; - /** * Provides a 'os2forms_mitid_child_name' element. * diff --git a/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildOtherGuardian.php b/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildOtherGuardian.php index 3347c17e..54dc97d5 100644 --- a/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildOtherGuardian.php +++ b/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildOtherGuardian.php @@ -17,6 +17,9 @@ */ class MitidChildOtherGuardian extends Hidden { + /** + * {@inheritdoc} + */ public function getValue(array $element, WebformSubmissionInterface $webform_submission, array $options = []) { if (isset($options['email']) || isset($options['pdf'])) { return ''; @@ -24,4 +27,5 @@ public function getValue(array $element, WebformSubmissionInterface $webform_sub return parent::getValue($element, $webform_submission, $options); } + } diff --git a/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildPostalCode.php b/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildPostalCode.php index 642584cd..1f365c62 100644 --- a/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildPostalCode.php +++ b/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildPostalCode.php @@ -2,8 +2,6 @@ namespace Drupal\os2forms_nemid\Plugin\WebformElement; -use Drupal\webform\Plugin\WebformElementBase; - /** * Provides a 'os2forms_mitid_child_postal_code' element. * diff --git a/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildStreet.php b/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildStreet.php index 606bc25f..44ad2964 100644 --- a/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildStreet.php +++ b/modules/os2forms_nemid/src/Plugin/WebformElement/MitidChildStreet.php @@ -2,8 +2,6 @@ namespace Drupal\os2forms_nemid\Plugin\WebformElement; -use Drupal\webform\Plugin\WebformElementBase; - /** * Provides a 'os2forms_mitid_child_street' element. * diff --git a/modules/os2forms_nemid/src/Plugin/WebformElement/ServiceplatformenCprElementBase.php b/modules/os2forms_nemid/src/Plugin/WebformElement/ServiceplatformenCprElementBase.php index 6567c6e3..e77530a3 100644 --- a/modules/os2forms_nemid/src/Plugin/WebformElement/ServiceplatformenCprElementBase.php +++ b/modules/os2forms_nemid/src/Plugin/WebformElement/ServiceplatformenCprElementBase.php @@ -38,9 +38,9 @@ public function handleElementPrepopulate(array &$element, FormStateInterface &$f } /** - * Appends name and address protected text, if person has name/address protection. + * Appends name/address protected text, if person has name/address protection. * - * @param CprLookupResult $cprLookupResult + * @param \Drupal\os2web_datalookup\LookupResult\CprLookupResult $cprLookupResult * Initialized CprLooupResult. * * @return string diff --git a/modules/os2forms_nemid/src/Service/FormsHelper.php b/modules/os2forms_nemid/src/Service/FormsHelper.php index d25606cc..55ace01b 100644 --- a/modules/os2forms_nemid/src/Service/FormsHelper.php +++ b/modules/os2forms_nemid/src/Service/FormsHelper.php @@ -139,7 +139,7 @@ public function retrieveCprLookupResult(FormStateInterface $form_state) { * CPRLookupResult or NULL. */ public static function retrieveCachedCprLookupResult(FormStateInterface $form_state) { - /** @var CprLookupResult $cprLookupResult */ + /** @var \Drupal\os2web_datalookup\LookupResult\CprLookupResult $cprLookupResult */ $cprLookupResult = NULL; // Trying to fetch person data from cache.