/** * {@inheritDoc} */ public function getPage() { if (!isset($this->page)) { $this->page = $this->pageMapper->find($this->pageId); } return $this->page; }
/** * {@inheritDoc} */ public function findAuthorshipsOfUser($userId, $siteId, $order = null, $paginated = false, $page = 1, $perPage = 10) { $result = $this->authorshipMapper->findAuthorshipsOfUser($userId, $siteId, $order, $paginated); if ($paginated) { $result->setCurrentPageNumber($page); $result->setItemCountPerPage($perPage); } else { $result = iterator_to_array($result); } if ($result) { $pageIds = array(); foreach ($result as $auth) { $pageIds[] = $auth->getPageId(); } $pages = $this->pageMapper->findAll(array(sprintf('%s IN (%s)', DbViewPages::PAGEID, implode(',', $pageIds)))); $pageByIds = array(); foreach ($pages as $page) { $pageByIds[$page->getId()] = $page; } foreach ($result as $auth) { $auth->setPage($pageByIds[$auth->getPageId()]); } } return $result; }
/** * {@inheritDoc} */ public function getRank() { if (!isset($this->rank)) { $this->rank = $this->pageMapper->findPageRank($this->getId()); } return $this->rank; }
/** * {@inheritDoc} */ public function findVotesOfUser($userId, $siteId, $order = null, $paginated = false, $page = -1, $perPage = -1) { $result = $this->mapper->findVotesOfUser($userId, $siteId, $order, $paginated); if ($paginated && $result && $page >= 0 && $perPage > 0) { $result->setCurrentPageNumber($page); $result->setItemCountPerPage($perPage); } else { $result = iterator_to_array($result); } if ($result) { $pageIds = array(); foreach ($result as $vote) { $pageIds[] = $vote->getPageId(); } if (count($pageIds) > 0) { $pages = $this->pageMapper->findAll(array(sprintf('%s IN (%s)', DbViewPages::PAGEID, implode(',', $pageIds)))); $pageByIds = array(); foreach ($pages as $page) { $pageByIds[$page->getId()] = $page; } foreach ($result as $vote) { $vote->setPage($pageByIds[$vote->getPageId()]); } } } return $result; }
/** * {@inheritDoc} */ public function getAggregatedValues($siteId, $aggregates, \DateTime $createdAfter, \DateTime $createdBefore) { return $this->mapper->getAggregatedValues($siteId, $aggregates, $createdAfter, $createdBefore); }