Ejemplo n.º 1
0
 /**
  * Get a paginated table with authors for a selected site
  * @param int $siteId
  * @param string $orderBy
  * @param int $order
  * @param int $page
  * @param int $perPage
  * @return \Application\Component\PaginatedTable\TableInterface;
  */
 protected function getAuthorsTable($siteId, $orderBy, $order, $page, $perPage)
 {
     $authors = $this->services->getUserService()->findAuthorSummaries($siteId, array($orderBy => $order), true);
     $authors->setItemCountPerPage($perPage);
     $authors->setCurrentPageNumber($page);
     $userIds = array();
     $authorById = array();
     foreach ($authors as $author) {
         $userIds[] = $author->getUserId();
         $authorById[$author->getUserId()] = $author;
     }
     $users = $this->services->getUserService()->findAll(array(sprintf('%s IN (%s)', DbViewUsers::USERID, implode(',', $userIds))));
     foreach ($users as $user) {
         $authorById[$user->getId()]->setUser($user);
     }
     $table = \Application\Factory\Component\PaginatedTableFactory::createAuthorsTable($authors);
     $table->getColumns()->setOrder($orderBy, $order === Order::ASCENDING);
     return $table;
 }