1 | <?php |
||
25 | trait ElementQueryOptionsTrait |
||
26 | { |
||
27 | /** |
||
28 | * @var array |
||
29 | * The query conditional id logic for (ElementQuery only) used to source the sync operation. |
||
30 | * example: -id=1,2,4 |
||
31 | */ |
||
32 | public $queryId = []; |
||
33 | |||
34 | /** |
||
35 | * @var array |
||
36 | * The query conditional status logic for (ElementQuery only) used to source the sync operation. |
||
37 | * example: -status=active,pending |
||
38 | */ |
||
39 | public $queryStatus = []; |
||
40 | |||
41 | /** |
||
42 | * @var array |
||
43 | * The query conditional used to source the sync operation. |
||
44 | * example: -where='and,elements.dateUpdated > "2000-01-01",elements.dateCreated < "2010-01-01"' |
||
45 | */ |
||
46 | public $queryWhere = []; |
||
47 | |||
48 | /** |
||
49 | * @var int |
||
50 | * The query limit logic used to source the sync operation. Set to -1 to remove limit. |
||
51 | * example: -limit=10 |
||
52 | */ |
||
53 | public $queryLimit = 100; |
||
54 | |||
55 | /** |
||
56 | * @var int |
||
57 | * The query offset logic used to source the sync operation. |
||
58 | * example: -limit=0 |
||
59 | */ |
||
60 | public $queryOffset = 0; |
||
61 | |||
62 | /** |
||
63 | * @var ElementQueryInterface|ElementQuery |
||
64 | */ |
||
65 | private $query; |
||
66 | |||
67 | /** |
||
68 | * Returns properties corresponding to the options for the action id |
||
69 | * Child classes may override this method to specify possible properties. |
||
70 | * |
||
71 | * @param string $actionID the action id of the current request |
||
72 | * @return array properties corresponding to the options for the action |
||
73 | */ |
||
74 | abstract public function getOptionValues($actionID); |
||
75 | |||
76 | /** |
||
77 | * Returns option alias names. |
||
78 | * Child classes may override this method to specify alias options. |
||
79 | * |
||
80 | * @return array the options alias names valid for the action |
||
81 | * where the keys is alias name for option and value is option name. |
||
82 | * |
||
83 | * @since 2.0.8 |
||
84 | * @see options() |
||
85 | */ |
||
86 | abstract public function optionAliases(); |
||
87 | |||
88 | /** |
||
89 | * @return string |
||
90 | * @throws Exception |
||
91 | */ |
||
92 | protected function elementType(): string |
||
99 | |||
100 | /** |
||
101 | * @return array |
||
102 | */ |
||
103 | protected function queryConfig(): array |
||
107 | |||
108 | /** |
||
109 | * @inheritdoc |
||
110 | */ |
||
111 | protected function queryOptions() |
||
121 | |||
122 | /** |
||
123 | * @inheritdoc |
||
124 | */ |
||
125 | protected function queryOptionAliases() |
||
135 | |||
136 | /******************************************* |
||
137 | * PREPARE |
||
138 | *******************************************/ |
||
139 | |||
140 | /** |
||
141 | * @throws Exception |
||
142 | */ |
||
143 | protected function prepQuery() |
||
177 | |||
178 | /** |
||
179 | * @param $method |
||
180 | * @param $value |
||
181 | * @return mixed |
||
182 | */ |
||
183 | private function prepOptionValue($method, $value) |
||
193 | |||
194 | /******************************************* |
||
195 | * PREPARE SPECIFIC ATTRIBUTES |
||
196 | *******************************************/ |
||
197 | |||
198 | /** |
||
199 | * @param $value |
||
200 | * @return null|array |
||
201 | */ |
||
202 | protected function prepQueryId($value) |
||
210 | |||
211 | /** |
||
212 | * @param $value |
||
213 | * @return null|array |
||
214 | */ |
||
215 | protected function prepQueryStatus($value) |
||
223 | |||
224 | /** |
||
225 | * @param $value |
||
226 | * @return null|array |
||
227 | */ |
||
228 | protected function prepQueryWhere($value) |
||
236 | |||
237 | /** |
||
238 | * @param array $config |
||
239 | * @return ElementQuery|ElementQueryInterface |
||
240 | * @throws Exception |
||
241 | */ |
||
242 | protected function getQuery(array $config = []): ElementQueryInterface |
||
255 | |||
256 | /** |
||
257 | * @return ElementQueryInterface |
||
258 | * @throws Exception |
||
259 | */ |
||
260 | protected function createQuery(): ElementQueryInterface |
||
267 | } |
||
268 |