1 | <?php |
||
16 | class ConfiguredQuery |
||
17 | { |
||
18 | /** |
||
19 | * @var QueryBuilder |
||
20 | */ |
||
21 | private $queryBuilder; |
||
22 | |||
23 | /** |
||
24 | * @var array|OrderingConfiguration[] associative, keys are strings for ordering fields |
||
25 | */ |
||
26 | private $orderingConfigurations; |
||
27 | |||
28 | /** |
||
29 | * @var bool |
||
30 | */ |
||
31 | private $totalCountNeeded; |
||
32 | |||
33 | /** |
||
34 | * @var int|null |
||
35 | */ |
||
36 | private $maximumOffset; |
||
37 | |||
38 | /** |
||
39 | * @var callable |
||
40 | */ |
||
41 | private $itemTransformer; |
||
42 | |||
43 | 46 | public function __construct(QueryBuilder $queryBuilder) |
|
49 | |||
50 | 32 | public function addOrderingConfiguration(string $orderBy, OrderingConfiguration $configuration): self |
|
60 | |||
61 | /** |
||
62 | * @param array|OrderingConfiguration[] $orderingConfigurations array of `orderBy => OrderingConfiguration` pairs |
||
63 | * @return ConfiguredQuery |
||
64 | */ |
||
65 | 28 | public function addOrderingConfigurations(array $orderingConfigurations): self |
|
73 | |||
74 | 31 | public function getOrderingConfigurationFor(string $orderBy): OrderingConfiguration |
|
82 | |||
83 | /** |
||
84 | * @return QueryBuilder |
||
85 | */ |
||
86 | 46 | public function getQueryBuilder(): QueryBuilder |
|
90 | |||
91 | /** |
||
92 | * @return bool |
||
93 | */ |
||
94 | 34 | public function isTotalCountNeeded(): bool |
|
98 | |||
99 | /** |
||
100 | * @param bool $totalCountNeeded |
||
101 | * @return $this |
||
102 | */ |
||
103 | 23 | public function setTotalCountNeeded(bool $totalCountNeeded): self |
|
108 | |||
109 | /** |
||
110 | * @param int $maximumOffset |
||
111 | * @return $this |
||
112 | */ |
||
113 | 1 | public function setMaximumOffset(int $maximumOffset): self |
|
118 | |||
119 | 6 | public function hasMaximumOffset(): bool |
|
123 | |||
124 | /** |
||
125 | * @return int |
||
126 | * @throws RuntimeException if maximum offset was not set. Check with hasMaximumOffset beforehand |
||
127 | */ |
||
128 | 1 | public function getMaximumOffset(): int |
|
136 | |||
137 | /** |
||
138 | * @return callable|null |
||
139 | */ |
||
140 | 34 | public function getItemTransformer() |
|
144 | |||
145 | public function setItemTransformer(callable $itemTransformer): self |
||
151 | } |
||
152 |