#138 Added section grouping as a higher level key to the resources array

This commit is contained in:
drgomesp 2013-02-21 15:46:59 -03:00
parent b4792d1cd5
commit 9c601664d1

View File

@ -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);
}
}
}
}