Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 09f9626

Browse files
committed
[FrameworkBundle] Display the class name in 'debug:router' when the controller is a service
1 parent 4033b60 commit 09f9626

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

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

Lines changed: 11 additions & 1 deletion
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

@@ -87,6 +88,15 @@ protected function execute(InputInterface $input, OutputInterface $output)
8788

8889
$this->convertController($route);
8990

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+
90100
$helper->describe($io, $route, array(
91101
'format' => $input->getOption('format'),
92102
'raw_text' => $input->getOption('raw'),
@@ -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)