当前位置: 首页>>代码示例>>PHP>>正文


PHP Paginator::getCurrentItems方法代码示例

本文整理汇总了PHP中Zend\Paginator\Paginator::getCurrentItems方法的典型用法代码示例。如果您正苦于以下问题:PHP Paginator::getCurrentItems方法的具体用法?PHP Paginator::getCurrentItems怎么用?PHP Paginator::getCurrentItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Paginator\Paginator的用法示例。


在下文中一共展示了Paginator::getCurrentItems方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: paginatorToArray

 /**
  * Convert a paginator to array
  *
  * @param Paginator $paginator
  * @param string $key root key for items, leave null to return items in root
  * @return array
  */
 protected function paginatorToArray(Paginator $paginator, $key = null)
 {
     $items = iterator_to_array($paginator->getCurrentItems());
     if (null === $key) {
         return $items;
     }
     return array('pages' => $paginator->count(), 'current' => $paginator->getCurrentPageNumber(), 'count' => $paginator->getTotalItemCount(), $key => $items);
 }
开发者ID:outeredge,项目名称:edge-zf2,代码行数:15,代码来源:Serializer.php

示例2: getPagination

 public function getPagination($iPageNumber = 0, $iCountPerPage = 0)
 {
     $paginatorAdapter = new DbSelect($this->mAdministratorTb->getSql()->select()->columns(array('id', 'role_id', 'username', 'realname', 'raw_add_time')), $this->mAdministratorTb->getAdapter(), $this->mAdministratorTb->getResultSetPrototype());
     $paginator = new Paginator($paginatorAdapter);
     $paginator->setCurrentPageNumber($iPageNumber)->setItemCountPerPage($iCountPerPage);
     $aRows = $this->mCore->IteratorToArray($paginator->getCurrentItems());
     $iTotal = $paginator->getTotalItemCount();
     return json_encode(array('rows' => $aRows, 'total' => $iTotal));
 }
开发者ID:yuwenyu,项目名称:SoJo,代码行数:9,代码来源:AdministratorModel.php

示例3: getPagination

 public function getPagination($iPageNumber = 0, $iCountPerPage = 0, $aOptions = array())
 {
     $paginatorAdapter = new DbSelect($this->mAuthorityTb->getSql()->select()->where($aOptions), $this->mAuthorityTb->getAdapter(), $this->mAuthorityTb->getResultSetPrototype());
     $paginator = new Paginator($paginatorAdapter);
     $paginator->setCurrentPageNumber($iPageNumber)->setItemCountPerPage($iCountPerPage);
     $iTotal = $paginator->getTotalItemCount();
     $aRows = $this->mCore->IteratorToArray($paginator->getCurrentItems());
     return json_encode(array('rows' => $aRows, 'total' => $iTotal));
 }
开发者ID:yuwenyu,项目名称:SoJo,代码行数:9,代码来源:AuthorityModel.php

示例4: testWithCacheDisabled

 public function testWithCacheDisabled()
 {
     $this->_paginator->setCacheEnabled(false);
     $this->_paginator->setCurrentPageNumber(1)->getCurrentItems();
     $cachedPageItems = $this->_paginator->getPageItemCache();
     $expected = new \ArrayIterator(range(1, 10));
     $this->assertEquals(array(), $cachedPageItems);
     $pageItems = $this->_paginator->getCurrentItems();
     $this->assertEquals($expected, $pageItems);
 }
开发者ID:Rovak,项目名称:zf2,代码行数:10,代码来源:PaginatorTest.php

示例5: indexAction

 public function indexAction()
 {
     $currentPage = $this->params()->fromRoute('page', null);
     $adapter = $this->jobTable->getAdapter();
     $select = $this->jobTable->getAll();
     $paginator = new Paginator(new \Zend\Paginator\Adapter\DbSelect($select, $adapter));
     $paginator->setCurrentPageNumber($currentPage);
     $paginator->setDefaultItemCountPerPage($this->config['admin_element_pagination']);
     $jobs = $paginator->getCurrentItems();
     return new ViewModel(array('jobs' => $jobs, 'paginator' => $paginator));
 }
