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


PHP Paginator::count方法代码示例

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


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

 private function getEvents($eventLoggerGateway)
 {
     $session = new Container('user');
     $pageNum = $session->page;
     $itemsPerPage = $session->itemsPerPage ? $session->itemsPerPage : Env::EVENT_PAGER;
     $filter = $session->eventData;
     $this->GTGateway('EventLoggerGateway')->setOptions($filter);
     $pager = new Paginator($eventLoggerGateway);
     $pager->setCurrentPageNumber($pageNum)->setItemCountPerPage($itemsPerPage);
     $partial = $this->getServiceLocator()->get('viewhelpermanager')->get('partial');
     $sm = $this->getServiceLocator();
     $formSearchEvent = new GTEventSearchForm($sm);
     $searchHtmlForm = $partial("gt-error-tracker/event/search.phtml", array("formSearchEvent" => $formSearchEvent, "searchValue" => $filter['eventData']));
     $result = array("pagerHtml" => $pager->count() > 0 ? $partial("gt-error-tracker/event/event_list.phtml", array("pager" => $pager, "count" => $eventLoggerGateway->count(), "formSearchHtml" => $searchHtmlForm)) : $partial("gt-error-tracker/empty_list.phtml", array('message' => 'No events found so far', "formSearchHtml" => $searchHtmlForm)), "page" => $pageNum);
     return $result;
 }
开发者ID:GoldenTeam,项目名称:GTErrorTracker,代码行数:16,代码来源:EventController.php

示例3: 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

示例4: testItemCountPerPageByDefault

 /**
  * @group ZF-7207
  */
 public function testItemCountPerPageByDefault()
 {
     $paginator = new Paginator\Paginator(new Adapter\ArrayAdapter(range(1, 20)));
     $this->assertEquals(2, $paginator->count());
 }
开发者ID:rajanlamic,项目名称:IntTest,代码行数:8,代码来源:PaginatorTest.php

示例5: testGetsPageCount

 public function testGetsPageCount()
 {
     $this->assertEquals(11, $this->_paginator->count());
 }
开发者ID:Rovak,项目名称:zf2,代码行数:4,代码来源:PaginatorTest.php

示例6: getListForm

 protected function getListForm(Paginator $paginator, $data = [])
 {
     $form = new SubmitForm('leademailform');
     if ($paginator->count() > 0) {
         // Batch Form
         foreach ($paginator as $entity) {
             $cbx = new \Zend\Form\Element\Checkbox("sel[" . $entity->getId() . "]");
             $form->add($cbx);
         }
     }
     if ($data) {
         $form->setData($data);
         if (!$form->isValid()) {
             $form->setData(array());
         }
     }
     return $form;
 }
开发者ID:arstropica,项目名称:zf2-dashboard,代码行数:18,代码来源:EmailController.php

示例7: getPages

 /**
  * Returns an array of all pages given a page number and range.
  *
  * @param  Paginator $paginator
  * @param  int $pageRange Unused
  * @return array
  */
 public function getPages(Paginator $paginator, $pageRange = null)
 {
     return $paginator->getPagesInRange(1, $paginator->count());
 }
开发者ID:eltondias,项目名称:Relogio,代码行数:11,代码来源:All.php

示例8: getListForm

 /**
  *
  * @param Paginator $paginator        	
  * @param array $data        	
  * @return \Lead\Form\ListForm
  */
 protected function getListForm(Paginator $paginator, $data = [])
 {
     $sl = $this->getServiceLocator();
     $form = $sl->get('FormElementManager')->get('Lead\\Form\\ListForm');
     $form->setName('leadbatchform');
     if ($paginator->count() > 0) {
         // Batch Form
         foreach ($paginator as $result) {
             if ($result instanceof Result) {
                 $entity = $result->getLead();
                 $cbx = new \Zend\Form\Element\Checkbox("sel[" . $entity->getId() . "]");
                 $form->add($cbx);
             }
         }
     }
     if ($data) {
         $form->setData($data);
         if (!$form->isValid()) {
             $form->setData(array());
         }
     }
     return $form;
 }
开发者ID:arstropica,项目名称:zf2-dashboard,代码行数:29,代码来源:ResultController.php

示例9: getNumberOfPages

 /**
  * Get number of pages
  * @return int number of pages
  */
 public function getNumberOfPages()
 {
     return (int) $this->paginator->count();
 }
开发者ID:camelcasetechsd,项目名称:certigate,代码行数:8,代码来源:MenuItem.php

示例10: getDeleteForm

 protected function getDeleteForm(Paginator $paginator, $data = [])
 {
     $sl = $this->getServiceLocator();
     $form = $sl->get('FormElementManager')->get('Account\\Form\\ListForm');
     $form->setName('accountbatchdelform');
     $form->remove('submit')->addConfirm();
     if ($paginator->count() > 0) {
         // Batch Form
         foreach ($paginator as $entity) {
             $hdn = new \Zend\Form\Element\Hidden("sel[" . $entity->getId() . "]");
             $hdn->setValue('1');
             $form->add($hdn);
         }
     }
     if ($data) {
         $form->setData($data);
         if (!$form->isValid()) {
             $form->setData(array());
         }
     }
     return $form;
 }
开发者ID:arstropica,项目名称:zf2-dashboard,代码行数:22,代码来源:AccountController.php

示例11: getLastPage

 /**
  * Get the last page.
  *
  * @return int
  */
 public function getLastPage()
 {
     return $this->paginator->count();
 }
开发者ID:JesseObrien,项目名称:fractal,代码行数:9,代码来源:ZendFrameworkPaginatorAdapter.php

示例12: isLastPage

 /**
  * Checks if provided paginator is in last page
  *
  * @param Paginator $paginator
  * @return bool
  */
 protected function isLastPage(Paginator $paginator)
 {
     return $paginator->getCurrentPageNumber() >= $paginator->count();
 }
开发者ID:shlinkio,项目名称:shlink,代码行数:10,代码来源:PaginatorUtilsTrait.php


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