Skip to content

Commit

Permalink
[FrameworkBundle] changed the router:debug to use the shortcut notati…
Browse files Browse the repository at this point in the history
…on for the controller
  • Loading branch information
fabpot committed Oct 2, 2013
1 parent d997dfa commit 1d210f8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
18 changes: 18 additions & 0 deletions src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php
Expand Up @@ -17,6 +17,7 @@
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
Expand Down Expand Up @@ -80,18 +81,35 @@ protected function execute(InputInterface $input, OutputInterface $output)
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'),
'name' => $name,
));
} 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'),
'show_controllers' => $input->getOption('show-controllers'),
));
}
}

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) {
}
}
}
}
Expand Up @@ -35,14 +35,11 @@ protected function describeRouteCollection(RouteCollection $routes, array $optio
);

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;
}
Expand Down

0 comments on commit 1d210f8

Please sign in to comment.