1 | <?php |
||
13 | |||
14 | class LampagerTransformer |
||
15 | { |
||
16 | /** @var LampagerPaginator */ |
||
17 | protected $paginator; |
||
18 | |||
19 | public function __construct(LampagerPaginator $paginator) |
||
20 | 36 | { |
|
21 | $this->paginator = $paginator; |
||
22 | 36 | } |
|
23 | 36 | ||
24 | /** |
||
25 | * Transform Query to CakePHP query. |
||
26 | * |
||
27 | * @param Query $query Query. |
||
28 | * @return array Options for Model::find. |
||
29 | */ |
||
30 | public function transform(Query $query) |
||
61 | 32 | } |
|
62 | |||
63 | /** |
||
64 | * Build query from the cursor. |
||
65 | * |
||
66 | * @param Cursor|int[]|string[] $cursor Cursor. |
||
67 | * @return array Options for Model::find. |
||
68 | */ |
||
69 | public function build($cursor = []) |
||
70 | 32 | { |
|
71 | return $this->transform($this->paginator->configure(new LampagerArrayCursor($this->paginator->builder, $cursor))); |
||
72 | 32 | } |
|
73 | |||
74 | /** |
||
75 | * @param SelectOrUnionAll $selectOrUnionAll |
||
76 | * @return string |
||
77 | */ |
||
78 | protected function compileSelectOrUnionAll(SelectOrUnionAll $selectOrUnionAll) |
||
79 | 32 | { |
|
80 | if ($selectOrUnionAll instanceof Select) { |
||
81 | 32 | return '(' . $this->compileSelect($selectOrUnionAll) . ')'; |
|
82 | 16 | } |
|
83 | |||
84 | 16 | if ($selectOrUnionAll instanceof UnionAll) { |
|
85 | 16 | $supportQuery = $this->compileSelect($selectOrUnionAll->supportQuery()); |
|
86 | 16 | $mainQuery = $this->compileSelect($selectOrUnionAll->mainQuery()); |
|
87 | 16 | ||
88 | if ($this->paginator->builder->getDataSource() instanceof Sqlite) { |
||
89 | return '(SELECT * FROM (' . $supportQuery . ') UNION ALL SELECT * FROM (' . $mainQuery . '))'; |
||
90 | } |
||
91 | |||
92 | return '((' . $supportQuery . ') UNION ALL (' . $mainQuery . '))'; |
||
93 | } |
||
94 | |||
95 | // @codeCoverageIgnoreStart |
||
96 | throw new \LogicException('Unreachable here'); |
||
97 | // @codeCoverageIgnoreEnd |
||
98 | } |
||
99 | 32 | ||
100 | /** |
||
101 | 32 | * @param Select $select |
|
102 | 32 | * @return string |
|
103 | */ |
||
104 | protected function compileSelect(Select $select) |
||
105 | 32 | { |
|
106 | $model = $this->paginator->builder; |
||
107 | 32 | $query = $this->paginator->query; |
|
108 | 32 | ||
109 | 32 | /** @var DboSource $db */ |
|
110 | 32 | $db = $model->getDataSource(); |
|
111 | 32 | ||
112 | 32 | return $db->buildStatement([ |
|
113 | 'limit' => $this->compileLimit($select), |
||
114 | 32 | 'order' => $this->compileOrderBy($select), |
|
115 | 32 | 'conditions' => array_merge_recursive( |
|
116 | $this->compileWhere($select), |
||
117 | 32 | $query['conditions'] ?: [] |
|
118 | ), |
||
119 | 32 | 'alias' => $model->alias, |
|
120 | 'table' => $db->fullTableName($model), |
||
121 | 'fields' => [ |
||
122 | $db->name("{$model->alias}.{$model->primaryKey}"), |
||
123 | ], |
||
124 | ], $model); |
||
125 | } |
||
126 | 32 | ||
127 | /** |
||
128 | 32 | * @param Select $select |
|
129 | 32 | * @return string[] |
|
130 | 16 | */ |
|
131 | protected function compileWhere(Select $select) |
||
138 | } |
||
139 | 16 | ||
140 | /** |
||
141 | 16 | * @param ConditionGroup $group |
|
142 | 16 | * @return \Generator<string,string> |
|
143 | 16 | */ |
|
144 | 16 | protected function compileWhereGroup(ConditionGroup $group) |
|
145 | { |
||
146 | 16 | foreach ($group as $condition) { |
|
147 | $column = $condition->left() . ' ' . $condition->comparator(); |
||
148 | $value = $condition->right(); |
||
149 | yield $column => $value; |
||
150 | } |
||
151 | } |
||
152 | 32 | ||
153 | /** |
||
154 | 32 | * @param SelectOrUnionAll $selectOrUnionAll |
|
155 | 32 | * @return string[] |
|
156 | 32 | */ |
|
157 | protected function compileOrderBy(SelectOrUnionAll $selectOrUnionAll) |
||
178 | } |
||
179 | |||
180 | /** |
||
181 | * @param Select $select |
||
182 | * @return int |
||
189 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths