Code Coverage
 
Lines
Branches
Paths
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2
3declare(strict_types=1);
4
5namespace Drupal\display_builder;
6
7use Drupal\Core\Entity\ContentEntityInterface;
8
9/**
10 * Provides an interface defining a display builder instance entity type.
11 */
12interface InstanceInterface extends ContentEntityInterface, 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 a source 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 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 a source 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 node data.
100   *
101   * @param string $node_id
102   *   The node ID of the source.
103   *
104   * @return array
105   *   The node data.
106   */
107  public function getNode(string $node_id): array;
108
109  /**
110   * Get the parent id of an node.
111   *
112   * @param string $node_id
113   *   The node ID of the source.
114   *
115   * @return string
116   *   The parent node id. Empty if the node is at the root level.
117   */
118  public function getParentId(string $node_id): string;
119
120  /**
121   * Set the source for a tree node.
122   *
123   * @param string $node_id
124   *   The node ID of the source.
125   * @param string $source_id
126   *   The source id.
127   * @param array $data
128   *   The source data.
129   */
130  public function setSource(string $node_id, string $source_id, array $data): void;
131
132  /**
133   * Set the third party settings for a tree node.
134   *
135   * @param string $node_id
136   *   The node ID of the source.
137   * @param string $island_id
138   *   The island id (relative to third party settings).
139   * @param array $data
140   *   The third party data for the island.
141   */
142  public function setThirdPartySettings(string $node_id, string $island_id, array $data): void;
143
144  /**
145   * Remove an tree node.
146   *
147   * @param string $node_id
148   *   The node ID of the source.
149   */
150  public function remove(string $node_id): void;
151
152  /**
153   * Set the save value of a display builder.
154   *
155   * @param array $save_data
156   *   The builder data to save.
157   */
158  public function setSave(array $save_data): void;
159
160  /**
161   * Gets the values for all defined contexts.
162   *
163   * @return \Drupal\Core\Plugin\Context\ContextInterface[]|null
164   *   An array of set contexts, keyed by context name.
165   */
166  public function getContexts(): ?array;
167
168  /**
169   * Get users.
170   *
171   * All users which have authored a step in present, past or future, with the
172   * most recent date of action.
173   *
174   * @return array
175   *   Each key is an User entity ID, each value is a timestamp.
176   */
177  public function getUsers(): array;
178
179  /**
180   * Check display has required context, meaning it can save value.
181   *
182   * @param \Drupal\Core\Plugin\Context\ContextInterface[]|null $contexts
183   *   (Optional) contexts if already accessible, keyed by context name.
184   *
185   * @return bool
186   *   True if required, False otherwise.
187   */
188  public function canSaveContextsRequirement(?array $contexts = NULL): bool;
189
190  /**
191   * Check display has required context, meaning it can save value.
192   *
193   * @param string $key
194   *   The context key to look for.
195   * @param \Drupal\Core\Plugin\Context\ContextInterface[] $contexts
196   *   (Optional) contexts if already accessible, keyed by context name.
197   *
198   * @return bool
199   *   True if required, False otherwise.
200   */
201  public function hasSaveContextsRequirement(string $key, array $contexts = []): bool;
202
203  /**
204   * If display builder has been saved.
205   *
206   * @return bool
207   *   Has save data.
208   */
209  public function hasSave(): bool;
210
211  /**
212   * The save value is the current value of display builder.
213   *
214   * @return bool
215   *   The save is the current or not.
216   */
217  public function saveIsCurrent(): bool;
218
219  /**
220   * Get the path index.
221   *
222   * @return array
223   *   The path index.
224   */
225  public function getPathIndex(): array;
226
227  /**
228   * Restore to the last saved state.
229   */
230  public function restore(): void;
231
232  /**
233   * Get a hash for this data as uniq id reference.
234   *
235   * @param array $data
236   *   The data to generate uniq id for.
237   *
238   * @return int
239   *   The uniq id value.
240   */
241  public static function getUniqId(array $data): int;
242
243}