1 | <?php |
||
45 | class ObjectAssociations extends SortableAssociations |
||
46 | { |
||
47 | use Accessor { |
||
48 | getQuery as parentGetQuery; |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * @inheritdoc |
||
53 | */ |
||
54 | const SOURCE_ATTRIBUTE = ObjectAssociation::SOURCE_ATTRIBUTE; |
||
55 | |||
56 | /** |
||
57 | * @inheritdoc |
||
58 | */ |
||
59 | const TARGET_ATTRIBUTE = ObjectAssociation::TARGET_ATTRIBUTE; |
||
60 | |||
61 | /** |
||
62 | * @inheritdoc |
||
63 | */ |
||
64 | 3 | public function init() |
|
74 | |||
75 | /** |
||
76 | * @throws \Throwable |
||
77 | */ |
||
78 | 3 | public function ensureTableExists() |
|
88 | |||
89 | /** |
||
90 | * @return bool |
||
91 | * @throws \Throwable |
||
92 | */ |
||
93 | 3 | private function createTable(): bool |
|
101 | |||
102 | /** |
||
103 | * @param ElementInterface $element |
||
104 | * @param Objects $field |
||
105 | * @return string|null |
||
106 | */ |
||
107 | public function findObjectIdByElement(ElementInterface $element, Objects $field) |
||
112 | |||
113 | /** |
||
114 | * @noinspection PhpDocMissingThrowsInspection |
||
115 | * |
||
116 | * @param string $fieldId |
||
117 | * @param string $elementId |
||
118 | * @param string|null $siteId |
||
119 | * @return null|string |
||
120 | */ |
||
121 | public function findObjectId(string $fieldId, string $elementId, string $siteId = null) |
||
132 | |||
133 | /** |
||
134 | * @noinspection PhpDocMissingThrowsInspection |
||
135 | * |
||
136 | * @param string $fieldId |
||
137 | * @param string $elementId |
||
138 | * @param string|null $siteId |
||
139 | * @return null|string |
||
140 | */ |
||
141 | public function findElementId(string $fieldId, string $elementId, string $siteId = null) |
||
152 | |||
153 | /** |
||
154 | * @inheritdoc |
||
155 | * @return ObjectAssociationQuery |
||
156 | */ |
||
157 | public function getQuery($config = []): SortableAssociationQueryInterface |
||
161 | |||
162 | /** |
||
163 | * @inheritdoc |
||
164 | * @return ObjectAssociationQuery |
||
165 | */ |
||
166 | protected function associationQuery( |
||
176 | |||
177 | /** |
||
178 | * @inheritdoc |
||
179 | * @param ObjectAssociationQuery $query |
||
180 | */ |
||
181 | protected function existingAssociations( |
||
194 | |||
195 | |||
196 | /** |
||
197 | * @param string $objectId |
||
198 | * @return ElementInterface |
||
199 | * @throws ElementNotFoundException |
||
200 | */ |
||
201 | public function getElementByObjectId(string $objectId): ElementInterface |
||
212 | |||
213 | /** |
||
214 | * @param string $objectId |
||
215 | * @return ElementInterface|null |
||
216 | */ |
||
217 | public function findElementByObjectId(string $objectId) |
||
229 | |||
230 | /** |
||
231 | * Find the HubSpot Id by Element Id |
||
232 | * |
||
233 | * @param int $id |
||
234 | * @return string|null |
||
235 | */ |
||
236 | public function findObjectIdByElementId(int $id) |
||
249 | |||
250 | |||
251 | /** |
||
252 | * @param $source |
||
253 | * @param int $fieldId |
||
254 | * @param int $siteId |
||
255 | * @return ObjectAssociationQuery |
||
256 | */ |
||
257 | private function query( |
||
270 | |||
271 | /** |
||
272 | * @param $source |
||
273 | * @param int $fieldId |
||
274 | * @param int $siteId |
||
275 | * @return array |
||
276 | */ |
||
277 | private function associations( |
||
286 | |||
287 | /** |
||
288 | * @inheritdoc |
||
289 | * @param bool $validate |
||
290 | * @throws \Exception |
||
291 | */ |
||
292 | public function save( |
||
314 | |||
315 | /** |
||
316 | * @param SortableAssociationQueryInterface $query |
||
317 | * @return Objects|null |
||
318 | */ |
||
319 | protected function resolveFieldFromQuery( |
||
328 | |||
329 | /** |
||
330 | * @inheritdoc |
||
331 | */ |
||
332 | protected static function tableAlias(): string |
||
336 | |||
337 | /** |
||
338 | * @inheritdoc |
||
339 | */ |
||
340 | public static function recordClass(): string |
||
344 | } |
||
345 |