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


PHP Pagerfanta::getMaxPerPage方法代码示例

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


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

示例1: createRepresentationFromPagerfanta

 public function createRepresentationFromPagerfanta(Pagerfanta $pager)
 {
     $this->pager = empty($pager) ? $this->pager : $pager;
     if (empty($this->pager)) {
         return array();
     }
     $representation = array('hasToPaginate' => $this->pager->haveToPaginate(), 'hasNextPage' => $this->pager->hasNextPage(), 'hasPreviousPage' => $this->pager->hasPreviousPage(), 'totalItems' => $this->pager->getNbResults(), 'itemsPerPage' => $this->pager->getMaxPerPage(), 'currentPage' => $this->pager->getCurrentPage(), 'data' => $this->pager->getCurrentPageResults());
     return $representation;
 }
开发者ID:claroline,项目名称:distribution,代码行数:9,代码来源:PaginatedCollectionRepresentation.php

示例2: indexAction

 /**
  * Lists all Test entities.
  *
  * @Route("/", name="test")
  * @Template()
  */
 public function indexAction()
 {
     $request = $this->getRequest();
     $em = $this->getDoctrine()->getEntityManager();
     $page = $request->query->get('page');
     if (!$page) {
         $page = 1;
     }
     $query = $em->createQueryBuilder();
     $query->add('select', 't')->add('from', 'ApplicationTestBundle:Test t')->add('orderBy', 't.featured DESC, t.position ASC, t.id DESC');
     $adapter = new DoctrineORMAdapter($query);
     $pagerfanta = new Pagerfanta($adapter);
     $pagerfanta->setMaxPerPage(10);
     // 10 by default
     $maxPerPage = $pagerfanta->getMaxPerPage();
     $pagerfanta->setCurrentPage($page);
     // 1 by default
     $entities = $pagerfanta->getCurrentPageResults();
     $routeGenerator = function ($page) {
         $url = '?page=' . $page;
         return $url;
     };
     $view = new DefaultView();
     $html = $view->render($pagerfanta, $routeGenerator);
     //$twig = $this->container->get('twig');
     //$twig->addExtension(new \Twig_Extensions_Extension_Text);
     return array('pager' => $html, 'entities' => $entities);
 }
开发者ID:norter,项目名称:directoriopro,代码行数:34,代码来源:TestController.php

示例3: paginate

 /**
  * Paginate to the next dataset if possible
  */
 protected function paginate()
 {
     if ($this->currentItem == $this->pagerfanta->getMaxPerPage() and $this->pagerfanta->hasNextPage()) {
         $this->pagerfanta->setCurrentPage($this->pagerfanta->getNextPage());
         $this->loadData();
     }
 }
开发者ID:indigophp,项目名称:data-import-extra,代码行数:10,代码来源:PaginatedReader.php

示例4: createRepresentation

 /**
  * @param Pagerfanta $pager  The pager
  * @param Route      $route  The collection's route
  * @param mixed      $inline Most of the time, a custom `CollectionRepresentation` instance
  *
  * @return PaginatedRepresentation
  */
 public function createRepresentation(Pagerfanta $pager, Route $route, $inline = null)
 {
     if (null === $inline) {
         $inline = new CollectionRepresentation($pager->getCurrentPageResults());
     }
     return new PaginatedRepresentation($inline, $route->getName(), $route->getParameters(), $pager->getCurrentPage(), $pager->getMaxPerPage(), $pager->getNbPages(), $this->getPageParameterName(), $this->getLimitParameterName(), $route->isAbsolute(), $pager->getNbResults());
 }
开发者ID:uvillazon,项目名称:symfonysecuriy,代码行数:14,代码来源:PagerfantaFactory.php

示例5: paginate

 /**
  * @param Request          $request
  * @param AdapterInterface $adapter
  * @param string|null      $route
  *
  * @return PaginatedRepresentation
  */
 protected function paginate(Request $request, AdapterInterface $adapter, $route = null, $routeParameters = null)
 {
     $pagerfanta = new Pagerfanta($adapter);
     $pagerfanta->setMaxPerPage($request->query->get(self::LIMIT_PARAMETER, 5));
     $pagerfanta->setCurrentPage($request->query->get(self::PAGE_PARAMETER, 1));
     $collection = new CollectionRepresentation($pagerfanta->getCurrentPageResults());
     $paginated = new PaginatedRepresentation($collection, $route ?? $request->get('_route'), $routeParameters ?? $request->attributes->get('_route_params'), $pagerfanta->getCurrentPage(), $pagerfanta->getMaxPerPage(), $pagerfanta->getNbPages(), self::PAGE_PARAMETER, self::LIMIT_PARAMETER, false, $pagerfanta->count());
     return $paginated;
 }
