Fix handling of symfony 2.1 nested routes, fixes #163

This commit is contained in:
Jordi Boggiano 2013-03-27 16:27:25 +01:00
parent 109161e985
commit 905ac99eb5

View File

@ -16,6 +16,7 @@ use Nelmio\ApiDocBundle\Annotation\ApiDoc;
use Nelmio\ApiDocBundle\Parser\ParserInterface; use Nelmio\ApiDocBundle\Parser\ParserInterface;
use Symfony\Component\Routing\Route; use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouterInterface; use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Nelmio\ApiDocBundle\Util\DocCommentExtractor; use Nelmio\ApiDocBundle\Util\DocCommentExtractor;
@ -100,7 +101,9 @@ class ApiDocExtractor
$resources = array(); $resources = array();
foreach ($routes as $route) { foreach ($routes as $route) {
if ($method = $this->getReflectionMethod($route->getDefault('_controller'))) { if ($route instanceof RouteCollection) {
$array = array_merge($array, $this->extractAnnotations($route->getIterator()));
} elseif ($method = $this->getReflectionMethod($route->getDefault('_controller'))) {
if ($annotation = $this->reader->getMethodAnnotation($method, self::ANNOTATION_CLASS)) { if ($annotation = $this->reader->getMethodAnnotation($method, self::ANNOTATION_CLASS)) {
if ($annotation->isResource()) { if ($annotation->isResource()) {
// remove format from routes used for resource grouping // remove format from routes used for resource grouping