From 89aec4bfd3767f7c4032434c7b026615c3a799ab Mon Sep 17 00:00:00 2001 From: Benjamin Bender Date: Fri, 22 Mar 2013 14:05:14 +0100 Subject: [PATCH] Add a little bit more flexibility to ApiDocExtractor --- Extractor/ApiDocExtractor.php | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/Extractor/ApiDocExtractor.php b/Extractor/ApiDocExtractor.php index 8f7631a..046663a 100644 --- a/Extractor/ApiDocExtractor.php +++ b/Extractor/ApiDocExtractor.php @@ -68,11 +68,21 @@ class ApiDocExtractor * You can extend this method if you don't want all the routes * to be included. * - * @return array of Route + * @return \Traverseable Iterator for a RouteCollection */ public function getRoutes() { - return $this->router->getRouteCollection()->all(); + return $this->router->getRouteCollection()->getIterator(); + } + + /** + * Extracts annotations from all known routes + * + * @return array + */ + public function all() + { + return $this->extractAnnotations($this->getRoutes()); } /** @@ -80,14 +90,16 @@ class ApiDocExtractor * - annotation * - resource * + * @param \Traversable $routes The routes for which the annotations should be extracted + * * @return array */ - public function all() + public function extractAnnotations(\Traversable $routes) { $array = array(); $resources = array(); - foreach ($this->getRoutes() as $route) { + foreach ($routes as $route) { if ($method = $this->getReflectionMethod($route->getDefault('_controller'))) { if ($annotation = $this->reader->getMethodAnnotation($method, self::ANNOTATION_CLASS)) { if ($annotation->isResource()) {