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


PHP Pagerfanta::getNbPages方法代码示例

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


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

示例1: __construct

 public function __construct(Pagerfanta $paginator, Request $request, $base_url)
 {
     $this->data = $paginator->getCurrentPageResults();
     $this->total_count = $paginator->getNbResults();
     $this->count = count($this->data);
     $query = array('q' => $request->get('q'), 'limit' => $request->get('limit'), 'page' => $request->get('page'));
     $this->query = $query;
     $this->urls['current'] = $base_url . '?' . http_build_query($query);
     if ($paginator->hasPreviousPage()) {
         $query['page'] = $paginator->getPreviousPage();
         $this->urls['previous'] = $base_url . '?' . http_build_query($query);
         if ($paginator->getCurrentPage() > 2) {
             $query['page'] = 1;
             $this->urls['start'] = $base_url . '?' . http_build_query($query);
         }
     }
     if ($paginator->hasNextPage()) {
         $query['page'] = $paginator->getNextPage();
         $this->urls['next'] = $base_url . '?' . http_build_query($query);
         if ($paginator->getCurrentPage() < $paginator->getNbPages() - 1) {
             $query['page'] = $paginator->getNbPages();
             $this->urls['end'] = $base_url . '?' . http_build_query($query);
         }
     }
 }
开发者ID:dstansby,项目名称:camdram,代码行数:25,代码来源:PaginatedCollection.php

示例2: searchAction

 /**
  * Perform a search and return a JSON response.
  *
  * @param Request $request
  *
  * @return JsonResponse
  */
 public function searchAction(Request $request)
 {
     $queryString = $request->query->get('q');
     $category = $request->query->get('category', null);
     $locale = $request->query->get('locale', null);
     $page = $this->listRestHelper->getPage();
     $limit = $this->listRestHelper->getLimit();
     $aggregateHits = [];
     $startTime = microtime(true);
     $categories = $category ? [$category] : $this->searchManager->getCategoryNames();
     foreach ($categories as $category) {
         $query = $this->searchManager->createSearch($queryString);
         if ($locale) {
             $query->locale($locale);
         }
         if ($category) {
             $query->category($category);
         }
         foreach ($query->execute() as $hit) {
             $aggregateHits[] = $hit;
         }
     }
     $time = microtime(true) - $startTime;
     $adapter = new ArrayAdapter($aggregateHits);
     $pager = new Pagerfanta($adapter);
     $pager->setMaxPerPage($limit);
     $pager->setCurrentPage($page);
     $representation = new SearchResultRepresentation(new CollectionRepresentation($pager->getCurrentPageResults(), 'result'), 'sulu_search_search', ['locale' => $locale, 'query' => $query, 'category' => $category], (int) $page, (int) $limit, $pager->getNbPages(), 'page', 'limit', false, count($aggregateHits), $this->getCategoryTotals($aggregateHits), number_format($time, 8));
     $view = View::create($representation);
     $context = SerializationContext::create();
     $context->enableMaxDepthChecks();
     $context->setSerializeNull(true);
     $view->setSerializationContext($context);
     return $this->viewHandler->handle($view);
 }
开发者ID:kriswillis,项目名称:sulu,代码行数:42,代码来源:SearchController.php

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

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

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

示例6: paginate

 /**
  * Build a Pagerfanta object based on the pagination information.
  *
  * The pagination information can be passed as a parameter, and if not the method use the injected provider to
  * extract pagination information based on the current context.
  *
  * @param \Pagerfanta\Adapter\AdapterInterface $adapter Wrapped query
  * @param PaginatedCollectionRequestInterface  $paginationInfo Requested pagination
  *
  * @return \PagerFanta\PagerFanta
  *
  * @throws \LogicException If no pagination could be used in order to paginate the results
  * @throws \AlphaLabs\Pagination\Exception\InvalidRequestedPage If the requested pagination could not be applied
  */
 public function paginate(AdapterInterface $adapter, PaginatedCollectionRequestInterface $paginationInfo = null)
 {
     if (is_null($paginationInfo)) {
         if (is_null($this->paginationInfoProvider)) {
             throw new \LogicException('A PaginatedCollectionRequestProviderInterface must be injected if you want to use pagination ' . 'and don\\t want to handle the pagination info with your own logic.');
         }
         $paginationInfo = $this->paginationInfoProvider->getPaginatedCollectionRequest();
         if (is_null($paginationInfo)) {
             throw new \LogicException('No pagination could be provided by the PaginatedCollectionRequestProviderInterface. The provider ' . 'must at least provide default pagination information in order to use the paginate() method.');
         }
     }
     $pager = new Pagerfanta($adapter);
     try {
         $pager->setMaxPerPage($paginationInfo->getItemsPerPage())->setCurrentPage($paginationInfo->getPage());
     } catch (LessThan1CurrentPageException $e) {
         $invalidPageException = new InvalidRequestedPage();
         $invalidPageException->setRequestedPage($paginationInfo->getPage())->setTargetPage(1);
         throw $invalidPageException;
     } catch (OutOfRangeCurrentPageException $e) {
         $invalidPageException = new InvalidRequestedPage();
         $invalidPageException->setRequestedPage($paginationInfo->getPage())->setTargetPage($pager->getNbPages() - 1);
         throw $invalidPageException;
     }
     return $pager;
 }