开发者ID:Lebe1ge,项目名称:JobeetForZF2,代码行数:11,代码来源:JobController.php

示例6: getCurrentItems

 public function getCurrentItems()
 {
     /** @var Commit[] $commits */
     $commits = parent::getCurrentItems();
     foreach ($commits as $commit) {
         foreach ($this->getCommitFileStatusMapper()->forCommit($commit) as $status) {
             $commit->addCommitFileStatus($status);
         }
         $commit->setRepository($this->getRepositoryMapper()->findById($commit->repository_id));
     }
     return $commits;
 }
开发者ID:jeremygiberson,项目名称:what-changed,代码行数:12,代码来源:CommitPaginator.php

示例7: indexAction

 public function indexAction()
 {
     $categories = $this->categoryTable->fetchAll();
     $results = array();
     $adapter = $this->jobTable->getAdapter();
     foreach ($categories as $category) {
         $select = $this->jobTable->getActiveJobsForPagination($category->id_category, $this->config['job_nb_valid_days']);
         $paginator = new Paginator(new \Zend\Paginator\Adapter\DbSelect($select, $adapter));
         $paginator->setCurrentPageNumber(0);
         $paginator->setDefaultItemCountPerPage($this->config['nb_job_by_category']);
         $jobs = $paginator->getCurrentItems();
         $activeJobs = $paginator->getTotalItemCount();
         $results[] = array('category' => $category, 'job' => $jobs, 'activeJobs' => $activeJobs);
     }
     $nbJobByCategory = $this->config['nb_job_by_category'];
     return new ViewModel(array('results' => $results, 'nbJobByCategory' => $nbJobByCategory));
 }
开发者ID:Lebe1ge,项目名称:JobeetForZF2,代码行数:17,代码来源:IndexController.php

示例8: indexAction

 public function indexAction()
 {
     /** @var QueryBuilder $qb */
     $qb = $this->getObjectManager()->createQueryBuilder();
     $qb->select('w')->from(Word::class, 'w');
     $form = new WordSearchForm();
     $form->setData($this->params()->fromQuery());
     $form->setInputFilter(new WordSearchInputFilter());
     // it doesn't matter if the form is not valid, as we would fill in default values anyway. This is just to avoid the default error messages
     $form->isValid();
     // set query, direction and order for the querybuilder
     $direction = strtolower($form->getData()['d']);
     $direction = $direction == 'desc' ? 'desc' : 'asc';
     $orderBy = strtolower($form->getData()['o']);
     switch ($orderBy) {
         case 'created':
             $order = 'createdAt';
             break;
         case 'updated':
             $order = 'updatedAt';
             break;
         default:
             $orderBy = $order = 'word';
             break;
     }
     $qb->orderBy('w.' . $order, $direction);
     // no need to avoid SQL injection, as doctrine does this for us
     $query = $form->getData()['q'];
     $qb->where('w.word LIKE :query')->setParameter('query', '%' . $query . '%');
     $itemsPerPage = 50;
     // set up the paginator
     $adapter = new DoctrineAdapter(new ORMPaginator($qb->getQuery()));
     $paginator = new Paginator($adapter);
     $paginator->setDefaultItemCountPerPage(50);
     $page = (int) $this->params()->fromQuery('p');
     if ($page != null) {
         $paginator->setCurrentPageNumber($page);
     } else {
         $paginator->setCurrentPageNumber(1);
     }
     $pages = $paginator->getTotalItemCount() / $itemsPerPage;
     $paginator->setPageRange($pages);
     $viewModel = new ViewModel();
     $viewModel->setVariables(['words' => $paginator->getCurrentItems(), 'pageCount' => $paginator->getPageRange() + 1, 'currentPage' => $paginator->getCurrentPageNumber(), 'orderBy' => $orderBy, 'direction' => $direction, 'query' => $query, 'form' => $form]);
     return $viewModel;
 }
开发者ID:spoorey,项目名称:hangman,代码行数:46,代码来源:WordController.php

