Final Class Yiisoft\Yii\DataView\Pagination\PaginationContext
| Inheritance | Yiisoft\Yii\DataView\Pagination\PaginationContext |
|---|
Context class for pagination widgets that provides URL generation and configuration.
Public Properties
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\Yii\DataView\Pagination\PaginationContext | |
| createUrl() | Creates a URL for the given page token. | Yiisoft\Yii\DataView\Pagination\PaginationContext |
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
Method Details
| 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,
) {}
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,
);
}
Signup or Login in order to comment.