Return items in a paged way

@return mixed
435414
public function index()
    {
        $options = $this->getQueryHelperOptions();
        $items = $this->repo->allPaged($options);

        if ( ! $items)
        {
            return $this->respondNotFound('Unable to fetch the selected resources');
        }

        $response = [
            'data' => [],
            'meta' => [
                'pagination' => []
            ]
        ];

        $resource = new Fractal\Resource\Collection($items->getCollection(), new $this->transformerClass);
        $resource->setPaginator(new Fractal\Pagination\IlluminatePaginatorAdapter($items));

        $response['data'] = $this->fractal->createData($resource)->toArray()['data'];

        $paginator = new Fractal\Pagination\IlluminatePaginatorAdapter($items);

        $response['meta']['pagination'] = [
            'total' => $paginator->getTotal(),
            'count' => $paginator->count(),
            'per_page' => $paginator->getPerPage(),
            'current_page' => $paginator->getCurrentPage(),
            'total_pages' => $paginator->getLastPage()
        ];

        return $response;
    }
188854
public function published()
    {
        $published = [];

        foreach ($this->items as $path => $slug) {
            $page = $this->pages->get($path);
            if ($page !== null && $page->published()) {
                $published[$path] = $slug;
            }
        }
        $this->items = $published;

        return $this;
    }
870600
public function getBreadcrumbItems()
    {
        $item = $this->getBaseItem();
        $items = array();

        while ($current = $item->getCurrentChild())
        {
            $items[] = $current;

            $item = $current;
        }

        return $items;
    }
704718
private function getFromTo(): array
    {
        if ($this->count < $this->perPage || $this->perPage === null) {
            $start = 1;
            $end = $this->count;
        } else {
            if ($this->hasMorePages()) {
                $end = $this->perPage * $this->currentPage;
                $start = ($end - $this->perPage) + 1;
            } else {
                $endTest = $this->perPage * $this->currentPage;
                $start = ($endTest - $this->perPage) + 1;

                $end = $start + $this->getCountOnLastPage();
            }
        }

        return ['from' => $start, 'to' => $end];
    }
58664
protected function page()
    {
        if ($this->key() == $this->count() || !$this->isScrollable()) {
            return $this;
        }

//        $raw = $this->manager->scroll($this->scrollId, $this->scrollDuration, Result::RESULTS_RAW);
        $raw = $this->manager->getClient()->scroll(
            [
                'scroll' => $this->scrollDuration,
                'scroll_id' => $this->scrollId,
            ]
        );
        $this->rewind();
        $this->scrollId = $raw['_scroll_id'];
        $this->documents = $raw['hits']['hits'];

        return $this;
    }
726838
public function PaginatedList()
    {
        $all_posts = $this->blogPosts ?: ArrayList::create();

        $posts = PaginatedList::create($all_posts);

        $posts->setPageLength($this->PostsPerPage);

        // Set current page
        $start = $this->request->getVar($posts->getPaginationGetVar());
        $posts->setPageStart($start);

        return $posts;
    }
574187
function get()
    {
        $result = array();

        foreach ((array)$this->matches as $item) {
            if ($this->engine == 'pspell') {
                $word = $item[0];
            }
            else {
                $word = mb_substr($this->content, $item[1], $item[2], RCUBE_CHARSET);
            }

            if (is_array($item[4])) {
                $suggestions = $item[4];
            }
            else if (empty($item[4])) {
                $suggestions = array();
            }
            else {
                $suggestions = explode("\t", $item[4]);
            }

            $result[$word] = $suggestions;
        }

        return $result;
    }
212448
def fetch_items(self):
        
        offset = self.per_page * (self.page - 1)
        items = self._query.limit(self.per_page).offset(offset).all()
        return items
933155
public function indexPage()
    {
        $pageIndexed = false;
        $documents = []; // this will become useful as soon as when starting to index individual records instead of whole pages

        if (is_null($this->solrConnection)) {
            // intended early return as it doesn't make sense to continue
            // and waste processing time if the solr server isn't available
            // anyways
            // FIXME use an exception
            return $pageIndexed;
        }

        $pageDocument = $this->getPageDocument();
        $pageDocument = $this->substitutePageDocument($pageDocument);

        $this->applyIndexPagePostProcessors($pageDocument);

        self::$pageSolrDocument = $pageDocument;
        $documents[] = $pageDocument;
        $documents = $this->getAdditionalDocuments($pageDocument, $documents);
        $this->processDocuments($documents);

        $pageIndexed = $this->addDocumentsToSolrIndex($documents);
        $this->documentsSentToSolr = $documents;

        return $pageIndexed;
    }