开发者ID:alphalabs,项目名称:pagination,代码行数:39,代码来源:PagerTrait.php

示例7: __construct

 public function __construct(Pagerfanta $pagerfanta)
 {
     $photos = $pagerfanta->getCurrentPageResults();
     $this->photos = $photos instanceof \Traversable ? iterator_to_array($photos) : $photos;
     $this->page = $pagerfanta->getCurrentPage();
     $this->pagesCount = $pagerfanta->getNbPages();
     $this->totalCount = $pagerfanta->getNbResults();
 }
开发者ID:Koc,项目名称:stfalcon-test-task,代码行数:8,代码来源:PhotosCollection.php

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

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

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

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

示例12: getFolderChildrens

 /**
  * Return list of children node
  * @param \eZ\Publish\Core\Repository\Values\Content\Location $location
  * @param type $maxPerPage
  * @param type $currentPage
  * @return type
  */
 public function getFolderChildrens(\eZ\Publish\Core\Repository\Values\Content\Location $location, $currentUser, $maxPerPage, $currentPage = 1, $category)
 {
     $criteria = array(new Criterion\ParentLocationId($location->id), new Criterion\ContentTypeIdentifier(array('service_link')), new Criterion\Visibility(Criterion\Visibility::VISIBLE));
     if (isset($category) && $category != "all") {
         $criteria[] = new Criterion\Field('category', Criterion\Operator::CONTAINS, $category);
     }
     $query = new Query();
     $query->filter = new Criterion\LogicalAnd($criteria);
     $query->sortClauses = array($this->sortClauseAuto($location));
     $searchResult = $this->repository->getSearchService()->findContent($query);
     $subscritions = $this->fetchByUserId($currentUser->id);
     //$this->debug($subscritions);
     $content = array();
     $contentId = null;
     foreach ($searchResult->searchHits as $serviceLink) {
         if (!$contentId) {
             $contentId = $serviceLink->valueObject->getVersionInfo()->getContentInfo()->id;
         }
         $content[] = array('serviceLink' => $serviceLink->valueObject->contentInfo->mainLocationId, 'subscrition' => $this->hasSubscription($subscritions, $serviceLink->valueObject->getVersionInfo()->getContentInfo()->id));
     }
     $result['offset'] = ($currentPage - 1) * $maxPerPage;
     $adapter = new ArrayAdapter($content);
     $pagerfanta = new Pagerfanta($adapter);
     $pagerfanta->setMaxPerPage($maxPerPage);
     $pagerfanta->setCurrentPage($currentPage);
     $httpReferer = $_SERVER['SCRIPT_URL'];
     if (isset($category)) {
         $httpReferer .= "?category=" . $category;
     } else {
         $httpReferer .= "?";
     }
     $result['offset'] = ($currentPage - 1) * $maxPerPage;
     $result['prev_page'] = $pagerfanta->hasPreviousPage() ? $pagerfanta->getPreviousPage() : 0;
     $result['next_page'] = $pagerfanta->hasNextPage() ? $pagerfanta->getNextPage() : 0;
     $result['nb_pages'] = $pagerfanta->getNbPages();
     $result['items'] = $pagerfanta->getCurrentPageResults();
     $result['base_href'] = $httpReferer;
     $result['current_page'] = $pagerfanta->getCurrentPage();
     $result['options'] = isset($contentId) ? $this->getCategorie($contentId, "ezselection") : array();
     return $result;
 }
开发者ID:Open-Wide,项目名称:OwPublishServiceBundle,代码行数:48,代码来源:FetchByLegacy.php

