From f938befbe716d2415de41d1cf0a684167fb7d9b9 Mon Sep 17 00:00:00 2001 From: Olivier Dolbeau Date: Sun, 23 Oct 2022 11:58:43 +0200 Subject: [PATCH] Make router optional in MakeRegistrationForm constructor --- src/Maker/MakeRegistrationForm.php | 6 +++++- src/Resources/config/makers.xml | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Maker/MakeRegistrationForm.php b/src/Maker/MakeRegistrationForm.php index e8c66d4cb..501c98ea6 100644 --- a/src/Maker/MakeRegistrationForm.php +++ b/src/Maker/MakeRegistrationForm.php @@ -85,8 +85,8 @@ final class MakeRegistrationForm extends AbstractMaker public function __construct( private FileManager $fileManager, private FormTypeRenderer $formTypeRenderer, - private RouterInterface $router, private DoctrineHelper $doctrineHelper, + private ?RouterInterface $router = null, ) { } @@ -111,6 +111,10 @@ public function interact(InputInterface $input, ConsoleStyle $io, Command $comma { $interactiveSecurityHelper = new InteractiveSecurityHelper(); + if (null === $this->router) { + throw new RuntimeCommandException('Router have been explicitely disabled in your configuration. This command needs to use the router.'); + } + if (!$this->fileManager->fileExists($path = 'config/packages/security.yaml')) { throw new RuntimeCommandException('The file "config/packages/security.yaml" does not exist. This command needs that file to accurately build your registration form.'); } diff --git a/src/Resources/config/makers.xml b/src/Resources/config/makers.xml index 271bba21a..8ea8f6ba9 100644 --- a/src/Resources/config/makers.xml +++ b/src/Resources/config/makers.xml @@ -77,8 +77,8 @@ - +