/**
  * @param Traversable $rows
  *
  * @return PageEntityUsages[]
  */
 private function foldRowsIntoPageEntityUsages(Traversable $rows)
 {
     $usagesPerPage = array();
     foreach ($rows as $row) {
         $pageId = (int) $row->eu_page_id;
         if (isset($usagesPerPage[$pageId])) {
             $pageEntityUsages = $usagesPerPage[$pageId];
         } else {
             $pageEntityUsages = new PageEntityUsages($pageId);
         }
         $entityId = $this->idParser->parse($row->eu_entity_id);
         list($aspect, $modifier) = EntityUsage::splitAspectKey($row->eu_aspect);
         $usage = new EntityUsage($entityId, $aspect, $modifier);
         $pageEntityUsages->addUsages(array($usage));
         $usagesPerPage[$pageId] = $pageEntityUsages;
     }
     return $usagesPerPage;
 }
 /**
  * Transforms the entity usages from $pageEntityUsages according to the relevant
  * aspects defined by calling setRelevantAspects(). A new PageEntityUsages
  * containing the filtered usage list is returned.
  *
  * @see getFilteredUsages()
  *
  * @param PageEntityUsages $pageEntityUsages
  *
  * @return PageEntityUsages
  */
 public function transformPageEntityUsages(PageEntityUsages $pageEntityUsages)
 {
     $entityIds = $pageEntityUsages->getEntityIds();
     $transformedPageEntityUsages = new PageEntityUsages($pageEntityUsages->getPageId(), array());
     foreach ($entityIds as $id) {
         $aspects = $pageEntityUsages->getUsageAspectKeys($id);
         $usages = $this->getFilteredUsages($id, $aspects);
         $transformedPageEntityUsages->addUsages($usages);
     }
     return $transformedPageEntityUsages;
 }