示例13: sharedSpacesAction

 /**
  * @Route(
  *      "/{resourceId}/shared/spaces",
  *      name="innova_collecticiel_shared_spaces",
  *      requirements={"resourceId" = "\d+"},
  *      defaults={"page" = 1}
  * )
  * @ParamConverter("dropzone", class="InnovaCollecticielBundle:Dropzone", options={"id" = "resourceId"})
  * @Template()
  */
 public function sharedSpacesAction($dropzone, $page)
 {
     $this->get('innova.manager.dropzone_voter')->isAllowToOpen($dropzone);
     $this->get('innova.manager.dropzone_voter')->isAllowToEdit($dropzone);
     $dropRepo = $this->getDoctrine()->getManager()->getRepository('InnovaCollecticielBundle:Drop');
     // dropsQuery : finished à TRUE et unlocked_drop à FALSE
     $dropsQuery = $dropRepo->getDropsAwaitingCorrectionQuery($dropzone);
     $countUnterminatedDrops = $dropRepo->countUnterminatedDropsByDropzone($dropzone->getId());
     // Déclarations des nouveaux tableaux, qui seront passés à la vue
     $userToCommentCount = array();
     $userNbTextToRead = array();
     foreach ($dropzone->getDrops() as $drop) {
         /** InnovaERV : ajout pour calculer les 2 zones **/
         // Nombre de commentaires non lus/ Repo : Comment
         $nbCommentsPerUser = $this->getDoctrine()->getRepository('InnovaCollecticielBundle:Comment')->countCommentNotRead($drop->getUser());
         // Nombre de devoirs à corriger/ Repo : Document
         $nbTextToRead = $this->getDoctrine()->getRepository('InnovaCollecticielBundle:Document')->countTextToRead($drop->getUser());
         // Affectations des résultats dans les tableaux
         $userToCommentCount[$drop->getUser()->getId()] = $nbCommentsPerUser;
         $userNbTextToRead[$drop->getUser()->getId()] = $nbTextToRead;
     }
     $adapter = new DoctrineORMAdapter($dropsQuery);
     $pager = new Pagerfanta($adapter);
     $pager->setMaxPerPage(DropzoneBaseController::DROP_PER_PAGE);
     try {
         $pager->setCurrentPage($page);
     } catch (NotValidCurrentPageException $e) {
         if ($page > 0) {
             return $this->redirect($this->generateUrl('innova_collecticiel_drops_awaiting_paginated', array('resourceId' => $dropzone->getId(), 'page' => $pager->getNbPages())));
         } else {
             throw new NotFoundHttpException();
         }
     }
     $adminInnova = false;
     if ($this->get('security.context')->isGranted('ROLE_ADMIN' === true)) {
         $adminInnova = true;
     }
     $dataToView = $this->addDropsStats($dropzone, array('workspace' => $dropzone->getResourceNode()->getWorkspace(), '_resource' => $dropzone, 'dropzone' => $dropzone, 'unterminated_drops' => $countUnterminatedDrops, 'pager' => $pager, 'nbCommentNotRead' => $userToCommentCount, 'userNbTextToRead' => $userNbTextToRead, 'adminInnova' => $adminInnova));
     return $dataToView;
 }
开发者ID:arnaudbey,项目名称:CollecticielBundle,代码行数:50,代码来源:DropController.php

示例14: addLinksToMetadata

 /**
  * @param Pagerfanta $paginator
  * @param $route
  * @param $limit
  */
 protected function addLinksToMetadata(Pagerfanta $paginator, $route, $limit)
 {
     $data = $this->get('bite_codes_rest_api_generator.services.response_data');
     $router = $this->get('router');
     $first = $router->generate($route, ['page' => 1, 'limit' => $limit], UrlGeneratorInterface::ABSOLUTE_URL);
     $prev = $paginator->hasPreviousPage() ? $router->generate($route, ['page' => $paginator->getPreviousPage(), 'limit' => $limit], UrlGeneratorInterface::ABSOLUTE_URL) : null;
     $current = $router->generate($route, ['page' => $paginator->getCurrentPage(), 'limit' => $limit], UrlGeneratorInterface::ABSOLUTE_URL);
     $next = $paginator->hasNextPage() ? $router->generate($route, ['page' => $paginator->getNextPage(), 'limit' => $limit], UrlGeneratorInterface::ABSOLUTE_URL) : null;
     $last = $router->generate($route, ['page' => $paginator->getNbPages(), 'limit' => $limit], UrlGeneratorInterface::ABSOLUTE_URL);
     $data->addLink('first', $first);
     $data->addLink('prev', $prev);
     $data->addLink('current', $current);
     $data->addLink('next', $next);
     $data->addLink('last', $last);
     $data->addMeta('total', $paginator->getNbResults());
 }
开发者ID:bitecodes,项目名称:rest-api-generator-bundle,代码行数:21,代码来源:RestApiController.php