开发者ID:ThreeDotsLabs,项目名称:crm,代码行数:16,代码来源:RestController.php

示例6: createPaginatedRepresentation

 /**
  * @param Pagerfanta $object
  *
  * @return PaginatedRepresentation
  */
 protected function createPaginatedRepresentation($object)
 {
     if (!$object instanceof Pagerfanta) {
         return;
     }
     $items = $object->getCurrentPageResults();
     if ($items instanceof \ArrayIterator) {
         $items = $items->getArrayCopy();
     }
     return new PaginatedRepresentation($items, $object->getCurrentPage(), $object->getMaxPerPage(), $object->getNbPages(), $object->getNbResults());
 }
开发者ID:jared-fraser,项目名称:JsonApiBundle,代码行数:16,代码来源:PagerfantaHandler.php

示例7: addPagination

 protected function addPagination(Request $request, Pagerfanta $pager, $resource)
 {
     $route = $request->attributes->get('_route');
     $params = $request->attributes->get('_route_params');
     $params = array_merge($params, $request->query->all());
     $resource->setMetaValue('page', $pager->getCurrentPage());
     $resource->setMetaValue('count', $pager->getNbResults());
     $resource->setMetaValue('nextPage', null);
     $resource->setMetaValue('previousPage', null);
     $resource->setMetaValue('next', null);
     $resource->setMetaValue('previous', null);
     if ($pager->hasNextPage()) {
         $resource->setMetaValue('next', $this->generateUrl($route, array_replace($params, ['page' => $pager->getNextPage(), 'limit' => $pager->getMaxPerPage()]), true));
         $resource->setMetaValue('nextPage', $pager->getNextPage());
     }
     if ($pager->hasPreviousPage()) {
         $resource->setMetaValue('previous', $this->generateUrl($route, array_replace($params, ['page' => $pager->getPreviousPage(), 'limit' => $pager->getMaxPerPage()]), true));
         $resource->setMetaValue('previousPage', $pager->getPreviousPage());
     }
 }
开发者ID:tuimedia,项目名称:forum,代码行数:20,代码来源:Pagination.php

示例8: testTransformPaginatedObjectCollectionReturnsCorrectArray

 public function testTransformPaginatedObjectCollectionReturnsCorrectArray()
 {
     $collection = array(new \stdClass());
     $pager = new Pagerfanta(new MockPager($collection));
     $pagerAdapter = new PagerfantaPaginatorAdapter($pager, function () {
         return 'url';
     });
     $registry = new TransformerRegistry();
     $transformer = new ArrayTransformer(new Manager(), $registry);
     $registry->setTransformer('mock', new MockTransformer());
     $data = $transformer->transformList('mock', array(new \stdClass()), array('child'), $pagerAdapter);
     $this->assertEquals(array('data' => array(array('transformed' => true, 'child' => array('data' => array('transformed' => true)))), 'meta' => array('pagination' => array('total' => 1, 'count' => 1, 'per_page' => $pager->getMaxPerPage(), 'current_page' => 1, 'total_pages' => 1, 'links' => array()))), $data);
 }
开发者ID:bburnichon,项目名称:rest-bundle,代码行数:13,代码来源:ArrayTransformerTest.php

示例9: indexAction

 /**
  * Lists all Project entities.
  *
  * @Route("/", name="project")
  * @Template()
  */
 public function indexAction()
 {
     $request = $this->getRequest();
     $page = $request->query->get('page', 1);
     // type?
     $type = $request->query->get('t', 0);
     if (!in_array($type, array(0, 1, 2))) {
         return $this->redirect($this->generateUrl('project'));
     }
     // category_id?
     $category_id = $request->query->get('c', 0);
     $q = $this->getDoctrine()->getEntityManager()->getRepository('ApplicationProjectBundle:Project')->getProjectsDQL($type, $category_id);
     $adapter = new DoctrineORMAdapter($q);
     $pagerfanta = new Pagerfanta($adapter);
     $pagerfanta->setMaxPerPage(10);
     // 10 by default
     $maxPerPage = $pagerfanta->getMaxPerPage();
     $pagerfanta->setCurrentPage($page);
     // 1 by default
     $entities = $pagerfanta->getCurrentPageResults();
     $routeGenerator = function ($page, $category_id, $type) {
         $url = '?page=' . $page;
         if ($category_id) {
             $url .= '&c=' . $category_id;
         }
         if ($type) {
             $url .= '&t=' . $type;
         }
         return $url;
     };
     $view = new DefaultView();
     $html = $view->render($pagerfanta, $routeGenerator, array('category_id' => (int) $category_id, 'type' => (int) $type));
     //$twig = $this->container->get('twig');
     //$twig->addExtension(new \Twig_Extensions_Extension_Text);
     switch ($type) {
         case 0:
             $page_title = 'Ideas';
             break;
         case 1:
             $page_title = 'Beta';
             break;
         case 2:
             $page_title = 'Startup';
             break;
         default:
             throw $this->createNotFoundException('Unable to find Category entity.');
             break;
     }
     return array('pager' => $html, 'entities' => $entities, 'type' => $type, 'page_title' => $page_title, 'category_id' => $category_id);
 }
