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\Island;
6
7use Drupal\Component\Plugin\ConfigurableInterface;
8use Drupal\Component\Plugin\PluginInspectionInterface;
9use Drupal\Core\Form\FormStateInterface;
10use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
11use Drupal\display_builder\InstanceInterface;
12
13/**
14 * Interface for island plugins.
15 */
16interface IslandInterface extends ConfigurableInterface, ContainerFactoryPluginInterface, IslandEventSubscriberInterface, PluginInspectionInterface {
17
18  /**
19   * Define keyboard shortcuts.
20   *
21   * @return array
22   *   An associative array of key => description.
23   */
24  public static function keyboardShortcuts(): array;
25
26  /**
27   * Build renderable from state data.
28   *
29   * @param \Drupal\display_builder\InstanceInterface $builder
30   *   Display builder instance.
31   * @param array $data
32   *   (Optional) UI Patterns 2 sources data. It can be the full data state
33   *   (so, the same as $builder->getCurrentState()) or just some specific data
34   *   of a single source of a sub-tree of sources.
35   * @param array $options
36   *   (Optional) Additional data to alter the island rendering.
37   *
38   * @return array
39   *   A renderable array.
40   */
41  public function build(InstanceInterface $builder, array $data = [], array $options = []): array;
42
43  /**
44   * Alter form element after its built.
45   *
46   * @param array $element
47   *   An associative array containing the structure of the form element.
48   * @param \Drupal\Core\Form\FormStateInterface $form_state
49   *   The current state of the form.
50   *
51   * @return array
52   *   The altered form element.
53   */
54  public function afterBuild(array $element, FormStateInterface $form_state): array;
55
56  /**
57   * Returns the translated plugin label.
58   *
59   * @return string
60   *   The island label.
61   */
62  public function label(): string;
63
64  /**
65   * Get island type value.
66   *
67   * @return string
68   *   The type value attribute value.
69   */
70  public function getTypeId(): string;
71
72  /**
73   * Get HTML ID.
74   *
75   * This ID is used to update an interactive island.
76   *
77   * @param string $builder_id
78   *   Builder ID.
79   *
80   * @return string
81   *   The HTML ID attribute value.
82   */
83  public function getHtmlId(string $builder_id): string;
84
85  /**
86   * Returns the icon if any.
87   *
88   * @return string
89   *   The icon string.
90   */
91  public function getIcon(): ?string;
92
93  /**
94   * Determine if the Island plugin is applicable.
95   *
96   * @return bool
97   *   TRUE if plugin is applicable, FALSE otherwise.
98   */
99  public function isApplicable(): bool;
100
101  /**
102   * Alter the renderable of the display builder instance.
103   *
104   * @param \Drupal\display_builder\InstanceInterface $instance
105   *   Display builder instance.
106   * @param array $build
107   *   The renderable to alter.
108   *
109   * @return array
110   *   The altered renderable.
111   */
112  public function alterRenderable(InstanceInterface $instance, array $build): array;
113
114}