diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php index f516f96d2a..e4b49a2679 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\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Routing\RouterInterface; +use Symfony\Component\Routing\Route; /** * A console command for retrieving information about routes @@ -80,6 +81,7 @@ EOF if (!$route) { throw new \InvalidArgumentException(sprintf('The route "%s" does not exist.', $name)); } + $this->convertController($route); $helper->describe($output, $route, array( 'format' => $input->getOption('format'), 'raw_text' => $input->getOption('raw'), @@ -87,6 +89,11 @@ EOF )); } else { $routes = $this->getContainer()->get('router')->getRouteCollection(); + + foreach ($routes as $route) { + $this->convertController($route); + } + $helper->describe($output, $routes, array( 'format' => $input->getOption('format'), 'raw_text' => $input->getOption('raw'), @@ -94,4 +101,15 @@ EOF )); } } + + private function convertController(Route $route) + { + $nameParser = $this->getContainer()->get('controller_name_converter'); + if ($route->hasDefault('_controller')) { + try { + $route->setDefault('_controller', $nameParser->build($route->getDefault('_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 9a9b6fd0fd..d1fba8e3b5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php @@ -35,14 +35,11 @@ class TextDescriptor extends Descriptor ); if ($showControllers) { - $defaultData = $route->getDefaults(); - $controller = $defaultData['_controller'] ? $defaultData['_controller'] : ''; + $controller = $route->getDefault('_controller'); if ($controller instanceof \Closure) { $controller = 'Closure'; - } else { - if (is_object($controller)) { - $controller = get_class($controller); - } + } elseif (is_object($controller)) { + $controller = get_class($controller); } $row[] = $controller; }