示例15: sharedSpacesAction

 /**
  * @Route(
  *      "/{resourceId}/shared/spaces",
  *      name="innova_collecticiel_shared_spaces",
  *      requirements={"resourceId" = "\d+"},
  *      defaults={"page" = 1}
  * )
  * @Route(
  *      "/{resourceId}/shared/spaces/{page}",
  *      name="innova_collecticiel_shared_spaces_paginated",
  *      requirements={"resourceId" = "\d+", "page" = "\d+"},
  *      defaults={"page" = 1}
  * )
  * @ParamConverter("dropzone", class="InnovaCollecticielBundle:Dropzone", options={"id" = "resourceId"})
  * @Template()
  */
 public function sharedSpacesAction($dropzone, $page)
 {
     // Onglet "Espaces partagés"
     $this->get('innova.manager.dropzone_voter')->isAllowToOpen($dropzone);
     $this->get('innova.manager.dropzone_voter')->isAllowToEdit($dropzone);
     $dropzoneManager = $this->get('innova.manager.dropzone_manager');
     $dropzoneVoter = $this->get('innova.manager.dropzone_voter');
     // Récupération du Workspace
     $workspace = $dropzone->getResourceNode()->getWorkspace();
     $dropRepo = $this->getDoctrine()->getManager()->getRepository('InnovaCollecticielBundle:Drop');
     // Ajout du code pour afficher les élèves inscrits mais qui n'ont pas déposé. InnovaERV.
     // Déclaration du tableau de workspace
     $workspaceArray = array();
     // Récupération du workspace courant
     $workspaceId = $dropzone->getResourceNode()->getWorkspace()->getId();
     $workspaceArray[] = $workspaceId;
     $userManager = $this->get('claroline.manager.user_manager');
     $withPager = false;
     $usersByWorkspaces = $userManager->getUsersByWorkspaces($workspaceArray, $page, 20, $withPager);
     //      var_dump($usersByWorkspaces[0]);
     $userWithRights = $userManager->getUsersWithRights($dropzone->getResourceNode());
     // Fin ajout du code pour afficher les élèves inscrits mais qui n'ont pas déposé. InnovaERV.
     // dropsQuery : finished à TRUE et unlocked_drop à FALSE
     $dropsQuery = $dropRepo->getSharedSpacesQuery($dropzone, $workspace);
     $countUnterminatedDrops = $dropRepo->countUnterminatedDropsByDropzone($dropzone->getId());
     // Déclarations des nouveaux tableaux, qui seront passés à la vue
     $userNbDocDropped = array();
     $userNbAdressedRequests = array();
     foreach ($dropzone->getDrops() as $drop) {
         /** InnovaERV : ajout pour calculer les 2 zones **/
         // Nombre de documents déposés/ Repo : Document
         $nbDocDropped = $this->getDoctrine()->getRepository('InnovaCollecticielBundle:Document')->countDocSubmissions($drop->getUser(), $drop->getDropZone());
         // Nombre de demandes adressées/ Repo : Document
         $nbAdressedRequests = $this->getDoctrine()->getRepository('InnovaCollecticielBundle:Document')->countTextToRead($drop->getUser(), $drop->getDropZone());
         // Affectations des résultats dans les tableaux
         $userNbDocDropped[$drop->getUser()->getId()] = $nbDocDropped;
         $userNbAdressedRequests[$drop->getUser()->getId()] = $nbAdressedRequests;
     }
     $adapter = new DoctrineORMAdapter($dropsQuery);
     $pager = new Pagerfanta($adapter);
     $pager->setMaxPerPage(DropzoneBaseController::DROP_PER_PAGE);
     //echo DropzoneBaseController::DROP_PER_PAGE . "--";
     try {
         $pager->setCurrentPage($page);
     } catch (NotValidCurrentPageException $e) {
         if ($page > 0) {
             return $this->redirect($this->generateUrl('innova_collecticiel_shared_spaces_paginated', array('resourceId' => $dropzone->getId(), 'page' => $pager->getNbPages())));
         } else {
             throw new NotFoundHttpException();
         }
     }
     $adminInnova = $dropzoneVoter->checkEditRight($dropzone);
     $collecticielOpenOrNot = $dropzoneManager->collecticielOpenOrNot($dropzone);
     /*
             if ($this->get('security.context')->isGranted('ROLE_ADMIN' === true)) {
                 $adminInnova = true;
             }*/
     $dataToView = $this->addDropsStats($dropzone, array('workspace' => $dropzone->getResourceNode()->getWorkspace(), '_resource' => $dropzone, 'dropzone' => $dropzone, 'unterminated_drops' => $countUnterminatedDrops, 'pager' => $pager, 'userNbDocDropped' => $userNbDocDropped, 'userNbAdressedRequests' => $userNbAdressedRequests, 'adminInnova' => $adminInnova, 'usersByWorkspaces' => $usersByWorkspaces, 'collecticielOpenOrNot' => $collecticielOpenOrNot));
     return $dataToView;
 }
开发者ID:ngodfraind,项目名称:CollecticielBundle,代码行数:76,代码来源:DropController.php


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