1 | <?php |
||
44 | abstract class IntegrationAssociations extends SortableAssociations |
||
45 | { |
||
46 | use Accessor { |
||
47 | getQuery as parentGetQuery; |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * @inheritdoc |
||
52 | */ |
||
53 | const TARGET_ATTRIBUTE = IntegrationAssociation::TARGET_ATTRIBUTE; |
||
54 | |||
55 | /** |
||
56 | * @inheritdoc |
||
57 | */ |
||
58 | const SOURCE_ATTRIBUTE = IntegrationAssociation::SOURCE_ATTRIBUTE; |
||
59 | |||
60 | /** |
||
61 | * @return IntegrationField |
||
62 | */ |
||
63 | abstract protected function fieldService(): IntegrationField; |
||
64 | |||
65 | /** |
||
66 | * @param IntegrationAssociation $record |
||
67 | * @return bool |
||
68 | * @throws \yii\base\InvalidConfigException |
||
69 | */ |
||
70 | abstract public function validateObject(IntegrationAssociation $record): bool; |
||
71 | |||
72 | /** |
||
73 | * @inheritdoc |
||
74 | * @return IntegrationAssociationQuery |
||
75 | */ |
||
76 | public function getQuery($config = []): SortableAssociationQueryInterface |
||
80 | |||
81 | /** |
||
82 | * @param ElementInterface $element |
||
83 | * @param Integrations $field |
||
84 | * @return string|null |
||
85 | */ |
||
86 | public function findObjectIdByElement(ElementInterface $element, Integrations $field) |
||
91 | |||
92 | /** |
||
93 | * @param int $elementId |
||
94 | * @param int $fieldId |
||
95 | * @param int|null $siteId |
||
96 | * @return null|string |
||
97 | */ |
||
98 | public function findObjectId(int $elementId, int $fieldId, int $siteId = null) |
||
109 | |||
110 | /** |
||
111 | * @param int $elementId |
||
112 | * @param int $fieldId |
||
113 | * @param int|null $siteId |
||
114 | * @return string |
||
115 | * @throws NotFoundException |
||
116 | */ |
||
117 | public function getObjectId(int $elementId, int $fieldId, int $siteId = null): string |
||
132 | |||
133 | /** |
||
134 | * @param string $objectId |
||
135 | * @param int $fieldId |
||
136 | * @param int|null $siteId |
||
137 | * @return null|string |
||
138 | */ |
||
139 | public function findElementId(string $objectId, int $fieldId, int $siteId = null) |
||
150 | |||
151 | /** |
||
152 | * @param string $objectId |
||
153 | * @param int $fieldId |
||
154 | * @param int|null $siteId |
||
155 | * @return string |
||
156 | * @throws NotFoundException |
||
157 | */ |
||
158 | public function getElementId(string $objectId, int $fieldId, int $siteId = null): string |
||
173 | |||
174 | /** |
||
175 | * @param string $objectId |
||
176 | * @param int $fieldId |
||
177 | * @param int|null $siteId |
||
178 | * @return ElementInterface|null |
||
179 | */ |
||
180 | public function findElement(string $objectId, int $fieldId, int $siteId = null) |
||
188 | |||
189 | /** |
||
190 | * @param string $objectId |
||
191 | * @param int $fieldId |
||
192 | * @param int|null $siteId |
||
193 | * @return ElementInterface |
||
194 | * @throws ElementNotFoundException |
||
195 | */ |
||
196 | public function getElement(string $objectId, int $fieldId, int $siteId = null): ElementInterface |
||
211 | |||
212 | /** |
||
213 | * @param string $objectId |
||
214 | * @param int $elementId |
||
215 | * @param int $fieldId |
||
216 | * @param int|null $siteId |
||
217 | * @param int|null $sortOrder |
||
218 | * @return bool |
||
219 | */ |
||
220 | public function associateByIds( |
||
235 | |||
236 | /** |
||
237 | * @param string $objectId |
||
238 | * @param int $elementId |
||
239 | * @param int $fieldId |
||
240 | * @param int|null $siteId |
||
241 | * @param int|null $sortOrder |
||
242 | * @return bool |
||
243 | */ |
||
244 | public function dissociateByIds( |
||
259 | |||
260 | /** |
||
261 | * @inheritdoc |
||
262 | * @param IntegrationAssociation $record |
||
263 | * @return IntegrationAssociationQuery |
||
264 | */ |
||
265 | protected function associationQuery( |
||
276 | |||
277 | /** |
||
278 | * @inheritdoc |
||
279 | * @param IntegrationAssociationQuery $query |
||
280 | */ |
||
281 | protected function existingAssociations( |
||
294 | |||
295 | /** |
||
296 | * @param int $elementId |
||
297 | * @param int $fieldId |
||
298 | * @param int $siteId |
||
299 | * @return IntegrationAssociationQuery |
||
300 | */ |
||
301 | private function query( |
||
314 | |||
315 | /** |
||
316 | * @param int $elementId |
||
317 | * @param int $fieldId |
||
318 | * @param int $siteId |
||
319 | * @return array |
||
320 | */ |
||
321 | private function associations( |
||
330 | |||
331 | /** |
||
332 | * @inheritdoc |
||
333 | * @param bool $validate |
||
334 | * @throws \Exception |
||
335 | */ |
||
336 | public function save( |
||
355 | |||
356 | /** |
||
357 | * @param SortableAssociationQueryInterface $query |
||
358 | * @return Integrations|null |
||
359 | */ |
||
360 | protected function resolveFieldFromQuery( |
||
369 | } |
||
370 |