Final Class Yiisoft\Yii\DataView\Pagination\OffsetPagination
| Inheritance | Yiisoft\Yii\DataView\Pagination\OffsetPagination » Yiisoft\Widget\Widget |
|---|---|
| Implements | Yiisoft\Yii\DataView\Pagination\PaginationWidgetInterface |
| Uses Traits | Yiisoft\Yii\DataView\Pagination\PaginationContextTrait |
Widget for rendering OffsetPaginator.
Public Methods
Protected Methods
| Method | Description | Defined By |
|---|---|---|
| getContext() | Gets the current pagination context. | Yiisoft\Yii\DataView\Pagination\PaginationContextTrait |
Method Details
| public addLinkAttributes( array $attributes ): self | ||
| $attributes | array | |
public function addLinkAttributes(array $attributes): self
{
$new = clone $this;
$new->linkAttributes = array_merge($new->linkAttributes, $attributes);
return $new;
}
Adds one or more CSS classes to the existing link classes.
Multiple classes can be added by passing them as separate arguments. null values are filtered out
automatically.
| public addLinkClass( \BackedEnum|string|null $class ): self | ||
| $class | \BackedEnum|string|null |
One or more CSS class names to add. Pass |
| return | self |
A new instance with the specified CSS classes added to existing ones. |
|---|---|---|
public function addLinkClass(BackedEnum|string|null ...$class): self
{
$new = clone $this;
Html::addCssClass($new->linkAttributes, $class);
return $new;
}
| public containerAttributes( array $attributes ): self | ||
| $attributes | array | |
public function containerAttributes(array $attributes): self
{
$new = clone $this;
$new->containerAttributes = $attributes;
return $new;
}
| public containerTag( string|null $tag ): self | ||
| $tag | string|null | |
public function containerTag(?string $tag): self
{
if ($tag === '') {
throw new InvalidArgumentException('Tag name cannot be empty.');
}
$new = clone $this;
$new->containerTag = $tag;
return $new;
}
Defined in: Yiisoft\Yii\DataView\Pagination\PaginationContextTrait::context()
Creates a new instance with the specified pagination context.
| public context( Yiisoft\Yii\DataView\Pagination\PaginationContext $context ): Yiisoft\Yii\DataView\Pagination\OffsetPagination | ||
| $context | Yiisoft\Yii\DataView\Pagination\PaginationContext |
The pagination context to use. |
| return | Yiisoft\Yii\DataView\Pagination\OffsetPagination |
New instance with the specified context. |
|---|---|---|
final public function context(PaginationContext $context): static
{
$new = clone $this;
$new->context = $context;
return $new;
}
Creates a new instance with the specified paginator and context.
| public static create( \Yiisoft\Data\Paginator\OffsetPaginator $paginator, string $urlPattern, string $firstPageUrl ): self | ||
| $paginator | \Yiisoft\Data\Paginator\OffsetPaginator |
The paginator to use. |
| $urlPattern | string |
URL pattern for page links. Must contain Yiisoft\Yii\DataView\Pagination\PaginationContext::URL_PLACEHOLDER. |
| $firstPageUrl | string |
URL used on the first page. |
| return | self |
New instance with the specified paginator and context. |
|---|---|---|
public static function create(OffsetPaginator $paginator, string $urlPattern, string $firstPageUrl): self
{
return self::widget()
->paginator($paginator)
->context(
new PaginationContext($urlPattern, $urlPattern, $firstPageUrl),
);
}
| public currentItemClass( string|null $class ): self | ||
| $class | string|null | |
public function currentItemClass(?string $class): self
{
$new = clone $this;
$new->currentItemClass = $class;
return $new;
}
| public currentLinkClass( string|null $class ): self | ||
| $class | string|null | |
public function currentLinkClass(?string $class): self
{
$new = clone $this;
$new->currentLinkClass = $class;
return $new;
}
| public disabledItemClass( string|null $class ): self | ||
| $class | string|null | |
public function disabledItemClass(?string $class): self
{
$new = clone $this;
$new->disabledItemClass = $class;
return $new;
}
| public disabledLinkClass( string|null $class ): self | ||
| $class | string|null | |
public function disabledLinkClass(?string $class): self
{
$new = clone $this;
$new->disabledLinkClass = $class;
return $new;
}
Defined in: Yiisoft\Yii\DataView\Pagination\PaginationContextTrait::getContext()
Gets the current pagination context.
| protected getContext( ): Yiisoft\Yii\DataView\Pagination\PaginationContext | ||
| return | Yiisoft\Yii\DataView\Pagination\PaginationContext |
The current pagination context. |
|---|---|---|
| throws | LogicException |
If the context has not been set. |
final protected function getContext(): PaginationContext
{
if ($this->context === null) {
throw new LogicException('Context is not set.');
}
return $this->context;
}
| public itemAttributes( array $attributes ): self | ||
| $attributes | array | |
public function itemAttributes(array $attributes): self
{
$new = clone $this;
$new->itemAttributes = $attributes;
return $new;
}
| public itemTag( string|null $tag ): self | ||
| $tag | string|null | |
public function itemTag(?string $tag): self
{
if ($tag === '') {
throw new InvalidArgumentException('Tag name cannot be empty.');
}
$new = clone $this;
$new->itemTag = $tag;
return $new;
}
| public labelFirst( string|\Stringable|null $label ): self | ||
| $label | string|\Stringable|null | |
public function labelFirst(string|Stringable|null $label): self
{
$new = clone $this;
$new->labelFirst = $label;
return $new;
}
| public labelLast( string|\Stringable|null $label ): self | ||
| $label | string|\Stringable|null | |
public function labelLast(string|Stringable|null $label): self
{
$new = clone $this;
$new->labelLast = $label;
return $new;
}
| public labelNext( string|\Stringable|null $label ): self | ||
| $label | string|\Stringable|null | |
public function labelNext(string|Stringable|null $label): self
{
$new = clone $this;
$new->labelNext = $label;
return $new;
}
| public labelPrevious( string|\Stringable|null $label ): self | ||
| $label | string|\Stringable|null | |
public function labelPrevious(string|Stringable|null $label): self
{
$new = clone $this;
$new->labelPrevious = $label;
return $new;
}
| public linkAttributes( array $attributes ): self | ||
| $attributes | array | |
public function linkAttributes(array $attributes): self
{
$new = clone $this;
$new->linkAttributes = $attributes;
return $new;
}
Set new link classes.
Multiple classes can be set by passing them as separate arguments. null values are filtered out
automatically.
| public linkClass( \BackedEnum|string|null $class ): self | ||
| $class | \BackedEnum|string|null |
One or more CSS class names to use. Pass |
public function linkClass(BackedEnum|string|null ...$class): self
{
$new = clone $this;
$new->linkAttributes['class'] = [];
Html::addCssClass($new->linkAttributes, $class);
return $new;
}
| public listAttributes( array $attributes ): self | ||
| $attributes | array | |
public function listAttributes(array $attributes): self
{
$new = clone $this;
$new->listAttributes = $attributes;
return $new;
}
| public listTag( string|null $tag ): self | ||
| $tag | string|null | |
public function listTag(?string $tag): self
{
if ($tag === '') {
throw new InvalidArgumentException('Tag name cannot be empty.');
}
$new = clone $this;
$new->listTag = $tag;
return $new;
}
Creates a new instance with the specified paginator.
| public paginator( \Yiisoft\Data\Paginator\PaginatorInterface $paginator ): Yiisoft\Yii\DataView\Pagination\OffsetPagination | ||
| $paginator | \Yiisoft\Data\Paginator\PaginatorInterface |
The paginator to use. |
| return | Yiisoft\Yii\DataView\Pagination\OffsetPagination |
New instance with the specified paginator. |
|---|---|---|
| throws | Yiisoft\Yii\DataView\Pagination\PaginatorNotSupportedException |
If paginator is not a \Yiisoft\Data\Paginator\OffsetPaginator. |
public function paginator(PaginatorInterface $paginator): static
{
/** @psalm-suppress DocblockTypeContradiction, NoValue */
if (!$paginator instanceof OffsetPaginator) {
throw new PaginatorNotSupportedException($paginator);
}
$new = clone $this;
$new->paginator = $paginator;
return $new;
}
| public render( ): string |
public function render(): string
{
if (!$this->showOnSinglePage && !$this->getPaginator()->isPaginationRequired()) {
return '';
}
$result = '';
if ($this->containerTag !== null) {
$result .= Html::openTag($this->containerTag, $this->containerAttributes) . "\n";
}
if ($this->listTag !== null) {
$result .= Html::openTag($this->listTag, $this->listAttributes) . "\n";
}
$items = $this->renderItems();
$result .= implode("\n", $items);
if ($this->listTag !== null) {
$result .= "\n" . Html::closeTag($this->listTag);
}
if ($this->containerTag !== null) {
$result .= "\n" . Html::closeTag($this->containerTag);
}
return $result;
}
| public showOnSinglePage( boolean $show = true ): self | ||
| $show | boolean | |
public function showOnSinglePage(bool $show = true): self
{
$new = clone $this;
$new->showOnSinglePage = $show;
return $new;
}
Signup or Login in order to comment.