Skip to content

Commit 9b78302

Browse files
authored
[make:registration] Make router optional in MakeRegistrationForm constructor (#1227)
1 parent a6423e3 commit 9b78302

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/Maker/MakeRegistrationForm.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ final class MakeRegistrationForm extends AbstractMaker
8585
public function __construct(
8686
private FileManager $fileManager,
8787
private FormTypeRenderer $formTypeRenderer,
88-
private RouterInterface $router,
8988
private DoctrineHelper $doctrineHelper,
89+
private ?RouterInterface $router = null,
9090
) {
9191
}
9292

@@ -111,6 +111,10 @@ public function interact(InputInterface $input, ConsoleStyle $io, Command $comma
111111
{
112112
$interactiveSecurityHelper = new InteractiveSecurityHelper();
113113

114+
if (null === $this->router) {
115+
throw new RuntimeCommandException('Router have been explicitely disabled in your configuration. This command needs to use the router.');
116+
}
117+
114118
if (!$this->fileManager->fileExists($path = 'config/packages/security.yaml')) {
115119
throw new RuntimeCommandException('The file "config/packages/security.yaml" does not exist. This command needs that file to accurately build your registration form.');
116120
}

src/Resources/config/makers.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@
7777
<service id="maker.maker.make_registration_form" class="Symfony\Bundle\MakerBundle\Maker\MakeRegistrationForm">
7878
<argument type="service" id="maker.file_manager" />
7979
<argument type="service" id="maker.renderer.form_type_renderer" />
80-
<argument type="service" id="router" />
8180
<argument type="service" id="maker.doctrine_helper" />
81+
<argument type="service" id="router" on-invalid="ignore" />
8282
<tag name="maker.command" />
8383
</service>
8484

0 commit comments

Comments
 (0)