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


PHP Pagerfanta::setCurrentPage方法代码示例

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


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

示例1: indexAction

 public function indexAction(Request $request, $page = 1)
 {
     $getTypes = $request->query->get('type_filters');
     $getSubjects = $request->query->get('subject_filters');
     $getPublishers = $request->query->get('publisher_filters');
     $typeFilters = !empty($getTypes) ? explode(',', $getTypes) : [];
     $subjectFilters = !empty($getSubjects) ? explode(',', $getSubjects) : [];
     $publisherFilters = !empty($getPublishers) ? explode(',', $getPublishers) : [];
     $journalSearcher = $this->get('fos_elastica.index.search.journal');
     $boolQuery = new Query\Bool();
     $match = new Query\Match();
     $match->setField('status', 1);
     $boolQuery->addMust($match);
     $match = new Query\Match();
     $match->setField('published', true);
     $boolQuery->addMust($match);
     if (!empty($typeFilters) || !empty($subjectFilters) || !empty($publisherFilters)) {
         foreach ($typeFilters as $type) {
             $match = new Query\Match();
             $match->setField('publisher.publisher_type.name', $type);
             $boolQuery->addMust($match);
         }
         foreach ($subjectFilters as $subject) {
             $match = new Query\Match();
             $match->setField('subjects.subject', $subject);
             $boolQuery->addMust($match);
         }
         foreach ($publisherFilters as $publisher) {
             $match = new Query\Match();
             $match->setField('publisher.name', $publisher);
             $boolQuery->addMust($match);
         }
     }
     $journalQuery = new Query($boolQuery);
     $typeAgg = new Aggregation\Terms('types');
     $typeAgg->setField('publisher.publisher_type.name');
     $typeAgg->setOrder('_term', 'asc');
     $typeAgg->setSize(0);
     $journalQuery->addAggregation($typeAgg);
     $subjectAgg = new Aggregation\Terms('subjects');
     $subjectAgg->setField('subjects.subject');
     $subjectAgg->setOrder('_term', 'asc');
     $subjectAgg->setSize(0);
     $journalQuery->addAggregation($subjectAgg);
     $publisherAgg = new Aggregation\Terms('publishers');
     $publisherAgg->setField('publisher.name');
     $publisherAgg->setOrder('_term', 'asc');
     $publisherAgg->setSize(0);
     $journalQuery->addAggregation($publisherAgg);
     $adapter = new ElasticaAdapter($journalSearcher, $journalQuery);
     $pagerfanta = new Pagerfanta($adapter);
     $pagerfanta->setMaxPerPage(21);
     $pagerfanta->setCurrentPage($page);
     $journals = $pagerfanta->getCurrentPageResults();
     $types = $adapter->getResultSet()->getAggregation('types')['buckets'];
     $subjects = $adapter->getResultSet()->getAggregation('subjects')['buckets'];
     $publishers = $adapter->getResultSet()->getAggregation('publishers')['buckets'];
     $data = ['types' => $types, 'subjects' => $subjects, 'publishers' => $publishers, 'type_filters' => $typeFilters, 'subject_filters' => $subjectFilters, 'publisher_filters' => $publisherFilters, 'journals' => $journals, 'pagerfanta' => $pagerfanta, 'page' => 'explore'];
     return $this->render('OjsSiteBundle:Explore:index.html.twig', $data);
 }
开发者ID:hasantayyar,项目名称:ojs,代码行数:60,代码来源:ExploreController.php

示例2: it_iterates_slice

 /**
  * @test
  */
 public function it_iterates_slice()
 {
     $pagerfanta = new Pagerfanta(new PorpaginasAdapter(new ArrayResult(array(1, 2, 3, 4))));
     $pagerfanta->setMaxPerPage(2);
     $pagerfanta->setCurrentPage(1);
     $this->assertEquals(array(1, 2), $pagerfanta->getCurrentPageResults());
     $pagerfanta->setCurrentPage(2);
     $this->assertEquals(array(3, 4), $pagerfanta->getCurrentPageResults());
 }
开发者ID:moufmouf,项目名称:porpaginas,代码行数:12,代码来源:PorpaginasAdapterTest.php

示例3: getPagerfanta

 /**
  * @return Pagerfanta
  */
 public function getPagerfanta()
 {
     if (is_null($this->pagerfanta)) {
         $adapter = new DoctrineDBALAdapter($this->getQueryBuilder(), $this->getCountField(), $this->getUseDistinctCount());
         $this->pagerfanta = new Pagerfanta($adapter);
         $this->pagerfanta->setCurrentPage($this->getPage());
         $this->pagerfanta->setMaxPerPage($this->getLimit());
     }
     return $this->pagerfanta;
 }
开发者ID:headonkeyboard,项目名称:KunstmaanBundlesCMS,代码行数:13,代码来源:AbstractDoctrineDBALAdminListConfigurator.php

示例4: getPagerfanta

 /**
  * @return Pagerfanta
  */
 public function getPagerfanta()
 {
     if (is_null($this->pagerfanta)) {
         $adapter = new DoctrineORMAdapter($this->getQuery());
         $this->pagerfanta = new Pagerfanta($adapter);
         $this->pagerfanta->setNormalizeOutOfRangePages(true);
         $this->pagerfanta->setMaxPerPage($this->getLimit());
         $this->pagerfanta->setCurrentPage($this->getPage());
     }
     return $this->pagerfanta;
 }
开发者ID:VickyDeschrijver,项目名称:KunstmaanBundlesCMS,代码行数:14,代码来源:AbstractDoctrineORMAdminListConfigurator.php

示例5: createPagerWithAdapter

 public function createPagerWithAdapter(AdapterInterface $adapter, $currentPage, $max = 20)
 {
     $pager = new Pagerfanta($adapter);
     $pager->setMaxPerPage($max);
     // should be configurable
     try {
         $pager->setCurrentPage($currentPage);
     } catch (OutOfRangeCurrentPageException $e) {
         $pager->setCurrentPage(1);
     }
     return $pager;
 }
开发者ID:ngydat,项目名称:CoreBundle,代码行数:12,代码来源:PagerFactory.php

示例6: showFolderListAction

 /**
  * Displays the list of article.
  *
  * @param \Symfony\Component\HttpFoundation\Request $request request object
  * @param \eZ\Publish\Core\MVC\Symfony\View\ContentView $view
  *
  * @return \Symfony\Component\HttpFoundation\Response $location is flagged as invisible
  */
 public function showFolderListAction(Request $request, ContentView $view)
 {
     $languages = $this->getConfigResolver()->getParameter('languages');
     // Using the criteria helper (a demobundle custom service) to generate our query's criteria.
     // This is a good practice in order to have less code in your controller.
     $criteria = $this->get('ezdemo.criteria_helper')->generateListFolderCriterion($view->getLocation(), $this->container->getParameter('ezdemo.folder.folder_view.excluded_content_types'), $languages);
     // Generating query
     $query = new LocationQuery();
     $query->query = $criteria;
     $query->sortClauses = array(new SortClause\DatePublished());
     // Initialize pagination.
     $pager = new Pagerfanta(new ContentSearchAdapter($query, $this->getRepository()->getSearchService()));
     $pager->setMaxPerPage($this->container->getParameter('ezdemo.folder.folder_list.limit'));
     $pager->setCurrentPage($request->get('page', 1));
     $includedContentTypeIdentifiers = $this->container->getParameter('ezdemo.folder.folder_tree.included_content_types');
     // Get sub folder structure
     $subContentCriteria = $this->get('ezdemo.criteria_helper')->generateSubContentCriterion($view->getLocation(), $includedContentTypeIdentifiers, $languages);
     $subContentQuery = new LocationQuery();
     $subContentQuery->query = $subContentCriteria;
     $subContentQuery->sortClauses = array(new SortClause\ContentName());
     $searchService = $this->getRepository()->getSearchService();
     $subContent = $searchService->findLocations($subContentQuery);
     $treeItems = array();
     foreach ($subContent->searchHits as $hit) {
         $treeItems[] = $hit->valueObject;
     }
     $view->addParameters(['pagerFolder' => $pager, 'treeItems' => $treeItems]);
     return $view;
 }
