當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。