src/mako/pagination/Pagination.php
public function pagination(): array
	{
		if(empty($this->pagination))
		{
			if(empty($this->request))
			{
				throw new RuntimeException('A [ Request ] instance is required to generate the pagination array.');
			}

			if(empty($this->urlBuilder))
			{
				throw new RuntimeException('A [ URLBuilder ] instance is required to generate the pagination array.');
			}

			$pagination = $this->toArray();

			if($this->options['max_page_links'] !== 0)
			{
				if($this->pages > $this->options['max_page_links'])
				{
					$start = (int) max(($this->currentPage) - ceil($this->options['max_page_links'] / 2), 0);

					$end = $start + $this->options['max_page_links'];

					if($end > $this->pages)
					{
						$end = $this->pages;
					}

					if($start > ($end - $this->options['max_page_links']))
					{
						$start = $end - $this->options['max_page_links'];
					}
				}
				else
				{
					$start = 0;

					$end = $this->pages;
				}

				$pagination['pages'] = [];

				for($i = $start + 1; $i <= $end; $i++)
				{
					$pagination['pages'][] =
					[
						'url'        => $this->buildPageUrl($i),
						'number'     => $i,
						'is_current' => $i === $this->currentPage,
					];
				}
			}

			$this->pagination = $pagination;
		}

		return $this->pagination;
	}
public function pagination(): array
	{
		if(empty($this->pagination))
		{
			if(empty($this->request))
			{
				throw new RuntimeException('A [ Request ] instance is required to generate the pagination array.');
			}

			if(empty($this->urlBuilder))
			{
				throw new RuntimeException('A [ URLBuilder ] instance is required to generate the pagination array.');
			}

			$pagination = $this->toArray();

			if($this->options['max_page_links'] !== 0)
			{
				if($this->pages > $this->options['max_page_links'])
				{
					$start = (int) max(($this->currentPage) - ceil($this->options['max_page_links'] / 2), 0);

					$end = $start + $this->options['max_page_links'];

					if($end > $this->pages)
					{
						$end = $this->pages;
					}

					if($start > ($end - $this->options['max_page_links']))
					{
						$start = $end - $this->options['max_page_links'];
					}
				}
				else
				{
					$start = 0;

					$end = $this->pages;
				}

				$pagination['pages'] = [];

				for($i = $start + 1; $i <= $end; $i++)
				{
					$pagination['pages'][] =
					[
						'url'        => $this->buildPageUrl($i),
						'number'     => $i,
						'is_current' => $i === $this->currentPage,
					];
				}
			}

			$this->pagination = $pagination;
		}

		return $this->pagination;
	}
public function pagination ( ) : array { if ( empty ( $ this -> pagination ) ) { if ( empty ( $ this -> request ) ) { throw new RuntimeException ( 'A [ Request ] instance is required to generate the pagination array.' ) ; } if ( empty ( $ this -> urlBuilder ) ) { throw new RuntimeException ( 'A [ URLBuilder ] instance is required to generate the pagination array.' ) ; } $ pagination = $ this -> toArray ( ) ; if ( $ this -> options [ 'max_page_links' ] !== 0 ) { if ( $ this -> pages > $ this -> options [ 'max_page_links' ] ) { $ start = ( int ) max ( ( $ this -> currentPage ) - ceil ( $ this -> options [ 'max_page_links' ] / 2 ) , 0 ) ; $ end = $ start + $ this -> options [ 'max_page_links' ] ; if ( $ end > $ this -> pages ) { $ end = $ this -> pages ; } if ( $ start > ( $ end - $ this -> options [ 'max_page_links' ] ) ) { $ start = $ end - $ this -> options [ 'max_page_links' ] ; } } else { $ start = 0 ; $ end = $ this -> pages ; } $ pagination [ 'pages' ] = [ ] ; for ( $ i = $ start + 1 ; $ i <= $ end ; $ i ++ ) { $ pagination [ 'pages' ] [ ] = [ 'url' => $ this -> buildPageUrl ( $ i ) , 'number' => $ i , 'is_current' => $ i === $ this -> currentPage , ] ; } } $ this -> pagination = $ pagination ; } return $ this -> pagination ; }
Builds and returns the pagination array.

@throws \RuntimeException
@return array
Builds and returns the pagination array .