开发者ID:ezsystems,项目名称:demobundle,代码行数:37,代码来源:FolderController.php

示例7: getData

 /**
  * {@inheritdoc}
  */
 public function getData(Parameters $parameters)
 {
     // Use output walkers option in DoctrineORMAdapter should be false as it affects performance greatly (see #3775)
     $paginator = new Pagerfanta(new DoctrineORMAdapter($this->queryBuilder, true, false));
     $paginator->setCurrentPage($parameters->get('page', 1));
     return $paginator;
 }
开发者ID:ahmadrabie,项目名称:Sylius,代码行数:10,代码来源:DataSource.php

示例8: createCollection

 public function createCollection(QueryBuilder $qb, Request $request, $route, array $routeParams = array())
 {
     $page = $request->query->get(self::PARAMETER_NAME_PAGE_NUMBER, 1);
     $count = $request->query->get(self::PARAMETER_NAME_PAGE_SIZE, self::PAGE_DEFAULT_COUNT);
     if ($count > self::MAX_PAGE_COUNT) {
         $count = self::MAX_PAGE_COUNT;
     }
     if ($count <= 0) {
         $count = self::PAGE_DEFAULT_COUNT;
     }
     $adapter = new DoctrineORMAdapter($qb);
     $pagerfanta = new Pagerfanta($adapter);
     $pagerfanta->setMaxPerPage($count);
     $pagerfanta->setCurrentPage($page);
     $players = [];
     foreach ($pagerfanta->getCurrentPageResults() as $result) {
         $players[] = $result;
     }
     $paginatedCollection = new PaginatedCollection($players, $pagerfanta->getNbResults());
     // make sure query parameters are included in pagination links
     $routeParams = array_merge($routeParams, $request->query->all());
     $createLinkUrl = function ($targetPage) use($route, $routeParams) {
         return $this->router->generate($route, array_merge($routeParams, array(self::PARAMETER_NAME_PAGE_NUMBER => $targetPage)));
     };
     $paginatedCollection->addLink('self', $createLinkUrl($page));
     $paginatedCollection->addLink('first', $createLinkUrl(1));
     $paginatedCollection->addLink('last', $createLinkUrl($pagerfanta->getNbPages()));
     if ($pagerfanta->hasNextPage()) {
         $paginatedCollection->addLink('next', $createLinkUrl($pagerfanta->getNextPage()));
     }
     if ($pagerfanta->hasPreviousPage()) {
         $paginatedCollection->addLink('prev', $createLinkUrl($pagerfanta->getPreviousPage()));
     }
     return $paginatedCollection;
 }
开发者ID:C3-TKO,项目名称:smash-api,代码行数:35,代码来源:PaginationFactory.php

示例9: renderPagination

 /**
  * @return string
  */
 public function renderPagination(Page $page, Twig_Environment $environment)
 {
     $pagerfanta = new Pagerfanta(new PorpaginasAdapter($page));
     $pagerfanta->setCurrentPage($page->getCurrentPage());
     $pagerfanta->setMaxPerPage($page->getCurrentLimit());
     return $environment->getExtension('pagerfanta')->renderPagerfanta($pagerfanta, $this->viewName, $this->options);
 }
开发者ID:moufmouf,项目名称:porpaginas,代码行数:10,代码来源:PagerfantaRenderingAdapter.php

示例10: createOrmPaginator

 /**
  * Creates a Doctrine ORM paginator for the given query builder.
  *
  * @param DoctrineQuery|DoctrineQueryBuilder $queryBuilder
  * @param int                                $page
  * @param int                                $maxPerPage
  *
  * @return Pagerfanta
  */
 public function createOrmPaginator($queryBuilder, $page = 1, $maxPerPage = self::MAX_ITEMS)
 {
     $paginator = new Pagerfanta(new DoctrineORMAdapter($queryBuilder, true, false));
     $paginator->setMaxPerPage($maxPerPage);
     $paginator->setCurrentPage($page);
     return $paginator;
 }
