10000 [FrameworkBundle] Display the class name in 'debug:router' when the c… · symfony/symfony@aadae0d · GitHub
[go: up one dir, main page]

Skip to content

Commit aadae0d

Browse files
committed
[FrameworkBundle] Display the class name in 'debug:router' when the controller is a service
1 parent 3165e13 commit aadae0d

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Symfony\Component\Console\Input\InputOption;
1818
use Symfony\Component\Console\Output\OutputInterface;
1919
use Symfony\Component\Console\Style\SymfonyStyle;
20+
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
2021
use Symfony\Component\Routing\RouterInterface;
2122
use Symfony\Component\Routing\Route;
2223

@@ -85,7 +86,16 @@ protected function execute(InputInterface $input, OutputInterface $output)
8586
throw new \InvalidArgumentException(sprintf('The route "%s" does not exist.', $name));
8687
}
8788

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+
}
8999

90100
$helper->describe($io, $route, array(
91101
'format' => $input->getOption('format'),
@@ -109,8 +119,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
109119

110120
private function convertController(Route $route)
111121
{
112-
$nameParser = $this->getContainer()->get('controller_name_converter');
113122
if ($route->hasDefault('_controller')) {
123+
$nameParser = $this->getContainer()->get('controller_name_converter');
114124
try {
115125
$route->setDefault('_controller', $nameParser->build($route->getDefault('_controller')));
116126
} catch (\InvalidArgumentException $e) {

0 commit comments

Comments
 (0)
0