17
17
use Symfony \Component \Console \Input \InputOption ;
18
18
use Symfony \Component \Console \Output \OutputInterface ;
19
19
use Symfony \Component \Console \Style \SymfonyStyle ;
20
+ use Symfony \Component \DependencyInjection \Exception \ServiceNotFoundException ;
20
21
use Symfony \Component \Routing \RouterInterface ;
21
22
use Symfony \Component \Routing \Route ;
22
23
@@ -87,6 +88,15 @@ protected function execute(InputInterface $input, OutputInterface $output)
87
88
88
89
$ this ->convertController ($ route );
89
90
91
+ // Converts a short notation service:method to a class::method.
92
+ if ($ route ->hasDefault ('_controller ' ) && 'txt ' === $ input ->getOption ('format ' )) {
93
+ list ($ service , $ method ) = explode (': ' , $ route ->getDefault ('_controller ' ), 2 );
94
+ try {
95
+ $ route ->setDefault ('_controller ' , sprintf ("%s:%s \n (service: %s) " , get_class ($ this ->getContainer ()->get ($ service )), $ method , $ service ));
96
+ } catch (ServiceNotFoundException $ e ) {
97
+ }
98
+ }
99
+
90
100
$ helper ->describe ($ io , $ route , array (
91
101
'format ' => $ input ->getOption ('format ' ),
92
102
'raw_text ' => $ input ->getOption ('raw ' ),
@@ -109,8 +119,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
109
119
110
120
private function convertController (Route $ route )
111
121
{
112
- $ nameParser = $ this ->getContainer ()->get ('controller_name_converter ' );
113
122
if ($ route ->hasDefault ('_controller ' )) {
123
+ $ nameParser = $ this ->getContainer ()->get ('controller_name_converter ' );
114
124
try {
115
125
$ route ->setDefault ('_controller ' , $ nameParser ->build ($ route ->getDefault ('_controller ' )));
116
126
} catch (\InvalidArgumentException $ e ) {
0 commit comments