本文整理汇总了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);
}
示例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;
}
示例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');
}
示例4: testItemCountPerPageByDefault
/**
* @group ZF-7207
*/
public function testItemCountPerPageByDefault()
{
$paginator = new Paginator\Paginator(new Adapter\ArrayAdapter(range(1, 20)));
$this->assertEquals(2, $paginator->count());
}
示例5: testGetsPageCount
public function testGetsPageCount()
{
$this->assertEquals(11, $this->_paginator->count());
}
示例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;
}
示例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());
}
示例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;
}
示例9: getNumberOfPages
/**
* Get number of pages
* @return int number of pages
*/
public function getNumberOfPages()
{
return (int) $this->paginator->count();
}
示例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;
}
示例11: getLastPage
/**
* Get the last page.
*
* @return int
*/
public function getLastPage()
{
return $this->paginator->count();
}
示例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();
}