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


PHP Pagerfanta::count方法代码示例

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


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

示例1: getPagerfantaRepresentation

 /**
  * Construct a pagerfanta representation from the current request
  *
  * @param AdapterInterface $adapter - The adapter to use
  * @return QueryablePaginatedRepresentation
  */
 protected function getPagerfantaRepresentation(Request $request, AdapterInterface $adapter)
 {
     $pagerfanta = new Pagerfanta($adapter);
     $limit = $request->query->get('limit');
     $zeroLimit = false;
     if (!$limit && ($limit === 0 || $limit === '0')) {
         $limit = $pagerfanta->count();
         $zeroLimit = true;
     }
     if (!$limit) {
         $limit = 10;
     }
     $pagerfanta->setMaxPerPage($limit);
     $page = $request->query->get('page');
     $nbPages = $pagerfanta->getNbPages();
     if (!$page) {
         $page = 1;
     }
     // Avoid errors: redirect to max page
     if ($page > $nbPages) {
         $page = $nbPages;
     }
     $pagerfanta->setCurrentPage($page);
     $route = new Route($request->get('_route'), $request->attributes->get('_route_params'), false);
     return new QueryablePaginatedRepresentation(new CollectionRepresentation($pagerfanta->getCurrentPageResults()), $route->getName(), $route->getParameters(), $pagerfanta->getCurrentPage(), $zeroLimit ? 0 : $pagerfanta->getMaxPerPage(), $nbPages, $pagerfanta->count(), null, null, $route->isAbsolute(), $request->query->get('where'), $request->query->get('search'), $request->query->get('order'), null, null, null);
 }
开发者ID:uebb,项目名称:hateoas-bundle,代码行数:32,代码来源:ResourceCollectionView.php

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

示例3: serializePagerfantaToJson

 public function serializePagerfantaToJson(JsonSerializationVisitor $visitor, Pagerfanta $pagerfanta, array $type, Context $context)
 {
     $type['name'] = 'array';
     return ['items' => $visitor->visitArray((array) $pagerfanta->getCurrentPageResults(), $type, $context), 'pages_count' => $pagerfanta->getNbPages(), 'current_page' => $pagerfanta->getCurrentPage(), 'max_per_page' => $pagerfanta->getMaxPerPage(), 'items_count' => $pagerfanta->count()];
 }
开发者ID:moriony,项目名称:rpc-server,代码行数:5,代码来源:PagerfantaHandler.php

示例4: getTotal

 /**
  * Get the total number of results.
  *
  * @return int
  */
 public function getTotal() : int
 {
     return $this->paginator->count();
 }
开发者ID:objective-php,项目名称:serializer,代码行数:9,代码来源:PagerFantaAdapter.php

示例5: testCountShouldReturnNbResults

 public function testCountShouldReturnNbResults()
 {
     $this->setAdapterNbResultsAny(30);
     $this->assertSame(30, $this->pagerfanta->count());
 }
开发者ID:3lolo,项目名称:lr_app,代码行数:5,代码来源:PagerfantaTest.php


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