1111
1212namespace Symfony \Bundle \MakerBundle \Maker ;
1313
14- use Symfony \Bundle \FrameworkBundle \Controller \AbstractController ;
1514use Symfony \Bundle \MakerBundle \ConsoleStyle ;
1615use Symfony \Bundle \MakerBundle \DependencyBuilder ;
1716use Symfony \Bundle \MakerBundle \Doctrine \DoctrineHelper ;
3332use Symfony \Component \Console \Input \InputInterface ;
3433use Symfony \Component \Console \Input \InputOption ;
3534use Symfony \Component \Console \Question \Question ;
35+ use Symfony \Component \HttpKernel \Kernel ;
3636use Symfony \Component \Yaml \Yaml ;
37+ use Symfony \Component \Form \Form ;
3738
3839/**
3940 * @author Ryan Weaver <[email protected] > @@ -101,10 +102,19 @@ public function interact(InputInterface $input, ConsoleStyle $io, Command $comma
101102 $ dependencies = new DependencyBuilder ();
102103 $ dependencies ->addClassDependency (
103104 TwigBundle::class,
104- 'tiwg '
105+ 'twig '
105106 );
107+ $ missingPackagesMessage = 'Twig must be installed to display login form ' ;
106108
107- $ missingPackagesMessage = $ dependencies ->getMissingPackagesMessage (self ::getCommandName (), 'Twig must be installed to display login form ' );
109+ if (Kernel::VERSION_ID < 40100 ) {
110+ $ dependencies ->addClassDependency (
111+ Form::class,
112+ 'symfony/form '
113+ );
114+ $ missingPackagesMessage = 'Twig and symfony/form must be installed to display login form ' ;
115+ }
116+
117+ $ missingPackagesMessage = $ dependencies ->getMissingPackagesMessage (self ::getCommandName (), $ missingPackagesMessage );
108118 if ($ missingPackagesMessage ) {
109119 throw new RuntimeCommandException ($ missingPackagesMessage );
110120 }
@@ -237,7 +247,7 @@ private function generateAuthenticatorClass(InputInterface $input)
237247 'user_class_name ' => $ userClassNameDetails ->getShortName (),
238248 'username_field ' => $ input ->getArgument ('username-field ' ),
239249 'user_needs_encoder ' => $ userNeedsEncoder ,
240- 'user_is_entity ' => $ this ->doctrineHelper ->isClassAMappedEntity ($ input ->getArgument ('user-class ' ))
250+ 'user_is_entity ' => $ this ->doctrineHelper ->isClassAMappedEntity ($ input ->getArgument ('user-class ' )),
241251 ]
242252 );
243253 }
@@ -252,12 +262,9 @@ private function generateFormLoginFiles(InputInterface $input)
252262 );
253263
254264 if (!class_exists ($ controllerClassNameDetails ->getFullName ())) {
255- $ controllerPath = $ this ->generator ->generateClass (
265+ $ controllerPath = $ this ->generator ->generateController (
256266 $ controllerClassNameDetails ->getFullName (),
257- 'authenticator/EmptySecurityController.tpl.php ' ,
258- [
259- 'parent_class_name ' => \method_exists (AbstractController::class, 'getParameter ' ) ? 'AbstractController ' : 'Controller ' ,
260- ]
267+ 'authenticator/EmptySecurityController.tpl.php '
261268 );
262269
263270 $ controllerSourceCode = $ this ->generator ->getFileContents ($ controllerPath );
@@ -282,7 +289,7 @@ private function generateFormLoginFiles(InputInterface $input)
282289 'templates/security/login.html.twig ' ,
283290 'authenticator/login_form.tpl.php ' ,
284291 [
285- 'username_field ' => $ input ->getArgument ('username-field ' )
292+ 'username_field ' => $ input ->getArgument ('username-field ' ),
286293 ]
287294 );
288295 }
0 commit comments