1 | <?php |
||
47 | class ObjectAssociations extends SortableAssociations |
||
48 | { |
||
49 | use Accessor { |
||
50 | getQuery as parentGetQuery; |
||
51 | } |
||
52 | |||
53 | /** |
||
54 | * @inheritdoc |
||
55 | */ |
||
56 | const SOURCE_ATTRIBUTE = ObjectAssociation::SOURCE_ATTRIBUTE; |
||
57 | |||
58 | /** |
||
59 | * @inheritdoc |
||
60 | */ |
||
61 | const TARGET_ATTRIBUTE = ObjectAssociation::TARGET_ATTRIBUTE; |
||
62 | |||
63 | /** |
||
64 | * @inheritdoc |
||
65 | * @throws \Throwable |
||
66 | */ |
||
67 | 3 | public function init() |
|
77 | |||
78 | /** |
||
79 | * @throws \Throwable |
||
80 | */ |
||
81 | 3 | public function ensureTableExists() |
|
91 | |||
92 | /** |
||
93 | * @return bool |
||
94 | * @throws \Throwable |
||
95 | */ |
||
96 | 3 | private function createTable(): bool |
|
104 | |||
105 | /** |
||
106 | * @inheritdoc |
||
107 | * @return ObjectAssociationQuery |
||
108 | */ |
||
109 | public function getQuery($config = []): SortableAssociationQueryInterface |
||
113 | |||
114 | /** |
||
115 | * @param ElementInterface $element |
||
116 | * @param Objects $field |
||
117 | * @return string|null |
||
118 | */ |
||
119 | public function findObjectIdByElement(ElementInterface $element, Objects $field) |
||
124 | |||
125 | /** |
||
126 | * @noinspection PhpDocMissingThrowsInspection |
||
127 | * |
||
128 | * @param int $elementId |
||
129 | * @param int $fieldId |
||
130 | * @param int|null $siteId |
||
131 | * @return null|string |
||
132 | */ |
||
133 | public function findObjectId(int $elementId, int $fieldId, int $siteId = null) |
||
144 | |||
145 | /** |
||
146 | * @param int $elementId |
||
147 | * @param int $fieldId |
||
148 | * @param int|null $siteId |
||
149 | * @return string |
||
150 | * @throws NotFoundException |
||
151 | */ |
||
152 | public function getObjectId(int $elementId, int $fieldId, int $siteId = null): string |
||
167 | |||
168 | /** |
||
169 | * @noinspection PhpDocMissingThrowsInspection |
||
170 | * |
||
171 | * @param string $objectId |
||
172 | * @param int $fieldId |
||
173 | * @param int|null $siteId |
||
174 | * @return null|string |
||
175 | */ |
||
176 | public function findElementId(string $objectId, int $fieldId, int $siteId = null) |
||
187 | |||
188 | /** |
||
189 | * @param string $objectId |
||
190 | * @param int $fieldId |
||
191 | * @param int|null $siteId |
||
192 | * @return string |
||
193 | * @throws NotFoundException |
||
194 | */ |
||
195 | public function getElementId(string $objectId, int $fieldId, int $siteId = null): string |
||
210 | |||
211 | /** |
||
212 | * @param string $objectId |
||
213 | * @param int $fieldId |
||
214 | * @param int|null $siteId |
||
215 | * @return ElementInterface|null |
||
216 | */ |
||
217 | public function findElement(string $objectId, int $fieldId, int $siteId = null) |
||
225 | |||
226 | /** |
||
227 | * @param string $objectId |
||
228 | * @param int $fieldId |
||
229 | * @param int|null $siteId |
||
230 | * @return ElementInterface |
||
231 | * @throws ElementNotFoundException |
||
232 | */ |
||
233 | public function getElement(string $objectId, int $fieldId, int $siteId = null): ElementInterface |
||
248 | |||
249 | /** |
||
250 | * @inheritdoc |
||
251 | * @return ObjectAssociationQuery |
||
252 | */ |
||
253 | protected function associationQuery( |
||
263 | |||
264 | /** |
||
265 | * @inheritdoc |
||
266 | * @param ObjectAssociationQuery $query |
||
267 | */ |
||
268 | protected function existingAssociations( |
||
281 | |||
282 | /** |
||
283 | * @param $source |
||
284 | * @param int $fieldId |
||
285 | * @param int $siteId |
||
286 | * @return ObjectAssociationQuery |
||
287 | */ |
||
288 | private function query( |
||
301 | |||
302 | /** |
||
303 | * @param $source |
||
304 | * @param int $fieldId |
||
305 | * @param int $siteId |
||
306 | * @return array |
||
307 | */ |
||
308 | private function associations( |
||
317 | |||
318 | /** |
||
319 | * @inheritdoc |
||
320 | * @param bool $validate |
||
321 | * @throws \Exception |
||
322 | */ |
||
323 | public function save( |
||
345 | |||
346 | /** |
||
347 | * @param SortableAssociationQueryInterface $query |
||
348 | * @return Objects|null |
||
349 | */ |
||
350 | protected function resolveFieldFromQuery( |
||
359 | |||
360 | /** |
||
361 | * @inheritdoc |
||
362 | */ |
||
363 | protected static function tableAlias(): string |
||
367 | |||
368 | /** |
||
369 | * @inheritdoc |
||
370 | */ |
||
371 | public static function recordClass(): string |
||
375 | } |
||
376 |