示例9: listAction

 public function listAction()
 {
     // Get params from matched route
     $slug = $this->params()->fromRoute('slug', null);
     $currentPage = $this->params()->fromRoute('page', null);
     $adapter = $this->jobTable->getAdapter();
     if (!is_null($slug)) {
         $category = $this->categoryTable->getCategoryBySlug($slug);
         $select = $this->jobTable->getActiveJobsForPagination($category->id_category, $this->config['job_nb_valid_days']);
         $paginator = new Paginator(new \Zend\Paginator\Adapter\DbSelect($select, $adapter));
         $paginator->setCurrentPageNumber($currentPage);
         $paginator->setDefaultItemCountPerPage($this->config['nb_job_pagination']);
         $jobs = $paginator->getCurrentItems();
         return new ViewModel(array('category' => $category, 'jobs' => $jobs, 'paginator' => $paginator, 'id' => $category->idCategory, 'slug' => $slug));
     } else {
         $this->getResponse()->setStatusCode(404);
         return;
     }
 }
开发者ID:Lebe1ge,项目名称:JobeetForZF2,代码行数:19,代码来源:CategoryController.php

示例10: getList

 /**
  * getList
  *
  * @return mixed|JsonModel
  */
 public function getList()
 {
     //ACCESS CHECK
     if (!$this->rcmIsAllowed('sites', 'admin')) {
         $this->getResponse()->setStatusCode(Response::STATUS_CODE_401);
         return $this->getResponse();
     }
     /** @var \Doctrine\ORM\EntityManagerInterface $entityManager */
     $entityManager = $this->getEntityManager();
     /** @var \Rcm\Repository\Site $siteRepo */
     $siteRepo = $entityManager->getRepository('\\Rcm\\Entity\\Site');
     $createQueryBuilder = $siteRepo->createQueryBuilder('site')->select('site')->leftJoin('site.domain', 'domain')->leftJoin('site.country', 'country')->leftJoin('site.language', 'language')->orderBy('domain.domain', 'ASC');
     $query = $createQueryBuilder->getQuery();
     $searchQuery = $this->params()->fromQuery('q');
     if ($searchQuery) {
         $createQueryBuilder->where($createQueryBuilder->expr()->like('domain.domain', ':searchQuery'));
         $query = $createQueryBuilder->getQuery();
         $query->setParameter('searchQuery', $searchQuery . '%');
     }
     $adaptor = new DoctrinePaginator(new ORMPaginator($query));
     $paginator = new Paginator($adaptor);
     $paginator->setDefaultItemCountPerPage(10);
     $page = (int) $this->params()->fromQuery('page');
     if ($page) {
         $paginator->setCurrentPageNumber($page);
     }
     $pageSize = (int) $this->params()->fromQuery('page_size');
     if ($pageSize) {
         $paginator->setItemCountPerPage($pageSize);
     }
     $sitesObjects = $paginator->getCurrentItems();
     $sites = [];
     /** @var \Rcm\Entity\Site $site */
     foreach ($sitesObjects as $site) {
         $sites[] = $site->toArray();
     }
     $list['items'] = $sites;
     $list['itemCount'] = $paginator->getTotalItemCount();
     $list['pageCount'] = $paginator->count();
     $list['currentPage'] = $paginator->getCurrentPageNumber();
     return new ApiJsonModel($list, 0, 'Success');
 }
开发者ID:reliv,项目名称:rcm-admin,代码行数:47,代码来源:ApiAdminManageSitesController.php

