blob: d6a1b97315673aeb1fd12a8721da0cdfa4032340 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
<?php
namespace gipfl\IcingaWeb2\Data;
use Icinga\Application\Benchmark;
use Icinga\Data\SimpleQuery;
class SimpleQueryPaginationAdapter implements Paginatable
{
/** @var SimpleQuery */
private $query;
public function __construct(SimpleQuery $query)
{
$this->query = $query;
}
#[\ReturnTypeWillChange]
public function count()
{
Benchmark::measure('Running count() for pagination');
$count = $this->query->count();
Benchmark::measure("Counted $count rows");
return $count;
}
public function limit($count = null, $offset = null)
{
$this->query->limit($count, $offset);
}
public function hasLimit()
{
return $this->getLimit() !== null;
}
public function getLimit()
{
return $this->query->getLimit();
}
public function setLimit($limit)
{
$this->query->limit(
$limit,
$this->getOffset()
);
}
public function hasOffset()
{
return $this->getOffset() !== null;
}
public function getOffset()
{
return $this->query->getOffset();
}
public function setOffset($offset)
{
$this->query->limit(
$this->getLimit(),
$offset
);
}
}
|