开发者ID:maldoinc,项目名称:EasyAdminBundle,代码行数:16,代码来源:Paginator.php

示例11: indexAction

 /**
  * @Route("/opencast/mediapackage", name="pumukitopencast")
  * @Template()
  */
 public function indexAction(Request $request)
 {
     if (!$this->has('pumukit_opencast.client')) {
         throw $this->createNotFoundException('PumukitOpencastBundle not configured.');
     }
     $opencastClient = $this->get('pumukit_opencast.client');
     $repository_multimediaobjects = $this->get('doctrine_mongodb')->getRepository('PumukitSchemaBundle:MultimediaObject');
     $limit = 10;
     $page = $request->get("page", 1);
     $criteria = $this->getCriteria($request);
     try {
         list($total, $mediaPackages) = $opencastClient->getMediaPackages(isset($criteria["name"]) ? $criteria["name"]->regex : "", $limit, ($page - 1) * $limit);
     } catch (\Exception $e) {
         return new Response($this->render('PumukitOpencastBundle:MediaPackage:error.html.twig', array('message' => $e->getMessage())), 400);
     }
     $currentPageOpencastIds = array();
     foreach ($mediaPackages as $mediaPackage) {
         $currentPageOpencastIds[] = $mediaPackage["id"];
     }
     $adapter = new FixedAdapter($total, $mediaPackages);
     $pagerfanta = new Pagerfanta($adapter);
     $pagerfanta->setMaxPerPage($limit);
     $pagerfanta->setCurrentPage($page);
     $repo = $repository_multimediaobjects->createQueryBuilder()->field("properties.opencast")->exists(true)->field("properties.opencast")->in($currentPageOpencastIds)->getQuery()->execute();
     return array('mediaPackages' => $pagerfanta, 'multimediaObjects' => $repo, 'player' => $opencastClient->getPlayerUrl());
 }
开发者ID:bmartinezteltek,项目名称:PuMuKIT2,代码行数:30,代码来源:MediaPackageController.php

示例12: indexAction

 public function indexAction(Request $req)
 {
     $rawSpeakers = $this->app['spot']->mapper(\OpenCFP\Domain\Entity\User::class)->all()->order(['first_name' => 'ASC'])->toArray();
     $airports = $this->service(AirportInformationDatabase::class);
     $rawSpeakers = array_map(function ($speaker) use($airports) {
         try {
             $airport = $airports->withCode($speaker['airport']);
             $speaker['airport'] = ['code' => $airport->code, 'name' => $airport->name, 'country' => $airport->country];
         } catch (\Exception $e) {
             $speaker['airport'] = ['code' => null, 'name' => null, 'country' => null];
         }
         return $speaker;
     }, $rawSpeakers);
     // Set up our page stuff
     $adapter = new ArrayAdapter($rawSpeakers);
     $pagerfanta = new Pagerfanta($adapter);
     $pagerfanta->setMaxPerPage(20);
     $pagerfanta->getNbResults();
     if ($req->get('page') !== null) {
         $pagerfanta->setCurrentPage($req->get('page'));
     }
     // Create our default view for the navigation options
     $routeGenerator = function ($page) {
         return '/admin/speakers?page=' . $page;
     };
     $view = new TwitterBootstrap3View();
     $pagination = $view->render($pagerfanta, $routeGenerator, ['proximity' => 3]);
     $templateData = ['airport' => $this->app->config('application.airport'), 'arrival' => date('Y-m-d', $this->app->config('application.arrival')), 'departure' => date('Y-m-d', $this->app->config('application.departure')), 'pagination' => $pagination, 'speakers' => $pagerfanta, 'page' => $pagerfanta->getCurrentPage()];
     return $this->render('admin/speaker/index.twig', $templateData);
 }
开发者ID:intfrr,项目名称:opencfp,代码行数:30,代码来源:SpeakersController.php

