diff --git a/src/Service/UwCustomFormsService.php b/src/Service/UwCustomFormsService.php index b5aeebd2a5c3ff50f143a2005323f57933ef59d1..3b08a1641761ac0cd4682cfe7a497cf1e2142ba0 100644 --- a/src/Service/UwCustomFormsService.php +++ b/src/Service/UwCustomFormsService.php @@ -348,14 +348,24 @@ class UwCustomFormsService { // Get the forms from the config. $forms = $this->configFactory->getEditable('uw_custom_forms.settings')->get('allowed_forms'); - foreach ($forms as $form) { - if ($form) { - $user = $this->entityTypeManager - ->getStorage('user') - ->load($this->currentUser->id()); - - if ($this->checkUserAccess($user, $form) instanceof AccessResultAllowed) { - $allowed_forms[] = $form; + // If there are forms, then get the info. + if ($forms) { + + // Step through each of the forms, and get the info. + foreach ($forms as $form) { + + // If there is a form, get its info. + if ($form) { + + // Get the user. + $user = $this->entityTypeManager + ->getStorage('user') + ->load($this->currentUser->id()); + + // If the user has access, then add it to the array. + if ($this->checkUserAccess($user, $form) instanceof AccessResultAllowed) { + $allowed_forms[] = $form; + } } } }