开发者ID:norter,项目名称:directoriopro,代码行数:56,代码来源:ProjectController.php

示例10: serializePagerfanta

 /**
  * @param JsonApiSerializationVisitor $visitor
  * @param Pagerfanta                  $pagerfanta
  * @param array                       $type
  * @param Context                     $context
  * @return Pagerfanta
  */
 public function serializePagerfanta(JsonApiSerializationVisitor $visitor, Pagerfanta $pagerfanta, array $type, Context $context)
 {
     $request = $this->requestStack->getCurrentRequest();
     $pagerfanta->setNormalizeOutOfRangePages(true);
     $pagerfanta->setAllowOutOfRangePages(true);
     $pagerfanta->setMaxPerPage($request->get('page[limit]', $this->paginationOptions['limit'], true));
     $pagerfanta->setCurrentPage($request->get('page[number]', 1, true));
     $results = $pagerfanta->getCurrentPageResults();
     if ($results instanceof \ArrayIterator) {
         $results = $results->getArrayCopy();
     }
     $data = $context->accept($results);
     $root = $visitor->getRoot();
     $root['meta'] = array('page' => $pagerfanta->getCurrentPage(), 'limit' => $pagerfanta->getMaxPerPage(), 'pages' => $pagerfanta->getNbPages(), 'total' => $pagerfanta->getNbResults());
     $root['links'] = array('first' => $this->getUriForPage(1), 'last' => $this->getUriForPage($pagerfanta->getNbPages()), 'prev' => $pagerfanta->hasPreviousPage() ? $this->getUriForPage($pagerfanta->getPreviousPage()) : null, 'next' => $pagerfanta->hasNextPage() ? $this->getUriForPage($pagerfanta->getNextPage()) : null);
     $visitor->setRoot($root);
     return $data;
 }
开发者ID:aliebing,项目名称:JsonApiBundle,代码行数:25,代码来源:PagerfantaHandler.php

示例11: getNavigationLinks

 private function getNavigationLinks(Pagerfanta $pager, array $params = array())
 {
     $page = $pager->getCurrentPage();
     $limit = $pager->getMaxPerPage();
     $links = [];
     if ($pager->getCurrentPage() > 1) {
         $links['first'] = $this->generateUrl('app_api_categories', array_merge($params, ['offset' => $this->getOffset(1, $limit)]));
     }
     if ($pager->hasPreviousPage()) {
         $links['previous'] = $this->generateUrl('app_api_categories', array_merge($params, ['offset' => $this->getOffset($pager->getPreviousPage(), $limit)]));
     }
     if ($pager->hasNextPage()) {
         $links['next'] = $this->generateUrl('app_api_categories', array_merge($params, ['offset' => $this->getOffset($pager->getNextPage(), $limit)]));
     }
     if ($pager->getNbPages() != $page) {
         $links['last'] = $this->generateUrl('app_api_categories', array_merge($params, ['offset' => $this->getOffset($pager->getNbPages(), $limit)]));
     }
     return $links;
 }
开发者ID:jpsymfony,项目名称:REST-BEHAT,代码行数:19,代码来源:CategoriesViewHandler.php

