Carew\Processor::buildCollectionsWithDocumentMethod PHP Method

buildCollectionsWithDocumentMethod() private method

private buildCollectionsWithDocumentMethod ( $documents, $method )
    private function buildCollectionsWithDocumentMethod($documents, $method)
    {
        $collections = array();
        foreach ($documents as $document) {
            $items = (array) $document->{$method}();
            foreach ($items as $item) {
                if (!array_key_exists($item, $collections)) {
                    $collections[$item] = array();
                }
                $collections[$item][$document->getFilePath()] = $document;
            }
        }
        $collections = array_map(array($this, 'sortByDate'), $collections);
        return $collections;
    }