diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php index 97707e8798b59..22f0bc6795d5b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php @@ -17,6 +17,7 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; +use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException; use Symfony\Component\Routing\RouterInterface; use Symfony\Component\Routing\Route; @@ -85,13 +86,14 @@ protected function execute(InputInterface $input, OutputInterface $output) throw new \InvalidArgumentException(sprintf('The route "%s" does not exist.', $name)); } - $this->convertController($route); + $callable = $this->extractCallable($route); $helper->describe($io, $route, array( 'format' => $input->getOption('format'), 'raw_text' => $input->getOption('raw'), 'name' => $name, 'output' => $io, + 'callable' => $callable, )); } else { foreach ($routes as $route) { @@ -109,12 +111,38 @@ protected function execute(InputInterface $input, OutputInterface $output) private function convertController(Route $route) { - $nameParser = $this->getContainer()->get('controller_name_converter'); if ($route->hasDefault('_controller')) { + $nameParser = $this->getContainer()->get('controller_name_converter'); try { $route->setDefault('_controller', $nameParser->build($route->getDefault('_controller'))); } catch (\InvalidArgumentException $e) { } } } + + private function extractCallable(Route $route) + { + if (!$route->hasDefault('_controller')) { + return; + } + + $controller = $route->getDefault('_controller'); + + if (1 === substr_count($controller, ':')) { + list($service, $method) = explode(':', $controller); + try { + return sprintf('%s::%s', get_class($this->getContainer()->get($service)), $method); + } catch (ServiceNotFoundException $e) { + } + } + + $nameParser = $this->getContainer()->get('controller_name_converter'); + try { + $shortNotation = $nameParser->build($controller); + $route->setDefault('_controller', $shortNotation); + + return $controller; + } catch (\InvalidArgumentException $e) { + } + } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php index 06ea508f613fc..a2c8a314e3306 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php @@ -92,6 +92,9 @@ protected function describeRoute(Route $route, array $options = array()) array('Defaults', $this->formatRouterConfig($route->getDefaults())), array('Options', $this->formatRouterConfig($route->getOptions())), ); + if (isset($options['callable'])) { + $tableRows[] = array('Callable', $options['callable']); + } $table = new Table($this->getOutput()); $table->setHeaders($tableHeaders)->setRows($tableRows);