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
@@ -85,7 +86,16 @@ protected function execute(InputInterface $input, OutputInterface $output)
85
86
throw new \InvalidArgumentException (sprintf ('The route "%s" does not exist. ' , $ name ));
86
87
}
87
88
88
- $ this ->convertController ($ route );
89
+ // Converts a short notation service:method to a class::method.
BCFF
90
+ if ('txt ' === $ input ->getOption ('format ' ) && $ route ->hasDefault ('_controller ' ) && 1 === substr_count ($ route ->getDefault ('_controller ' ), ': ' )) {
91
+ list ($ service , $ method ) = explode (': ' , $ route ->getDefault ('_controller ' ));
92
+ try {
93
+ $ route ->setDefault ('_controller ' , sprintf ("%s::%s \n (service: %s) " , get_class ($ this ->getContainer ()->get ($ service )), $ method , $ service ));
94
+ } catch (ServiceNotFoundException $ e ) {
95
+ }
96
+ } else {
97
+ $ this ->convertController ($ route );
98
+ }
89
99
90
100
$ helper ->describe ($ io , $ route , array (
91
101
'format ' => $ input ->getOption ('format ' ),
@@ -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