Newscoop\TemplateList\PaginatedBaseList::paginateList PHP Method

paginateList() protected method

Paginate target and fill list items
protected paginateList ( mixed $target, integer $pageNumber, integer $maxResults, ListResult $list = null, boolean $useCache = true ) : ListResult
$target mixed
$pageNumber integer
$maxResults integer
$list Newscoop\ListResult
$useCache boolean
return Newscoop\ListResult
    protected function paginateList($target, $pageNumber, $maxResults, $list = null, $useCache = true)
    {
        if (!$list) {
            $list = new ListResult();
        }
        if (!$pageNumber) {
            $pageNumber = $this->pageNumber;
        }
        $cacheId = $this->cacheService->getCacheKey(array($this->getCacheKey(), $this->getPageNumber()), $this->getName());
        if ($this->cacheService->contains($cacheId) && $useCache) {
            $this->pagination = $this->cacheService->fetch($cacheId);
        } else {
            $this->pagination = $this->paginatorService->paginate($target, $pageNumber, $maxResults);
            $this->cacheService->save($cacheId, $this->pagination);
        }
        $list->count = count($this->pagination->getItems());
        $list->items = $this->pagination->getItems();
        return $list;
    }