diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php index 8c29492040..eb4407b8f8 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php @@ -83,10 +83,10 @@ EOF $name = $input->getArgument('name'); $helper = new DescriptorHelper(); + $routes = $this->getContainer()->get('router')->getRouteCollection(); if ($name) { - $route = $this->getContainer()->get('router')->getRouteCollection()->get($name); - if (!$route) { + if (!$route = $routes->get($name)) { throw new \InvalidArgumentException(sprintf('The route "%s" does not exist.', $name)); } $this->convertController($route); @@ -96,8 +96,6 @@ EOF 'name' => $name, )); } else { - $routes = $this->getContainer()->get('router')->getRouteCollection(); - foreach ($routes as $route) { $this->convertController($route); }