1 | <?php |
||
18 | class DoctrineDBAL extends AbstractAdapter implements EntityManagerAwareInterface, PaginatorAdapterInterface |
||
19 | { |
||
20 | use PaginatorAdapterTrait; |
||
21 | |||
22 | /** |
||
23 | * Запрос данных |
||
24 | * @var QueryBuilder |
||
25 | */ |
||
26 | protected $query; |
||
27 | |||
28 | /** |
||
29 | * Запрос на подсчет данных |
||
30 | * @var QueryBuilder |
||
31 | */ |
||
32 | protected $countQuery; |
||
33 | |||
34 | /** |
||
35 | * Параметры сортировки |
||
36 | * @var array |
||
37 | */ |
||
38 | protected $order; |
||
39 | |||
40 | /** |
||
41 | * @var int |
||
42 | */ |
||
43 | protected $limit = 25; |
||
44 | |||
45 | /** |
||
46 | * @var int |
||
47 | */ |
||
48 | protected $offset = 0; |
||
49 | |||
50 | /** |
||
51 | * Alias корневой сущности |
||
52 | * @var string |
||
53 | */ |
||
54 | protected $rootAlias; |
||
55 | |||
56 | /** |
||
57 | * @var EntityManagerInterface |
||
58 | */ |
||
59 | protected $entityManager; |
||
60 | |||
61 | /** |
||
62 | * Проверяет корректность запроса |
||
63 | * @throws Exception\RuntimeException |
||
64 | */ |
||
65 | protected function validateQuery() |
||
75 | |||
76 | /** |
||
77 | * Возвращает данные для грида |
||
78 | * @return array |
||
79 | * @throws Exception\RuntimeException |
||
80 | */ |
||
81 | public function getData() |
||
105 | |||
106 | /** |
||
107 | * @param QueryBuilder $query |
||
108 | * @return QueryBuilder |
||
109 | */ |
||
110 | protected function prepareConditions($query) |
||
111 | { |
||
112 | $i = 0; |
||
113 | if (count($this->getConditions()) !== 0) { |
||
114 | foreach ($this->getConditions() as $condition) { |
||
115 | $conditionKey = 'NNXGridCondition_' . $i; |
||
116 | $query->andWhere($condition->getKey() . ' ' . $condition->getCriteria() . ' :' . $conditionKey); |
||
117 | $query->setParameter($conditionKey, $condition->getValue()); |
||
118 | $i++; |
||
119 | } |
||
120 | } |
||
121 | |||
122 | return $query; |
||
123 | } |
||
124 | |||
125 | /** |
||
126 | * @return int |
||
127 | * @throws Exception\RuntimeException |
||
128 | */ |
||
129 | public function getCount() |
||
154 | |||
155 | /** |
||
156 | * @return mixed |
||
157 | */ |
||
158 | public function init() |
||
161 | |||
162 | |||
163 | /** |
||
164 | * @return QueryBuilder |
||
165 | */ |
||
166 | public function getQuery() |
||
170 | |||
171 | /** |
||
172 | * @param QueryBuilder $query |
||
173 | * @return $this |
||
174 | */ |
||
175 | public function setQuery($query) |
||
180 | |||
181 | /** |
||
182 | * @return array |
||
183 | */ |
||
184 | public function getOrder() |
||
188 | |||
189 | /** |
||
190 | * [['field'=> 'u.username', 'order' => 'DESC'],['field' => 'u.create_date_time']] |
||
191 | * @param array | Traversable $order |
||
192 | * @return $this |
||
193 | */ |
||
194 | public function setOrder($order) |
||
199 | |||
200 | /** |
||
201 | * @return int |
||
202 | */ |
||
203 | public function getLimit() |
||
207 | |||
208 | /** |
||
209 | * @param int $limit |
||
210 | * @return $this |
||
211 | */ |
||
212 | public function setLimit($limit) |
||
217 | |||
218 | /** |
||
219 | * @return int |
||
220 | */ |
||
221 | public function getOffset() |
||
225 | |||
226 | /** |
||
227 | * @param int $offset |
||
228 | * @return $this |
||
229 | */ |
||
230 | public function setOffset($offset) |
||
235 | |||
236 | /** |
||
237 | * @return QueryBuilder |
||
238 | */ |
||
239 | public function getCountQuery() |
||
243 | |||
244 | /** |
||
245 | * @param QueryBuilder $countQuery |
||
246 | * @return $this |
||
247 | */ |
||
248 | public function setCountQuery($countQuery) |
||
253 | |||
254 | /** |
||
255 | * @return string |
||
256 | */ |
||
257 | public function getRootAlias() |
||
261 | |||
262 | /** |
||
263 | * @param string $rootAlias |
||
264 | * @return $this |
||
265 | */ |
||
266 | public function setRootAlias($rootAlias) |
||
271 | |||
272 | /** |
||
273 | * @return EntityManagerInterface |
||
274 | */ |
||
275 | public function getEntityManager() |
||
279 | |||
280 | /** |
||
281 | * @param ObjectManager|EntityManagerInterface $entityManager |
||
282 | * @return $this |
||
283 | */ |
||
284 | public function setEntityManager(EntityManagerInterface $entityManager) |
||
289 | } |
||
290 |
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
will produce issues in the first and second line, while this second example
will produce no issues.