示例13: renderTag

 /**
  * Renders the tag.
  *
  * @param \Netgen\TagsBundle\API\Repository\Values\Tags\Tag $tag
  * @param \Symfony\Component\HttpFoundation\Request $request
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 protected function renderTag(Tag $tag, Request $request)
 {
     $configResolver = $this->getConfigResolver();
     if ($this->adapter instanceof TagAdapterInterface) {
         $this->adapter->setTag($tag);
     }
     $pager = new Pagerfanta($this->adapter);
     $pager->setMaxPerPage($configResolver->getParameter('tag_view.related_content_list.limit', 'eztags'));
     $pager->setCurrentPage($request->get('page', 1));
     $response = new Response();
     $response->headers->set('X-Tag-Id', $tag->id);
     if ($configResolver->getParameter('tag_view.cache', 'eztags') === true) {
         $response->setPublic();
         if ($configResolver->getParameter('tag_view.ttl_cache', 'eztags') === true) {
             $response->setSharedMaxAge($configResolver->getParameter('tag_view.default_ttl', 'eztags'));
         }
         // Make the response vary against X-User-Hash header ensures that an HTTP
         // reverse proxy caches the different possible variations of the
         // response as it can depend on user role for instance.
         if ($request->headers->has('X-User-Hash')) {
             $response->setVary('X-User-Hash');
         }
         $response->setLastModified($tag->modificationDate);
     }
     return $this->render($configResolver->getParameter('tag_view.template', 'eztags'), array('tag' => $tag, 'pager' => $pager), $response);
 }
开发者ID:umanit,项目名称:TagsBundle,代码行数:34,代码来源:TagViewController.php

示例14: testGetNextPageShouldThrowALogicExceptionIfTheCurrentPageIsTheLast

 /**
  * @expectedException Pagerfanta\Exception\LogicException
  */
 public function testGetNextPageShouldThrowALogicExceptionIfTheCurrentPageIsTheLast()
 {
     $this->setAdapterNbResultsAny(100);
     $this->pagerfanta->setMaxPerPage(10);
     $this->pagerfanta->setCurrentPage(10);
     $this->pagerfanta->getNextPage();
 }
开发者ID:3lolo,项目名称:lr_app,代码行数:10,代码来源:PagerfantaTest.php

示例15: viewAction

 /**
  * Lists all ArchivedClock entities within the requested week
  *
  * @param integer $year  Year in YYYY format
  * @param integer $month Month in MM format
  * @param integer $day   Day in DD format
  *
  * @return Symfony\Component\HttpFoundation\Response
  */
 public function viewAction($year, $month, $day)
 {
     if (false === $this->get('security.context')->isGranted('ROLE_ADMIN')) {
         throw new AccessDeniedException();
     }
     $em = $this->getDoctrine()->getManager();
     $week = new \DateTime();
     $week->setDate($year, $month, $day);
     $week->setTime(0, 0, 0);
     // Midnight
     $week = $this->container->get('dt_utils')->getFirstDayOfWeek($week);
     $archivedClocksQB = $em->createQueryBuilder()->select('ac')->from('OpenSkedgeBundle:ArchivedClock', 'ac')->where('ac.week = :week')->setParameter('week', $week);
     $page = $this->container->get('request')->query->get('page', 1);
     $limit = $this->container->get('request')->query->get('limit', 15);
     $adapter = new DoctrineORMAdapter($archivedClocksQB);
     $paginator = new Pagerfanta($adapter);
     try {
         $paginator->setMaxPerPage($limit);
         $paginator->setCurrentPage($page);
         $entities = $paginator->getCurrentPageResults();
     } catch (NotValidMaxPerPageException $e) {
         throw new HttpException(400, 'Not a valid limit', $e, array(), $e->getCode());
     } catch (NotValidCurrentPageException $e) {
         throw $this->createNotFoundException('Page does not exist.');
     }
     return $this->render('OpenSkedgeBundle:HoursReport:view.html.twig', array('week' => $week, 'entities' => $entities, 'paginator' => $paginator));
 }
开发者ID:edubacco,项目名称:OpenSkedge,代码行数:36,代码来源:HoursReportController.php


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