示例11: getInstalledModules

 /**
  * Get installed modules
  *
  * @param integer $page
  * @param integer $perPage
  * @param string $orderBy
  * @param string $orderType
  * @param array $filters
  *      string status
  *      string type
  * @return object
  */
 public function getInstalledModules($page = 1, $perPage = 0, $orderBy = null, $orderType = null, array $filters = [])
 {
     $orderFields = ['id', 'type', 'status', 'version', 'vendor', 'email'];
     $orderType = !$orderType || $orderType == 'desc' ? 'desc' : 'asc';
     $orderBy = $orderBy && in_array($orderBy, $orderFields) ? $orderBy : 'id';
     $select = $this->select();
     $select->from(['a' => 'application_module'])->columns(['id', 'name', 'type', 'status', 'version', 'vendor', 'email' => 'vendor_email', 'description'])->join(['b' => 'application_module_depend'], 'a.id = b.depend_module_id', ['module_depends' => 'id'], 'left')->order($orderBy . ' ' . $orderType);
     // filter by status
     if (!empty($filters['status'])) {
         switch ($filters['status']) {
             case self::MODULE_STATUS_ACTIVE:
             case self::MODULE_STATUS_NOT_ACTIVE:
                 $select->where(['a.status' => $filters['status']]);
                 break;
             default:
         }
     }
     // filter by type
     if (!empty($filters['type'])) {
         switch ($filters['type']) {
             case self::MODULE_TYPE_SYSTEM:
             case self::MODULE_TYPE_CUSTOM:
                 $select->where(['a.type' => $filters['type']]);
                 break;
             default:
         }
     }
     $paginator = new Paginator(new DbSelectPaginator($select, $this->adapter));
     $paginator->setCurrentPageNumber($page);
     $paginator->setItemCountPerPage(PaginationUtility::processPerPage($perPage));
     $paginator->setPageRange(SettingService::getSetting('application_page_range'));
     // load the custom deactivated module's translations
     foreach ($paginator->getCurrentItems() as $module) {
         if ($module['type'] == self::MODULE_TYPE_CUSTOM && $module['status'] == self::MODULE_STATUS_NOT_ACTIVE) {
             $this->addModuleTranslations($this->getSystemModuleConfig($module['name'], false));
         }
     }
     return $paginator;
 }
开发者ID:spooner77,项目名称:dream-cms,代码行数:51,代码来源:ApplicationModuleAdministration.php

示例12: getList

 /**
  * Return list of resources
  *
  * @param callable $queryBuilderCallback
  * @param callable $queryCallback
  * @throws \Application\Library\Exception\ValidationException
  * @return mixed
  */
 public function getList(\Closure $queryBuilderCallback = null, \Closure $queryCallback = null)
 {
     $form = new ModelFilterForm();
     $form->setData($this->params()->fromQuery());
     if (!$form->isValid()) {
         throw new ValidationException($form->getMessages(), 400);
     }
     $limit = $form->getData()['rows'];
     $page = $form->getData()['page'];
     $queryBuilder = $this->getEntityManager()->createQueryBuilder();
     $queryBuilder->select('c')->from($this->entityClass, 'c');
     if (!is_null($queryBuilderCallback)) {
         $queryBuilderCallback($queryBuilder);
     }
     $query = $queryBuilder->getQuery()->setHydrationMode(Query::HYDRATE_ARRAY);
     if (!is_null($queryCallback)) {
         $queryCallback($query);
     }
     $paginator = new Paginator(new DoctrinePaginator(new ORMPaginator($query)));
     $paginator->setCurrentPageNumber($page)->setItemCountPerPage($limit);
     $return = array('page' => $paginator->getCurrentPageNumber(), 'total' => ceil($paginator->getTotalItemCount() / $limit), 'records' => $paginator->getTotalItemCount(), 'rows' => $paginator->getCurrentItems()->getArrayCopy());
     return new JsonModel($return);
 }
开发者ID:sarancea,项目名称:ciklum,代码行数:31,代码来源:ApiAbstract.php