1289871
public function generateItems()
    {
        // Iterator for pagination pages.
        $j = 1;

        foreach ($this->getLinks() as $index => $link) {
            // Create new pagination item
            $item = new PaginationItem($link);

            // If we on first link and currently active page is not first,
            // we know that this link is for previous pagination item.
            if ($index === 0 && $this->currentPage != 1) {
                $this->markAsPrevious($item);

                continue;
            }

            // If we on last link and currently active page is not last,
            // we know that this link is for next pagination item.
            if (
                $index === $this->getLinksCount(true)
                && $this->currentPage != $this->getLinksCount(true)
            ) {
                $this->markAsNext($item);

                break;
            }

            // We can't use loop index, because sometimes first and
            // last link are for the next and previous item, so use
            // external iterator to index pages of pagination.
            $item->number = $j++;

            // Push pagination pages to items collection.
            $this->items[] = $item;
        }
    }
1295833
public function getValuesByPage(): array
    {
        $result = array();

        foreach ($this->_definition as $key => $value) {
            $page = $this->getFieldProperty($key, 'page');

            if ($page) {
                $result[$page][$key] = $this->$key;
            }
        }

        return $result;
    }
716061
public function prepare_items() {

		// Define Columns
		$columns = $this->get_columns();
		$hidden = [];
		$sortable = $this->get_sortable_columns();
		$this->_column_headers = [ $columns, $hidden, $sortable ];

		// Data
		$data = $this->getLatestExports();

		// Pagination
		$per_page = $this->get_items_per_page( 'pb_export_per_page', 50 );
		$current_page = $this->get_pagenum();
		$total_items = count( $data );
		$orderby = ( ! empty( $_REQUEST['orderby'] ) ) ? $_REQUEST['orderby'] : 'exported';
		$order = ( ! empty( $_REQUEST['order'] ) ) ? $_REQUEST['order'] : 'desc';

		// Data slice
		$sort = ( $orderby === 'exported' ) ? [ $orderby => $order ] : [
			$orderby => $order,
			'exported' => 'desc',
		];
		$data = wp_list_sort( $data, $sort );
		$data = array_slice( $data, ( ( $current_page - 1 ) * $per_page ), $per_page );
		$this->items = $data;

		$this->set_pagination_args(
			[
				'total_items' => $total_items,
				'per_page' => $per_page,
				'total_pages' => ceil( $total_items / $per_page ),
			]
		);
	}
948061
protected function getPageArray()
    {
        $range = \range($this->firstPage, $this->lastPage);
        $pageArray = [];

        foreach ($range as $page) {
            $pageArray[] = [
                'page' => $page,
                'label' => $page,
                'type' => 'page'
            ];
        }

        return $pageArray;
    }
1093855
public static function findAll($page_request = null)
    {
        if($page_request != null){
            return self::listAllReturnLineItems(['page' => $page_request->getPageNumber(), 'size' => $page_request->getSize() ]);
        }else {
            return self::listAllReturnLineItems();
        }
    }
130974
public function getPagination()
    {
        $limit = $this->userManager->getUsersLimit();
        $count = $this->countVisibleUsers();
        $pages = $count / $limit;
        $remainder = $count % $limit;
        if ($remainder === 0) {
            return $pages;
        } else {
            return floor($pages) + 1;
        }
    }
154752
protected function pager()
    {
        if ($this->pager === null) {
            $this->pager = $this->createPagination();
        }

        return $this->pager;
    }
837904
public function get_items() {
        if (!isset($this->data[Parser::INDEX_CHILDREN_SPEC])) {
            return array();
        }

        $items = array();
        foreach ($this->data[Parser::INDEX_CHILDREN_SPEC] as $k => $data) {
            $items[] = $this->api->get_item($data['value']);
        }
        
        return $items;
    }