1 | <?php |
||
22 | class QueryBuilderProvider implements Provider |
||
23 | { |
||
24 | /** |
||
25 | * @var QueryBuilder The original query, as passed to us. |
||
26 | */ |
||
27 | private $originalQuery; |
||
28 | |||
29 | /** |
||
30 | * @var QueryBuilder The query, before limits are applied |
||
31 | */ |
||
32 | private $queryBeforeLimits; |
||
33 | |||
34 | /** |
||
35 | * @var QueryBuilder The underlying query |
||
36 | */ |
||
37 | private $query; |
||
38 | |||
39 | /** |
||
40 | * @var QueryConfiguration |
||
41 | */ |
||
42 | private $queryConfiguration; |
||
43 | |||
44 | /** |
||
45 | * @var callable the default global function to check if a row should be included |
||
46 | */ |
||
47 | private $defaultGlobalSearchFunction; |
||
|
|||
48 | |||
49 | /** |
||
50 | * @var callable the default global order function |
||
51 | */ |
||
52 | private $defaultGlobalOrderFunction; |
||
53 | |||
54 | /** |
||
55 | * @var array an array of callables with local search functions to check if the row should be included |
||
56 | */ |
||
57 | private $columnSearchFunction = []; |
||
58 | |||
59 | /** |
||
60 | * @var array an array that will hold the search functions for each column |
||
61 | */ |
||
62 | private $columnConfiguration = []; |
||
63 | |||
64 | /** |
||
65 | * CollectionProvider constructor. |
||
66 | * @param QueryBuilder $query The query to base the built query on |
||
67 | */ |
||
68 | public function __construct(QueryBuilder $query) |
||
73 | |||
74 | /** |
||
75 | * Here the DTQueryConfiguration is passed to prepare the provider for the processing of the request. |
||
76 | * This will only be called when the DTProvider needs to handle the request. |
||
77 | * It will never be called when the DTProvider does not need to handle the request. |
||
78 | * |
||
79 | * @param QueryConfiguration $queryConfiguration |
||
80 | * @param ColumnConfiguration[] $columnConfiguration |
||
81 | * @return mixed |
||
82 | */ |
||
83 | public function prepareForProcessing(QueryConfiguration $queryConfiguration, array $columnConfiguration) |
||
88 | |||
89 | /** |
||
90 | * This method should process all configurations and prepare the underlying data for the view. It will arrange the |
||
91 | * data and provide the results in a DTData object. |
||
92 | * It will be called after {@link #prepareForProcessing} has been called and needs to return the processed data in |
||
93 | * a DTData object so the Composer can further handle the data. |
||
94 | * |
||
95 | * @return ResponseData The processed data |
||
96 | * |
||
97 | */ |
||
98 | public function process() |
||
132 | |||
133 | /** |
||
134 | * Will compile the collection into the final collection where operations like search and order can be applied. |
||
135 | * |
||
136 | * @param QueryBuilder $query |
||
137 | * @param ColumnConfiguration[] $columnConfiguration |
||
138 | * @return QueryBuilder |
||
139 | * @throws DatatableException |
||
140 | */ |
||
141 | private function compileQuery(array $columnConfiguration) |
||
149 | |||
150 | /** |
||
151 | * When a global (single) search has been done against data in the datatable. |
||
152 | * |
||
153 | * @param array $columnConfiguration |
||
154 | * @return QueryBuilder |
||
155 | * @throws DatatableException |
||
156 | */ |
||
157 | private function compileGlobalQuery(array $columnConfiguration) |
||
163 | |||
164 | /** |
||
165 | * When a global query is being performed (ie, a query against a single column) |
||
166 | * |
||
167 | * @param ColumnConfiguration[] $columnConfiguration |
||
168 | * @return QueryBuilder |
||
169 | * @throws DatatableException |
||
170 | */ |
||
171 | private function compileColumnQuery(array $columnConfiguration) |
||
184 | |||
185 | /** |
||
186 | * Create the query w/ QueryBuilder |
||
187 | * @param ColumnConfiguration $column |
||
188 | * @param $searchValue |
||
189 | * @return QueryBuilder |
||
190 | * @throws DatatableException |
||
191 | */ |
||
192 | private function createQueryForColumn(ColumnConfiguration $column, $searchValue) |
||
209 | |||
210 | /** |
||
211 | * @param ColumnConfiguration[] $columnConfiguration |
||
212 | * @param string $name |
||
213 | * @return ColumnConfiguration |
||
214 | */ |
||
215 | private function getColumnFromName($columnConfiguration, $name) |
||
222 | |||
223 | /** |
||
224 | * When a global query is being performed (ie, a query against |
||
225 | */ |
||
226 | private function compileColumnNames() |
||
235 | |||
236 | /** |
||
237 | * Will sort the query based on the given datatable query configuration. |
||
238 | */ |
||
239 | private function sortQuery() |
||
249 | |||
250 | /** |
||
251 | * Will limit a query hased on the start and length given |
||
252 | */ |
||
253 | private function limitQuery() |
||
258 | } |
This check marks private properties in classes that are never used. Those properties can be removed.