13
13
14
14
use Symfony \Bundle \MakerBundle \ConsoleStyle ;
15
15
use Symfony \Bundle \MakerBundle \DependencyBuilder ;
16
+ use Symfony \Bundle \MakerBundle \Generator ;
16
17
use Symfony \Bundle \MakerBundle \Str ;
17
18
use Symfony \Bundle \MakerBundle \Validator ;
18
19
use Symfony \Component \Console \Input \InputArgument ;
19
20
use Symfony \Component \Console \Input \InputInterface ;
20
21
use Symfony \Component \Console \Output \OutputInterface ;
22
+ use Symfony \Component \Routing \RouterInterface ;
21
23
use Sensio \Bundle \FrameworkExtraBundle \Configuration \Route ;
22
24
23
25
/**
@@ -28,6 +30,15 @@ final class MakeControllerCommand extends AbstractCommand
28
30
{
29
31
protected static $ defaultName = 'make:controller ' ;
30
32
33
+ private $ router ;
34
+
35
+ public function __construct (Generator $ generator , RouterInterface $ router )
36
+ {
37
+ $ this ->router = $ router ;
38
+
39
+ parent ::__construct ($ generator );
40
+ }
41
+
31
42
public function configure ()
32
43
{
33
44
$ this
@@ -63,6 +74,11 @@ protected function getResultMessage(array $params): string
63
74
64
75
protected function writeNextStepsMessage (array $ params , ConsoleStyle $ io )
65
76
{
77
+ if (!count ($ this ->router ->getRouteCollection ())) {
78
+ $ io ->text ('<error> Warning! </> No routes configuration defined yet. ' );
79
+ $ io ->text (' You should probably uncomment the annotation routes in <comment>config/routes.yaml</> ' );
80
+ $ io ->newLine ();
81
+ }
66
82
$ io ->text ('Next: Open your new controller class and add some pages! ' );
67
83
}
68
84
0 commit comments