From 905ac99eb55c92820bfe62d857d2b8591a997819 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 27 Mar 2013 16:27:25 +0100 Subject: [PATCH] Fix handling of symfony 2.1 nested routes, fixes #163 --- Extractor/ApiDocExtractor.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Extractor/ApiDocExtractor.php b/Extractor/ApiDocExtractor.php index 47c08da..5a7dffc 100644 --- a/Extractor/ApiDocExtractor.php +++ b/Extractor/ApiDocExtractor.php @@ -16,6 +16,7 @@ use Nelmio\ApiDocBundle\Annotation\ApiDoc; use Nelmio\ApiDocBundle\Parser\ParserInterface; use Symfony\Component\Routing\Route; use Symfony\Component\Routing\RouterInterface; +use Symfony\Component\Routing\RouteCollection; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; use Nelmio\ApiDocBundle\Util\DocCommentExtractor; @@ -100,7 +101,9 @@ class ApiDocExtractor $resources = array(); 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->isResource()) { // remove format from routes used for resource grouping