[FrameworkBundle] changed the router:debug to use the shortcut notation for the controller
This commit is contained in:
parent
d997dfa556
commit
1d210f86a6
@ -17,6 +17,7 @@ use Symfony\Component\Console\Input\InputInterface;
|
|||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
use Symfony\Component\Routing\RouterInterface;
|
use Symfony\Component\Routing\RouterInterface;
|
||||||
|
use Symfony\Component\Routing\Route;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A console command for retrieving information about routes
|
* A console command for retrieving information about routes
|
||||||
@ -80,6 +81,7 @@ EOF
|
|||||||
if (!$route) {
|
if (!$route) {
|
||||||
throw new \InvalidArgumentException(sprintf('The route "%s" does not exist.', $name));
|
throw new \InvalidArgumentException(sprintf('The route "%s" does not exist.', $name));
|
||||||
}
|
}
|
||||||
|
$this->convertController($route);
|
||||||
$helper->describe($output, $route, array(
|
$helper->describe($output, $route, array(
|
||||||
'format' => $input->getOption('format'),
|
'format' => $input->getOption('format'),
|
||||||
'raw_text' => $input->getOption('raw'),
|
'raw_text' => $input->getOption('raw'),
|
||||||
@ -87,6 +89,11 @@ EOF
|
|||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
$routes = $this->getContainer()->get('router')->getRouteCollection();
|
$routes = $this->getContainer()->get('router')->getRouteCollection();
|
||||||
|
|
||||||
|
foreach ($routes as $route) {
|
||||||
|
$this->convertController($route);
|
||||||
|
}
|
||||||
|
|
||||||
$helper->describe($output, $routes, array(
|
$helper->describe($output, $routes, array(
|
||||||
'format' => $input->getOption('format'),
|
'format' => $input->getOption('format'),
|
||||||
'raw_text' => $input->getOption('raw'),
|
'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) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,14 +35,11 @@ class TextDescriptor extends Descriptor
|
|||||||
);
|
);
|
||||||
|
|
||||||
if ($showControllers) {
|
if ($showControllers) {
|
||||||
$defaultData = $route->getDefaults();
|
$controller = $route->getDefault('_controller');
|
||||||
$controller = $defaultData['_controller'] ? $defaultData['_controller'] : '';
|
|
||||||
if ($controller instanceof \Closure) {
|
if ($controller instanceof \Closure) {
|
||||||
$controller = 'Closure';
|
$controller = 'Closure';
|
||||||
} else {
|
} elseif (is_object($controller)) {
|
||||||
if (is_object($controller)) {
|
$controller = get_class($controller);
|
||||||
$controller = get_class($controller);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$row[] = $controller;
|
$row[] = $controller;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user