當前位置: 首頁>>代碼示例>>PHP>>正文


PHP RequestConfiguration::isPaginated方法代碼示例

本文整理匯總了PHP中Sylius\Bundle\ResourceBundle\Controller\RequestConfiguration::isPaginated方法的典型用法代碼示例。如果您正苦於以下問題:PHP RequestConfiguration::isPaginated方法的具體用法?PHP RequestConfiguration::isPaginated怎麽用?PHP RequestConfiguration::isPaginated使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Sylius\Bundle\ResourceBundle\Controller\RequestConfiguration的用法示例。


在下文中一共展示了RequestConfiguration::isPaginated方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getResources

 /**
  * {@inheritdoc}
  */
 public function getResources(RequestConfiguration $requestConfiguration, RepositoryInterface $repository)
 {
     if (null !== ($repositoryMethod = $requestConfiguration->getRepositoryMethod())) {
         $callable = [$repository, $repositoryMethod];
         $resources = call_user_func_array($callable, $requestConfiguration->getRepositoryArguments());
         return $resources;
     }
     if (!$requestConfiguration->isPaginated() && !$requestConfiguration->isLimited()) {
         return $repository->findBy($requestConfiguration->getCriteria(), $requestConfiguration->getSorting());
     }
     if (!$requestConfiguration->isPaginated()) {
         return $repository->findBy($requestConfiguration->getCriteria(), $requestConfiguration->getSorting(), $requestConfiguration->getLimit());
     }
     return $repository->createPaginator($requestConfiguration->getCriteria(), $requestConfiguration->getSorting());
 }
開發者ID:enhavo,項目名稱:enhavo,代碼行數:18,代碼來源:ResourcesResolver.php

示例2: getResources

 /**
  * {@inheritdoc}
  */
 public function getResources(RequestConfiguration $requestConfiguration, RepositoryInterface $repository)
 {
     $repositoryMethod = $requestConfiguration->getRepositoryMethod();
     if (null !== $repositoryMethod) {
         $arguments = array_values($requestConfiguration->getRepositoryArguments());
         return $repository->{$repositoryMethod}(...$arguments);
     }
     if (!$requestConfiguration->isPaginated() && !$requestConfiguration->isLimited()) {
         return $repository->findAll();
     }
     if (!$requestConfiguration->isPaginated()) {
         return $repository->findBy($requestConfiguration->getCriteria(), $requestConfiguration->getSorting(), $requestConfiguration->getLimit());
     }
     return $repository->createPaginator($requestConfiguration->getCriteria(), $requestConfiguration->getSorting());
 }
開發者ID:loic425,項目名稱:Sylius,代碼行數:18,代碼來源:ResourcesResolver.php

示例3:

 function it_creates_paginator_by_default(RequestConfiguration $requestConfiguration, RepositoryInterface $repository, Pagerfanta $paginator)
 {
     $requestConfiguration->isHtmlRequest()->willReturn(true);
     $requestConfiguration->getRepositoryMethod()->willReturn(null);
     $requestConfiguration->isPaginated()->willReturn(true);
     $requestConfiguration->getPaginationMaxPerPage()->willReturn(5);
     $requestConfiguration->isLimited()->willReturn(false);
     $requestConfiguration->getCriteria()->willReturn([]);
     $requestConfiguration->getSorting()->willReturn([]);
     $repository->createPaginator([], [])->willReturn($paginator);
     $this->getResources($requestConfiguration, $repository)->shouldReturn($paginator);
 }
開發者ID:TheMadeleine,項目名稱:Sylius,代碼行數:12,代碼來源:ResourcesResolverSpec.php

示例4: get

 /**
  * {@inheritdoc}
  */
 public function get(RequestConfiguration $requestConfiguration, RepositoryInterface $repository)
 {
     if (null !== ($repositoryMethod = $requestConfiguration->getRepositoryMethod())) {
         $callable = [$repository, $repositoryMethod];
         return call_user_func_array($callable, $requestConfiguration->getRepositoryArguments());
     }
     if (!$requestConfiguration->isPaginated() && !$requestConfiguration->isLimited()) {
         return $repository->findAll();
     }
     if (!$requestConfiguration->isPaginated()) {
         return $repository->findBy($requestConfiguration->getCriteria(), $requestConfiguration->getSorting(), $requestConfiguration->getLimit());
     }
     $request = $requestConfiguration->getRequest();
     /** @var Pagerfanta $paginator */
     $paginator = $repository->createPaginator($requestConfiguration->getCriteria(), $requestConfiguration->getSorting());
     $paginator->setCurrentPage($request->query->get('page', 1));
     if (!$requestConfiguration->isHtmlRequest()) {
         $route = new Route($request->attributes->get('_route'), array_merge($request->attributes->get('_route_params'), $request->query->all()));
         return $this->pagerfantaRepresentationFactory->createRepresentation($paginator, $route);
     }
     return $paginator;
 }
開發者ID:Mangetsu,項目名稱:Sylius,代碼行數:25,代碼來源:ResourcesCollectionProvider.php

示例5: array

 function it_creates_a_pagniated_respresentation_for_pagerfanta_for_non_html_requests(RequestConfiguration $requestConfiguration, RepositoryInterface $repository, Pagerfanta $paginator, Request $request, ParameterBag $queryParameters, ParameterBag $requestAttributes, PagerfantaFactory $pagerfantaRepresentationFactory, PaginatedRepresentation $paginatedRepresentation)
 {
     $requestConfiguration->isHtmlRequest()->willReturn(false);
     $requestConfiguration->getRepositoryMethod()->willReturn(null);
     $requestConfiguration->isPaginated()->willReturn(true);
     $requestConfiguration->isLimited()->willReturn(false);
     $requestConfiguration->getCriteria()->willReturn(array());
     $requestConfiguration->getSorting()->willReturn(array());
     $repository->createPaginator(array(), array())->willReturn($paginator);
     $requestConfiguration->getRequest()->willReturn($request);
     $request->query = $queryParameters;
     $queryParameters->get('page', 1)->willReturn(6);
     $queryParameters->all()->willReturn(array('foo' => 2, 'bar' => 15));
     $request->attributes = $requestAttributes;
     $requestAttributes->get('_route')->willReturn('sylius_product_index');
     $requestAttributes->get('_route_params')->willReturn(array('slug' => 'foo-bar'));
     $paginator->setCurrentPage(6)->shouldBeCalled();
     $pagerfantaRepresentationFactory->createRepresentation($paginator, Argument::type(Route::class))->willReturn($paginatedRepresentation);
     $this->get($requestConfiguration, $repository)->shouldReturn($paginatedRepresentation);
 }
開發者ID:Spomky,項目名稱:Sylius,代碼行數:20,代碼來源:ResourcesCollectionProviderSpec.php


注:本文中的Sylius\Bundle\ResourceBundle\Controller\RequestConfiguration::isPaginated方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。