0 follower

Final Class Yiisoft\Yii\DataView\Pagination\PaginationContext

InheritanceYiisoft\Yii\DataView\Pagination\PaginationContext

Context class for pagination widgets that provides URL generation and configuration.

Constants

Hide inherited constants

Constant Value Description Defined By
URL_PLACEHOLDER 'YII-DATAVIEW-PAGE-PLACEHOLDER' Placeholder used in URL patterns that will be replaced with the actual page token. Yiisoft\Yii\DataView\Pagination\PaginationContext

Property Details

Hide inherited properties

$firstPageUrl public property
public string $firstPageUrl null
$nextUrlPattern public property
public string $nextUrlPattern null
$previousUrlPattern public property

Method Details

Hide inherited methods

__construct() public method

public __construct( string $nextUrlPattern, string $previousUrlPattern, string $firstPageUrl ): mixed
$nextUrlPattern string

URL pattern for next page links. Must contain \Yiisoft\Yii\DataView\Pagination\URL_PLACEHOLDER.

$previousUrlPattern string

URL pattern for previous page links. Must contain \Yiisoft\Yii\DataView\Pagination\URL_PLACEHOLDER.

$firstPageUrl string

URL used on the first page.

                public function __construct(
    public readonly string $nextUrlPattern,
    public readonly string $previousUrlPattern,
    public readonly string $firstPageUrl,
) {}

            
createUrl() public method

Creates a URL for the given page token.

This method replaces the URL_PLACEHOLDER in either the next or previous URL pattern (depending on the token type) with the URL-encoded token value.

public createUrl( \Yiisoft\Data\Paginator\PageToken $pageToken ): string
$pageToken \Yiisoft\Data\Paginator\PageToken

Token for the page.

return string

The generated URL with the token value properly encoded.

                public function createUrl(PageToken $pageToken): string
{
    return str_replace(
        self::URL_PLACEHOLDER,
        urlencode($pageToken->value),
        $pageToken->isPrevious ? $this->previousUrlPattern : $this->nextUrlPattern,
    );
}