blob: 5adb86ba20ae0ad38ddf26066338b3801cc25db7 (
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
|
<?php
// Icinga Web 2 X.509 Module | (c) 2018 Icinga GmbH | GPLv2
namespace Icinga\Module\X509;
use Icinga\Data\Sortable;
use ipl\Sql;
/**
* @internal
*/
class SortAdapter implements Sortable
{
protected $select;
protected $callback;
public function __construct(Sql\Select $select, \Closure $callback = null)
{
$this->select = $select;
$this->callback = $callback;
}
public function order($field, $direction = null)
{
if ($this->callback !== null) {
$field = call_user_func($this->callback, $field) ?: $field;
}
if ($direction === null) {
$this->select->orderBy($field);
} else {
$this->select->orderBy($field, $direction);
}
}
public function hasOrder()
{
return $this->select->hasOrderBy();
}
public function getOrder()
{
return $this->select->getOrderBy();
}
}
|