Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | n/a |
0 / 0 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace Drupal\display_builder; |
6 | |
7 | use Drupal\Core\Entity\EntityInterface; |
8 | |
9 | /** |
10 | * Provides an interface defining a display builder instance entity type. |
11 | */ |
12 | interface InstanceInterface extends EntityInterface, HistoryInterface { |
13 | |
14 | /** |
15 | * Returns the display builder profile. |
16 | * |
17 | * @return \Drupal\display_builder\ProfileInterface|null |
18 | * The display builder profile. |
19 | */ |
20 | public function getProfile(): ?ProfileInterface; |
21 | |
22 | /** |
23 | * Set the display builder profile from id. |
24 | * |
25 | * @param string $profile_id |
26 | * Entity ID of the display builder profile. |
27 | */ |
28 | public function setProfile(string $profile_id): void; |
29 | |
30 | /** |
31 | * Move an instance to root. |
32 | * |
33 | * @param string $node_id |
34 | * The node ID of the source. |
35 | * @param int $position |
36 | * The position. |
37 | * |
38 | * @return bool |
39 | * True if success, false otherwise. |
40 | */ |
41 | public function moveToRoot(string $node_id, int $position): bool; |
42 | |
43 | /** |
44 | * Attach a new source instance to root. |
45 | * |
46 | * @param int $position |
47 | * The position. |
48 | * @param string $source_id |
49 | * The source ID. |
50 | * @param array $data |
51 | * The source data. |
52 | * @param array $third_party_settings |
53 | * (Optional) The source third party settings. Used for paste/duplicate. |
54 | * |
55 | * @return string |
56 | * The node ID of the source. |
57 | */ |
58 | public function attachToRoot(int $position, string $source_id, array $data, array $third_party_settings = []): string; |
59 | |
60 | /** |
61 | * Attach a new source to a slot. |
62 | * |
63 | * @param string $parent_id |
64 | * The parent id. |
65 | * @param string $slot_id |
66 | * The slot id. |
67 | * @param int $position |
68 | * The position. |
69 | * @param string $source_id |
70 | * The source ID. |
71 | * @param array $data |
72 | * The source data. |
73 | * @param array $third_party_settings |
74 | * (Optional) The source third party settings. Used for paste/duplicate. |
75 | * |
76 | * @return string |
77 | * The node ID of the source. |
78 | */ |
79 | public function attachToSlot(string $parent_id, string $slot_id, int $position, string $source_id, array $data, array $third_party_settings = []): string; |
80 | |
81 | /** |
82 | * Move an instance to a slot. |
83 | * |
84 | * @param string $node_id |
85 | * The node ID of the source. |
86 | * @param string $parent_id |
87 | * The parent id. |
88 | * @param string $slot_id |
89 | * The slot id. |
90 | * @param int $position |
91 | * The position. |
92 | * |
93 | * @return bool |
94 | * True if success, false otherwise. |
95 | */ |
96 | public function moveToSlot(string $node_id, string $parent_id, string $slot_id, int $position): bool; |
97 | |
98 | /** |
99 | * Get instance data. |
100 | * |
101 | * @param string $node_id |
102 | * The node ID of the source. |
103 | * |
104 | * @return array |
105 | * The instance data. |
106 | */ |
107 | public function get(string $node_id): array; |
108 | |
109 | /** |
110 | * Get the parent id of an instance. |
111 | * |
112 | * @param array $root |
113 | * The root data. |
114 | * @param string $node_id |
115 | * The node ID of the source. |
116 | * |
117 | * @return string |
118 | * The parent id or empty. |
119 | */ |
120 | public function getParentId(array $root, string $node_id): string; |
121 | |
122 | /** |
123 | * Set the source for an instance. |
124 | * |
125 | * @param string $node_id |
126 | * The node ID of the source. |
127 | * @param string $source_id |
128 | * The source id. |
129 | * @param array $data |
130 | * The source data. |
131 | */ |
132 | public function setSource(string $node_id, string $source_id, array $data): void; |
133 | |
134 | /** |
135 | * Set the third party settings for an instance. |
136 | * |
137 | * @param string $node_id |
138 | * The node ID of the source. |
139 | * @param string $island_id |
140 | * The island id (relative to third party settings). |
141 | * @param array $data |
142 | * The third party data for the island. |
143 | */ |
144 | public function setThirdPartySettings(string $node_id, string $island_id, array $data): void; |
145 | |
146 | /** |
147 | * Remove an instance. |
148 | * |
149 | * @param string $node_id |
150 | * The node ID of the source. |
151 | */ |
152 | public function remove(string $node_id): void; |
153 | |
154 | /** |
155 | * Set the save value of a display builder. |
156 | * |
157 | * @param array $save_data |
158 | * The builder data to save. |
159 | */ |
160 | public function setSave(array $save_data): void; |
161 | |
162 | /** |
163 | * Gets the values for all defined contexts. |
164 | * |
165 | * @return \Drupal\Core\Plugin\Context\ContextInterface[]|null |
166 | * An array of set contexts, keyed by context name. |
167 | */ |
168 | public function getContexts(): ?array; |
169 | |
170 | /** |
171 | * Get users. |
172 | * |
173 | * All users which have authored a step in present, past or future, with the |
174 | * most recent date of action. |
175 | * |
176 | * @return array |
177 | * Each key is an User entity ID, each value is a timestamp. |
178 | */ |
179 | public function getUsers(): array; |
180 | |
181 | /** |
182 | * Check display has required context, meaning it can save value. |
183 | * |
184 | * @param \Drupal\Core\Plugin\Context\ContextInterface[]|null $contexts |
185 | * (Optional) contexts if already accessible, keyed by context name. |
186 | * |
187 | * @return bool |
188 | * True if required, False otherwise. |
189 | */ |
190 | public function canSaveContextsRequirement(?array $contexts = NULL): bool; |
191 | |
192 | /** |
193 | * Check display has required context, meaning it can save value. |
194 | * |
195 | * @param string $key |
196 | * The context key to look for. |
197 | * @param \Drupal\Core\Plugin\Context\ContextInterface[] $contexts |
198 | * (Optional) contexts if already accessible, keyed by context name. |
199 | * |
200 | * @return bool |
201 | * True if required, False otherwise. |
202 | */ |
203 | public function hasSaveContextsRequirement(string $key, array $contexts = []): bool; |
204 | |
205 | /** |
206 | * If display builder has been saved. |
207 | * |
208 | * @return bool |
209 | * Has save data. |
210 | */ |
211 | public function hasSave(): bool; |
212 | |
213 | /** |
214 | * The save value is the current value of display builder. |
215 | * |
216 | * @return bool |
217 | * The save is the current or not. |
218 | */ |
219 | public function saveIsCurrent(): bool; |
220 | |
221 | /** |
222 | * Get the path index. |
223 | * |
224 | * @param array $root |
225 | * (Optional) The root state. |
226 | * |
227 | * @return array |
228 | * The path index. |
229 | */ |
230 | public function getPathIndex(array $root = []): array; |
231 | |
232 | /** |
233 | * Restore to the last saved state. |
234 | */ |
235 | public function restore(): void; |
236 | |
237 | /** |
238 | * Get a hash for this data as uniq id reference. |
239 | * |
240 | * @param array $data |
241 | * The data to generate uniq id for. |
242 | * |
243 | * @return int |
244 | * The uniq id value. |
245 | */ |
246 | public static function getUniqId(array $data): int; |
247 | |
248 | } |