示例13: constructForeignKeys

 public function constructForeignKeys(Paginator $paginator)
 {
     if (!$this->allowForeignKeys) {
         return $paginator;
     }
     foreach ($this->foreignKeys as $key) {
         foreach ($paginator->getCurrentItems() as $item) {
             if ($this->serviceLocator->has('model\\' . $key->table)) {
                 try {
                     $table = $this->serviceLocator->get('model\\' . $key->table)->getTable();
                     $table->getSelect()->reset('where');
                     $object = $table->get($item->{$key->name}, $key->col, true);
                 } catch (Exception $e) {
                     throw new \Exception('Can\'t find col ' . $key->col . ' in model ' . $key->table);
                 }
             } else {
                 throw new \Exception('Can\'t find \'model\' ' . $key->table . ' service');
             }
             $object = $object ? $object->count() == 1 ? current($object->getArrayCopy()) : $object->getArrayCopy() : null;
             $item->{$key->key ? $key->key : $key->table} = $object;
             $functionName = $key->table;
             $snakeCase = strpos($functionName, '_');
             if ($snakeCase) {
                 $functionName = ucwords($functionName, '_');
                 $functionName = str_replace('_', '', $functionName);
             } else {
                 $functionName = ucfirst($functionName);
             }
             $functionName = 'get' . $functionName;
             $getFunction = function () use($item, $key) {
                 return $item->{$key->key ? $key->key : $key->table};
             };
             $item->methods[$functionName] = \Closure::bind($getFunction, $item, get_class($item));
         }
     }
     return $paginator;
 }
开发者ID:LiubomyrPelo,项目名称:data,代码行数:37,代码来源:AbstractTable.php

示例14: listarOcorrenciaAction

 public function listarOcorrenciaAction()
 {
     try {
         if ($this->getRequest()->isPost()) {
             $limit = json_decode($this->getRequest()->getPost()['limit'], true);
             $filters = json_decode($this->getRequest()->getPost()['filters'], true);
             $filters = $filters['filters'];
             //                $filters = array($filters['filters']);
             $sortField = $this->getRequest()->getPost()['sortField'];
             $sortDirection = $this->getRequest()->getPost()['sortDirection'];
             $page = json_decode($this->getRequest()->getPost()['page'], true);
             $lotacaoSession = new Container('lotacaoVisibilidade');
             $lotacao = $lotacaoSession->lotacaoVisibilidade;
             $dados = array('id' => $this->getRequest()->getPost()['id'], 'placaVeiculo' => $this->getRequest()->getPost()['placaVeiculo.placa'], 'lotacaoMacro' => $lotacao);
             $ocorrenciaNegocio = $this->getServiceLocator()->get('Frota\\Negocio\\Ocorrencia');
             // if ($filtro) {
             $retorno = $ocorrenciaNegocio->getRepository()->listarOcorrencia($filters, $dados, $sortField, $sortDirection);
             //                } else {
             //                    $retorno = $ocorrenciaNegocio->getRepository()->listarOcorrencia($filtro, $dados, $sortField, $sortDirection);
             //                }
             $paginator = new Paginator(new ArrayAdapter($retorno));
             $paginator->setCurrentPageNumber($page);
             $paginator->setDefaultItemCountPerPage($limit);
             $count = $paginator->getItemCount($retorno);
             $itemsArray = (array) $paginator->getCurrentItems();
             return new JsonModel(array("data" => $itemsArray, "message" => "Ocorrência(s) listada(s) com sucesso", "success" => true, "total" => $count));
         }
     } catch (ValidacaoException $exc) {
         return new JsonModel(array("data" => "", "message" => $exc->getMessage(), "success" => false));
     } catch (Exception $exc) {
         $logger = $this->getServiceLocator()->get('Zend\\Log');
         $logger->err($exc, array("Ocorreu um erro:"));
         return new JsonModel(array("data" => "", "message" => $exc->getMessage(), "success" => false));
     }
     return new JsonModel(array("data" => "", "message" => "Erro na busca dos registros.", "success" => false));
 }
开发者ID:Rodrigojorge,项目名称:frota,代码行数:36,代码来源:OcorrenciaController.php

示例15: setPaginator

 /**
  * @param Paginator $paginator
  */
 public function setPaginator(Paginator $paginator)
 {
     foreach ($paginator->getCurrentItems() as $k => $item) {
         $this->setVariable($k, $this->hydrator->extract($item));
     }
 }
开发者ID:spalax,项目名称:zf2-file-uploader,代码行数:9,代码来源:PaginatorJsonModel.php


注:本文中的Zend\Paginator\Paginator::getCurrentItems方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。