1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @copyright Copyright (c) 2018 Robin Appelman <[email protected]> |
4
|
|
|
* |
5
|
|
|
* @license GNU AGPL version 3 or any later version |
6
|
|
|
* |
7
|
|
|
* This program is free software: you can redistribute it and/or modify |
8
|
|
|
* it under the terms of the GNU Affero General Public License as |
9
|
|
|
* published by the Free Software Foundation, either version 3 of the |
10
|
|
|
* License, or (at your option) any later version. |
11
|
|
|
* |
12
|
|
|
* This program is distributed in the hope that it will be useful, |
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15
|
|
|
* GNU Affero General Public License for more details. |
16
|
|
|
* |
17
|
|
|
* You should have received a copy of the GNU Affero General Public License |
18
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
19
|
|
|
* |
20
|
|
|
*/ |
21
|
|
|
|
22
|
|
|
namespace SearchDAV\Query; |
23
|
|
|
|
24
|
|
|
|
25
|
|
|
use SearchDAV\Backend\SearchPropertyDefinition; |
26
|
|
|
|
27
|
|
|
class Query { |
28
|
|
|
/** |
29
|
|
|
* @var SearchPropertyDefinition[] |
30
|
|
|
* |
31
|
|
|
* The list of properties to be selected |
32
|
|
|
*/ |
33
|
|
|
public $select; |
34
|
|
|
/** |
35
|
|
|
* @var Scope[] |
36
|
|
|
* |
37
|
|
|
* The collections to perform the search in |
38
|
|
|
*/ |
39
|
|
|
public $from; |
40
|
|
|
/** |
41
|
|
|
* @var Operator |
42
|
|
|
* |
43
|
|
|
* The search operator, either a comparison ('gt', 'eq', ...) or a boolean operator ('and', 'or', 'not') |
44
|
|
|
*/ |
45
|
|
|
public $where; |
46
|
|
|
/** |
47
|
|
|
* @var Order[] |
48
|
|
|
* |
49
|
|
|
* The list of order operations that should be used to order the results. |
50
|
|
|
* |
51
|
|
|
* Each order operations consists of a property to sort on and a sort direction. |
52
|
|
|
* If more then one order operations are specified, the comparisons for ordering should |
53
|
|
|
* be applied in the order that the order operations are defined in with the earlier comparisons being |
54
|
|
|
* more significant. |
55
|
|
|
*/ |
56
|
|
|
public $orderBy; |
57
|
|
|
/** |
58
|
|
|
* @var Limit |
59
|
|
|
* |
60
|
|
|
* The limit and offset for the search query |
61
|
|
|
*/ |
62
|
|
|
public $limit; |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Query constructor. |
66
|
|
|
* @param SearchPropertyDefinition[] $select |
67
|
|
|
* @param Scope[] $from |
68
|
|
|
* @param Operator $where |
69
|
|
|
* @param Order[] $orderBy |
70
|
|
|
* @param Limit $limit |
71
|
|
|
*/ |
72
|
|
|
public function __construct(array $select, array $from, Operator $where, array $orderBy, Limit $limit) { |
73
|
|
|
$this->select = $select; |
74
|
|
|
$this->from = $from; |
75
|
|
|
$this->where = $where; |
76
|
|
|
$this->orderBy = $orderBy; |
77
|
|
|
$this->limit = $limit; |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|