Get the pager for the message list of a subject.

@param \Claroline\ForumBundle\Entity\Subject $subject
@param integer $page
@param integer $max

@return \Pagerfanta\Pagerfanta
346139
public function getMessagesPager(Subject $subject, $page = 1, $max = 20)
    {
        $messages = $this->messageRepo->findBySubject($subject);

        return $this->pagerFactory->createPagerFromArray($messages, $page, $max);
    }
679462
protected function getFindPager(Query $query, $currentPage, $maxPerPage)
    {
        $adapter = new FindAdapter($query, $this->getSite()->getFindService());
        $pager = new Pagerfanta($adapter);

        $pager->setNormalizeOutOfRangePages(true);
        $pager->setMaxPerPage($maxPerPage);
        $pager->setCurrentPage($currentPage);

        return $pager;
    }
748066
public function getAllGroupsBySearch($page, $search, $max = 50)
    {
        $query = $this->groupRepo->findAllGroupsBySearch($search);
        return $this->pagerFactory->createPagerFromArray($query, $page, $max);
    }
620482
public function paginate($page, $perPage = 30)
	{
		$this->set('from', max(0, $perPage * ($page - 1)));
		$this->set('size', $perPage);

		return $this;
	}
137349
protected function getPage($records, $maxshown, $numpages) {
        $show = floor($numpages / 2);
        if (self::$lastpage > $numpages) {
            self::$page = (self::$current > $show ? (self::$current - $show) : 1);
            if (self::$current < (self::$lastpage - $show)) {
                self::$lastpage = ((self::$current <= $show) ? (self::$current + ($numpages - self::$current)) : (self::$current + $show));
            }
            else { self::$page = self::$current - ($numpages - ((ceil(intval($records) / ($maxshown >= 1 ? intval($maxshown) : 1)) - self::$current)) - 1); }
        }
        else { self::$page = 1; }
    }
1088238
public function getPagedResults($limit = 50, $page = 0)
    {
        $dql = sprintf(self::DQL_GET_PAGED, AuditEvent::class);
        return $this->getPaginator($dql, $limit, $page);
    }
352702
protected function createContentSearchPager(Query $query, $currentPage, $maxPerPage)
    {
        @trigger_error(
            'PagerfantaFindTrait is deprecated since version 2.5 and will be removed in 3.0. Use PagerfantaTrait instead.',
            E_USER_DEPRECATED
        );

        $adapter = new ContentSearchAdapter($query, $this->getSite()->getFindService());

        return $this->getPager($adapter, $currentPage, $maxPerPage);
    }
1141205
private function setPager($query, $page, $maxPerPage)
    {
        $adapter = new DoctrineORMAdapter($query);
        $pager = new PagerFanta($adapter);
        $pager
            ->setMaxPerPage($maxPerPage)
            ->setCurrentPage($page)
        ;

        // Pagerfanta returns a traversable object, not directly serializable
        $posts = [];
        foreach ($pager->getCurrentPageResults() as $post) {
            $posts[] = $post;
        }

        return [
            'total' => $pager->getNbResults(),
            'count' => count($posts),
            'posts' => $posts,
        ];
    }
1306500
public function get(
        $page = 1,
        $pageSize = 1000,
        $subscribed = null,
        $onlyGuest = false,
        $websiteId = null,
        $storeId = null
    ) {

        $this
            ->initCollection()
            ->joinWebsite()
            ->filterWebsite($websiteId)
            ->filterStore($storeId)
            ->filterSubscribed($subscribed)
            ->filterCustomers($onlyGuest)
            ->setPage($page, $pageSize);

        return $this->subscriptionsResponseFactory->create()
            ->setCurrentPage($this->subscriptionCollection->getCurPage())
            ->setLastPage($this->subscriptionCollection->getLastPageNumber())
            ->setPageSize($this->subscriptionCollection->getPageSize())
            ->setTotalCount($this->subscriptionCollection->getSize())
            ->setSubscriptions($this->handleSubscriptions());
    }