示例12: overviewAction

 /**
  * @Route("/", name = "jms_jobs_overview")
  * @Template
  */
 public function overviewAction()
 {
     $lastJobsWithError = $this->getRepo()->findLastJobsWithError(5);
     $qb = $this->getEm()->createQueryBuilder();
     $qb->select('j')->from('JMSJobQueueBundle:Job', 'j')->where($qb->expr()->isNull('j.originalJob'))->orderBy('j.id', 'desc');
     foreach ($lastJobsWithError as $i => $job) {
         $qb->andWhere($qb->expr()->neq('j.id', '?' . $i));
         $qb->setParameter($i, $job->getId());
     }
     $pager = new Pagerfanta(new DoctrineORMAdapter($qb));
     $pager->setCurrentPage(max(1, (int) $this->request->query->get('page', 1)));
     $pager->setMaxPerPage(max(5, min(50, (int) $this->request->query->get('per_page', 20))));
     $pagerView = new TwitterBootstrapView();
     $router = $this->router;
     $routeGenerator = function ($page) use($router, $pager) {
         return $router->generate('jms_jobs_overview', array('page' => $page, 'per_page' => $pager->getMaxPerPage()));
     };
     return array('jobsWithError' => $lastJobsWithError, 'jobPager' => $pager, 'jobPagerView' => $pagerView, 'jobPagerGenerator' => $routeGenerator);
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:23,代码来源:JobController.php

示例13: calculateNbResults

 private function calculateNbResults($nbPages)
 {
     return $nbPages * $this->pagerfanta->getMaxPerPage();
 }
开发者ID:3lolo,项目名称:lr_app,代码行数:4,代码来源:ViewTestCase.php

示例14: adminAction

 /**
  * Admin Thread entities.
  *
  * @Route("/admin", name="thread_admin")
  * @Template()
  */
 public function adminAction()
 {
     $session = $this->getRequest()->getSession();
     if (!$session->get('admin')) {
         return $this->redirect('/');
     }
     $request = $this->getRequest();
     $page = $request->query->get('page');
     if (!$page) {
         $page = 1;
     }
     $em = $this->getDoctrine()->getEntityManager();
     $query = $em->createQueryBuilder();
     $query->add('select', 't')->add('from', 'ApplicationForumBundle:Thread t')->add('orderBy', 't.featured DESC, t.id DESC');
     // categoria?
     $category_id = $request->query->get('c');
     if ($category_id) {
         $query->add('where', 't.forum_id = :forum_id')->setParameter('forum_id', $category_id);
     }
     $adapter = new DoctrineORMAdapter($query);
     $pagerfanta = new Pagerfanta($adapter);
     $pagerfanta->setMaxPerPage(20);
     // 10 by default
     $maxPerPage = $pagerfanta->getMaxPerPage();
     $pagerfanta->setCurrentPage($page);
     // 1 by default
     $entities = $pagerfanta->getCurrentPageResults();
     $routeGenerator = function ($page, $category_id) {
         $url = '?page=' . $page;
         if ($category_id) {
             $url .= '&c=' . $category_id;
         }
         return $url;
     };
     $view = new DefaultView();
     $html = $view->render($pagerfanta, $routeGenerator, array('category_id' => (int) $category_id));
     // estadisticas de anuncios
     $query = "SELECT COUNT(t.id) AS total, t.forum_id, f.title FROM Thread t, Forum f WHERE t.forum_id = f.id GROUP BY f.title ORDER BY total DESC";
     $db = $this->get('database_connection');
     $categories = $db->fetchAll($query);
     return array('categories_aux' => $categories, 'pager' => $html, 'entities' => $entities);
 }
开发者ID:norter,项目名称:directoriopro,代码行数:48,代码来源:ThreadController.php

示例15: configureCollectionRepresentation

 protected function configureCollectionRepresentation(CollectionRepresentation $collectionRepresentation, Pagerfanta $pager, $entity = null, $collectionRel = null)
 {
     // Properties
     $collectionRepresentation->total = $pager->getNbResults();
     $collectionRepresentation->page = $pager->getCurrentPage();
     $collectionRepresentation->limit = $pager->getMaxPerPage();
     // Links between pages
     $createRoute = function ($page, $limit) use($entity, $collectionRel) {
         $parameters = array('search' => array('page' => $page, 'limit' => $limit));
         return null !== $entity && null !== $collectionRel ? $this->getUrlGenerator()->generateEntityCollectionUrl($entity, $collectionRel, $parameters) : $this->getUrlGenerator()->generateCollectionUrl($parameters);
     };
     $collectionRepresentation->addLink($this->atomLinkFactory->create('self', $createRoute($pager->getCurrentPage(), $pager->getMaxPerPage())));
     if ($pager->hasNextPage()) {
         $collectionRepresentation->addLink($this->atomLinkFactory->create('next', $createRoute($pager->getNextPage(), $pager->getMaxPerPage())));
     }
     if ($pager->hasPreviousPage()) {
         $collectionRepresentation->addLink($this->atomLinkFactory->create('previous', $createRoute($pager->getPreviousPage(), $pager->getMaxPerPage())));
     }
     $collectionRepresentation->addLink($this->atomLinkFactory->create('first', $createRoute(1, $pager->getMaxPerPage())));
     $collectionRepresentation->addLink($this->atomLinkFactory->create('last', $createRoute($pager->getNbPages(), $pager->getMaxPerPage())));
 }
开发者ID:rpg600,项目名称:FSCRestBundle,代码行数:21,代码来源:AbstractResource.php


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