diff --git a/modules/core/quick/src/Form/ConfigureQuickForm.php b/modules/core/quick/src/Form/ConfigureQuickForm.php index 22e26ca8f..3bfd5de47 100644 --- a/modules/core/quick/src/Form/ConfigureQuickForm.php +++ b/modules/core/quick/src/Form/ConfigureQuickForm.php @@ -11,6 +11,7 @@ use Drupal\Core\Session\AccountInterface; use Drupal\farm_quick\Plugin\QuickForm\ConfigurableQuickFormInterface; use Drupal\farm_quick\QuickFormInstanceManagerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\Routing\Exception\ResourceNotFoundException; /** * Form that renders quick form configuration forms. @@ -87,10 +88,10 @@ class ConfigureQuickForm extends EntityForm { $quick_form = $this->getQuickFormInstance($quick_form); } - // Deny access if no quick form exists. This is the case with a quick form + // Raise 404 if no quick form exists. This is the case with a quick form // ID that is not a valid quick form plugin ID. if ($quick_form === NULL) { - return AccessResult::forbidden(); + throw new ResourceNotFoundException(); } // Deny access if the quick form plugin is not configurable. diff --git a/modules/core/quick/src/Form/QuickForm.php b/modules/core/quick/src/Form/QuickForm.php index 4fd80caf5..08e04225e 100644 --- a/modules/core/quick/src/Form/QuickForm.php +++ b/modules/core/quick/src/Form/QuickForm.php @@ -8,6 +8,7 @@ use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Session\AccountInterface; use Drupal\farm_quick\QuickFormInstanceManagerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\Routing\Exception\ResourceNotFoundException; /** * Form that renders quick forms. @@ -93,7 +94,12 @@ class QuickForm extends FormBase implements BaseFormIdInterface { * The access result. */ public function access(AccountInterface $account, string $quick_form) { - return $this->quickFormInstanceManager->createInstance($quick_form)->getPlugin()->access($account); + if ($quick_form = $this->quickFormInstanceManager->createInstance($quick_form)) { + return $quick_form->getPlugin()->access($account); + } + + // Raise 404 if the quick form does not exist. + throw new ResourceNotFoundException(); } /**