493463
public function getSignatureRequests($page = 1)
    {
        $params = array(
            'page' => $page
        );

        $response = $this->rest->get(
            static::SIGNATURE_REQUEST_LIST_PATH,
            $params
        );

        $this->checkResponse($response);

        $list = new SignatureRequestList($response);

        if ($page > $list->getNumPages()) {
            throw new Error('page_not_found', 'Page not found');
        }

        return $list;
    }
620854
public function findAllCurrent($limit = 1000, $page = 1)
    {
        try {
            $qb = $this->getValidSpecialPriceQuery();

            $adapter = new DoctrineORMAdapter($qb);
            $pagerfanta = new Pagerfanta($adapter);
            $pagerfanta->setMaxPerPage($limit);
            $pagerfanta->setCurrentPage($page);

            return $pagerfanta;
        } catch (NoResultException $exc) {
            return null;
        }
    }
86768
public function paginate($per_page = 5, $page = null, $page_name = 'imap_page'){
        $this->page = $page > $this->page ? $page : $this->page;
        $this->limit = $per_page;

        return $this->get()->paginate($per_page, $this->page, $page_name);
    }
1035010
public function transform($events, $eventsCount, $page, $maxPerPage)
    {
        $pageCount = count($events);
        $eventsCollection = new EventCollectionObjectRepresentation(
            (int) $page,
            (int) $maxPerPage,
            (int) $numberOfPages = ceil($eventsCount/$maxPerPage),
            (int) $eventsCount,
            $this->calculateLinks($page, $numberOfPages)
        );
        foreach ($events as $event) {
            $eventsCollection->addEvent(new EventObjectRepresentation($event));
        }

        $response = new Response(
            $this->serializer->serialize(
                [
                    $eventsCollection
                ], 'xml'),
            $this->getHttpStatusCode($pageCount)
        );

        $response->headers->set('Content-type', 'text/xml');
        $response->setCharset('utf-8');

        // set infinite cache if page is complete
        if ($maxPerPage === $pageCount) {
            $response
                ->setMaxAge(60 * 60 * 24 * 365)
                ->setSharedMaxAge(60 * 60 * 24 * 365);
        }

        return $response;
    }
976499
public function getByPage($page = 1, $limit = 10, $with = array())
    {
        $result = new StdClass;
        $result->page = $page;
        $result->limit = $limit;
        $result->totalItems = 0;
        $result->items = array();

        $query = $this->make($with);
        $users = $query->skip($limit * ($page - 1))
            ->take($limit)
            ->get();
        $result->totalItems = $this->model->count();
        $result->items = $users->all();

        return $result;
    }
882149
public function paginate($page = 1, $maxPerPage = 10)
    {
        $this
            ->setLimit($maxPerPage)
            ->setOffset(($page - 1) * $maxPerPage);

        $pager = $this->find();
        $pager->setPage($page);
        $pager->setMaxPerPage($maxPerPage);

        return $pager;
    }
289106
public function pageAction( $page = 1 )
    {
        $sitemap               = new DOMDocument( "1.0", "UTF-8" );
        $root                  = $sitemap->createElement( "urlset" );
        $sitemap->formatOutput = true;
        $root->setAttribute( "xmlns", "http://www.sitemaps.org/schemas/sitemap/0.9" );
        $sitemap->appendChild( $root );
        $query         = $this->getQuery();
        $query->limit  = static::PACKET_MAX;
        $query->offset = static::PACKET_MAX * ( $page - 1 );

        $searchService = $this->get( "ezpublish.api.repository" )->getSearchService();

        $results = $searchService->findLocations( $query );
        $this->fillSitemap( $sitemap, $root, $results );

        $response = new Response( $sitemap->saveXML(), 200, [ "Content-type" => "text/xml" ] );
        $response->setSharedMaxAge( 24 * 3600 );

        return $response;
    }
530748
function page($page, $limit = null, $offset = 0) {
		if ($page === null || $limit === null) {
			// retrieve all rows
			$this->num(':offset', $offset);
			$this->num(':count', PHP_INT_MAX);
		}
		else { // $page != null
			$this->num(':offset', $limit * ($page - 1) + $offset);
			$this->num(':count', $limit);
		}

		return $this;
	}