1 | <?php |
||
30 | abstract class Integrations extends Field |
||
31 | { |
||
32 | use NormalizeValueTrait, |
||
33 | ModifyElementQueryTrait; |
||
34 | |||
35 | /** |
||
36 | * The Plugin's translation category |
||
37 | */ |
||
38 | const TRANSLATION_CATEGORY = ''; |
||
39 | |||
40 | /** |
||
41 | * The action path to preform field actions |
||
42 | */ |
||
43 | const ACTION_PREFORM_ACTION_PATH = ''; |
||
44 | |||
45 | /** |
||
46 | * The action path to preform field actions |
||
47 | */ |
||
48 | const ACTION_PREFORM_ITEM_ACTION_PATH = ''; |
||
49 | |||
50 | /** |
||
51 | * The action path to associate an item |
||
52 | */ |
||
53 | const ACTION_ASSOCIATION_ITEM_PATH = ''; |
||
54 | |||
55 | /** |
||
56 | * The action path to dissociate an item |
||
57 | */ |
||
58 | const ACTION_DISSOCIATION_ITEM_PATH = ''; |
||
59 | |||
60 | /** |
||
61 | * The action path to create an integration object |
||
62 | */ |
||
63 | const ACTION_CREATE_ITEM_PATH = ''; |
||
64 | |||
65 | /** |
||
66 | * The action event name |
||
67 | */ |
||
68 | const EVENT_REGISTER_ACTIONS = 'registerActions'; |
||
69 | |||
70 | /** |
||
71 | * The action event name |
||
72 | */ |
||
73 | const EVENT_REGISTER_AVAILABLE_ACTIONS = 'registerAvailableActions'; |
||
74 | |||
75 | /** |
||
76 | * The item action event name |
||
77 | */ |
||
78 | const EVENT_REGISTER_ITEM_ACTIONS = 'registerItemActions'; |
||
79 | |||
80 | /** |
||
81 | * The item action event name |
||
82 | */ |
||
83 | const EVENT_REGISTER_AVAILABLE_ITEM_ACTIONS = 'registerAvailableItemActions'; |
||
84 | |||
85 | /** |
||
86 | * The default action event name |
||
87 | */ |
||
88 | const DEFAULT_AVAILABLE_ACTIONS = []; |
||
89 | |||
90 | /** |
||
91 | * The default item action event name |
||
92 | */ |
||
93 | const DEFAULT_AVAILABLE_ITEM_ACTIONS = []; |
||
94 | |||
95 | /** |
||
96 | * The input template path |
||
97 | */ |
||
98 | const INPUT_TEMPLATE_PATH = ''; |
||
99 | |||
100 | /** |
||
101 | * The input template path |
||
102 | */ |
||
103 | const INPUT_ITEM_TEMPLATE_PATH = '_inputItem'; |
||
104 | |||
105 | /** |
||
106 | * The input template path |
||
107 | */ |
||
108 | const SETTINGS_TEMPLATE_PATH = ''; |
||
109 | |||
110 | /** |
||
111 | * @var string |
||
112 | */ |
||
113 | public $object; |
||
114 | |||
115 | /** |
||
116 | * @var int|null |
||
117 | */ |
||
118 | public $min; |
||
119 | |||
120 | /** |
||
121 | * @var int|null |
||
122 | */ |
||
123 | public $max; |
||
124 | |||
125 | /** |
||
126 | * @var string |
||
127 | */ |
||
128 | public $viewUrl = ''; |
||
129 | |||
130 | /** |
||
131 | * @var string |
||
132 | */ |
||
133 | public $listUrl = ''; |
||
134 | |||
135 | /** |
||
136 | * @var IntegrationActionInterface[] |
||
137 | */ |
||
138 | public $selectedActions = []; |
||
139 | |||
140 | /** |
||
141 | * @var IntegrationItemActionInterface[] |
||
142 | */ |
||
143 | public $selectedItemActions = []; |
||
144 | |||
145 | /** |
||
146 | * @var string|null |
||
147 | */ |
||
148 | public $selectionLabel; |
||
149 | |||
150 | /** |
||
151 | * @return string |
||
152 | */ |
||
153 | abstract public static function recordClass(): string; |
||
154 | |||
155 | /******************************************* |
||
156 | * OBJECT |
||
157 | *******************************************/ |
||
158 | |||
159 | /** |
||
160 | * @return string |
||
161 | */ |
||
162 | public function getObjectLabel(): string |
||
166 | |||
167 | /** |
||
168 | * @inheritdoc |
||
169 | */ |
||
170 | public static function hasContentColumn(): bool |
||
174 | |||
175 | /** |
||
176 | * @return string |
||
177 | */ |
||
178 | public static function defaultSelectionLabel(): string |
||
182 | |||
183 | |||
184 | /******************************************* |
||
185 | * VALIDATION |
||
186 | *******************************************/ |
||
187 | |||
188 | /** |
||
189 | * @inheritdoc |
||
190 | */ |
||
191 | public function getElementValidationRules(): array |
||
210 | |||
211 | /******************************************* |
||
212 | * RULES |
||
213 | *******************************************/ |
||
214 | |||
215 | /** |
||
216 | * @inheritdoc |
||
217 | */ |
||
218 | public function rules() |
||
245 | |||
246 | |||
247 | /******************************************* |
||
248 | * SEARCH |
||
249 | *******************************************/ |
||
250 | |||
251 | /** |
||
252 | * @param ActiveQuery $value |
||
253 | * @inheritdoc |
||
254 | */ |
||
255 | public function getSearchKeywords($value, ElementInterface $element): string |
||
266 | |||
267 | |||
268 | /******************************************* |
||
269 | * VIEWS |
||
270 | *******************************************/ |
||
271 | |||
272 | /** |
||
273 | * @inheritdoc |
||
274 | * @param ActiveQuery $value |
||
275 | * @throws \Twig_Error_Loader |
||
276 | * @throws \yii\base\Exception |
||
277 | */ |
||
278 | public function getInputHtml($value, ElementInterface $element = null): string |
||
289 | |||
290 | /** |
||
291 | * @param ActiveQuery $query |
||
292 | * @param ElementInterface|null $element |
||
293 | * @param bool $static |
||
294 | * @return array |
||
295 | * @throws \craft\errors\MissingComponentException |
||
296 | * @throws \yii\base\InvalidConfigException |
||
297 | */ |
||
298 | protected function inputHtmlVariables( |
||
338 | |||
339 | /** |
||
340 | * @param ElementInterface|null $element |
||
341 | * @return array |
||
342 | * @throws \craft\errors\MissingComponentException |
||
343 | * @throws \yii\base\InvalidConfigException |
||
344 | */ |
||
345 | protected function getActionHtml(ElementInterface $element = null): array |
||
361 | |||
362 | /** |
||
363 | * @param ElementInterface|null $element |
||
364 | * @return array |
||
365 | * @throws \craft\errors\MissingComponentException |
||
366 | * @throws \yii\base\InvalidConfigException |
||
367 | */ |
||
368 | protected function getItemActionHtml(ElementInterface $element = null): array |
||
384 | |||
385 | |||
386 | /******************************************* |
||
387 | * SETTINGS |
||
388 | *******************************************/ |
||
389 | |||
390 | /** |
||
391 | * @inheritdoc |
||
392 | * @throws \Twig_Error_Loader |
||
393 | * @throws \yii\base\Exception |
||
394 | */ |
||
395 | public function getSettingsHtml() |
||
402 | |||
403 | /** |
||
404 | * @return array |
||
405 | * @throws \craft\errors\MissingComponentException |
||
406 | * @throws \yii\base\InvalidConfigException |
||
407 | */ |
||
408 | protected function settingsHtmlVariables(): array |
||
417 | |||
418 | |||
419 | /******************************************* |
||
420 | * ACTIONS |
||
421 | *******************************************/ |
||
422 | |||
423 | /** |
||
424 | * @return IntegrationActionInterface[] |
||
425 | * @throws \craft\errors\MissingComponentException |
||
426 | * @throws \yii\base\InvalidConfigException |
||
427 | */ |
||
428 | public function getAvailableActions(): array |
||
444 | |||
445 | /** |
||
446 | * @return IntegrationActionInterface[] |
||
447 | * @throws \craft\errors\MissingComponentException |
||
448 | * @throws \yii\base\InvalidConfigException |
||
449 | */ |
||
450 | public function getAvailableItemActions(): array |
||
466 | |||
467 | /** |
||
468 | * @param ElementInterface|null $element |
||
469 | * @return IntegrationActionInterface[] |
||
470 | * @throws \craft\errors\MissingComponentException |
||
471 | * @throws \yii\base\InvalidConfigException |
||
472 | */ |
||
473 | public function getActions(ElementInterface $element = null): array |
||
490 | |||
491 | /** |
||
492 | * @param ElementInterface|null $element |
||
493 | * @return IntegrationItemActionInterface[] |
||
494 | * @throws \craft\errors\MissingComponentException |
||
495 | * @throws \yii\base\InvalidConfigException |
||
496 | */ |
||
497 | public function getItemActions(ElementInterface $element = null): array |
||
514 | |||
515 | /** |
||
516 | * @param array $actions |
||
517 | * @param string $instance |
||
518 | * @return array |
||
519 | * @throws \craft\errors\MissingComponentException |
||
520 | * @throws \yii\base\InvalidConfigException |
||
521 | */ |
||
522 | protected function resolveActions(array $actions, string $instance) |
||
537 | |||
538 | |||
539 | /******************************************* |
||
540 | * EVENTS |
||
541 | *******************************************/ |
||
542 | |||
543 | /** |
||
544 | * @inheritdoc |
||
545 | */ |
||
546 | public function afterElementSave(ElementInterface $element, bool $isNew) |
||
561 | |||
562 | /******************************************* |
||
563 | * SETTINGS |
||
564 | *******************************************/ |
||
565 | |||
566 | /** |
||
567 | * @inheritdoc |
||
568 | */ |
||
569 | public function settingsAttributes(): array |
||
585 | |||
586 | /** |
||
587 | * Returns the site ID that target elements should have. |
||
588 | * |
||
589 | * @param ElementInterface|Element|null $element |
||
590 | * |
||
591 | * @return int |
||
592 | */ |
||
593 | protected function targetSiteId(ElementInterface $element = null): int |
||
602 | } |
||
603 |