Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
paginator.php
1
<?php
2
3
namespace
Bitrix\Socialnetwork\Internals\LiveFeed\Counter\Collector
;
4
5
use Traversable;
6
7
class
Paginator
implements
\IteratorAggregate
8
{
9
private
int
$limit;
10
private
int
$pages;
11
private
array $offsets = [];
12
13
public
function
__construct
(
int
$total,
int
$limit)
14
{
15
$this->limit = $limit;
16
$this->pages = ceil($total / $limit);
17
$this->paginate();
18
}
19
23
public
function
getIterator
(): Traversable
24
{
25
return
new \ArrayIterator($this->offsets);
26
}
27
28
private
function
paginate(): void
29
{
30
for
($page = 1; $page <= $this->pages; $page++)
31
{
32
$this->offsets[] = ($page - 1) * $this->limit;
33
}
34
}
35
}
Bitrix\Socialnetwork\Internals\LiveFeed\Counter\Collector\Paginator
Definition
paginator.php:8
Bitrix\Socialnetwork\Internals\LiveFeed\Counter\Collector\Paginator\__construct
__construct(int $total, int $limit)
Definition
paginator.php:13
Bitrix\Socialnetwork\Internals\LiveFeed\Counter\Collector\Paginator\getIterator
getIterator()
Definition
paginator.php:23
Bitrix\Socialnetwork\Internals\LiveFeed\Counter\Collector
Definition
paginator.php:3
modules
socialnetwork
lib
internals
livefeed
counter
collector
paginator.php
Создано системой
1.10.0