Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/main/lib/Provider/Params/ |
Upload File : |
<?php declare(strict_types=1); namespace Bitrix\Main\Provider\Params; use Bitrix\Main\ArgumentException; use Bitrix\Main\UI\PageNavigation; /** * Page params for providers GridParams */ class Pager implements PagerInterface { /** * @throws ArgumentException */ public function __construct(protected int $limit = 50, protected int $offset = 0) { $this ->setLimit($this->limit) ->setOffset($this->offset) ; } /** * @throws ArgumentException */ public static function buildFromPageNavigation(PageNavigation $pageNavigation): static { return new static($pageNavigation->getOffset() ?: 0, $pageNavigation->getLimit() ?: 50); } public function getLimit(): int { return $this->limit; } /** * {@inheritDoc} */ public function setLimit(int $limit): static { if ($limit < 1) { throw new ArgumentException('The limit should be a positive number'); } $this->limit = $limit; return $this; } public function getOffset(): int { return $this->offset; } /** * {@inheritDoc} */ public function setOffset(int $offset): static { if ($offset < 0) { throw new ArgumentException('The offset should be a not negative number'); } $this->offset = $offset; return $this; } /** * {@inheritDoc} */ public function setPage(int $page): static { if ($page < 1) { throw new ArgumentException('The page should be a positive number'); } $this->offset = ($page - 1) * $this->limit; return $this; } /** * {@inheritDoc} */ public function setSize(int $size): PagerInterface { return $this->setLimit($size); } }