From 9c601664d1bc8aca257caff49e59913fbff597bc Mon Sep 17 00:00:00 2001 From: drgomesp Date: Thu, 21 Feb 2013 15:46:59 -0300 Subject: [PATCH] #138 Added section grouping as a higher level key to the resources array --- Formatter/AbstractFormatter.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/Formatter/AbstractFormatter.php b/Formatter/AbstractFormatter.php index 17a421d..2f0f243 100644 --- a/Formatter/AbstractFormatter.php +++ b/Formatter/AbstractFormatter.php @@ -127,17 +127,19 @@ abstract class AbstractFormatter implements FormatterInterface { $array = array(); foreach ($collection as $coll) { - if(is_null($coll['annotation']->getSection())) { - $array[$coll['resource']][] = $coll['annotation']->toArray(); - } else { - $array[$coll['annotation']->getSection()][] = $coll['annotation']->toArray(); - } + $array[$coll['annotation']->getSection()][$coll['resource']][] = $coll['annotation']->toArray(); } $processedCollection = array(); - foreach ($array as $path => $annotations) { - foreach ($annotations as $annotation) { - $processedCollection[$path][] = $this->processAnnotation($annotation); + foreach ($array as $section => $resources) { + foreach ($resources as $path => $annotations) { + foreach ($annotations as $annotation) { + if($section) { + $processedCollection[$section][$path][] = $this->processAnnotation($annotation); + } else { + $processedCollection['others'][$path][] = $this->processAnnotation($annotation); + } + } } }