Interim commit.
[yaffs-website] / web / modules / contrib / entity_browser / src / DisplayInterface.php
1 <?php
2
3 namespace Drupal\entity_browser;
4
5 use Drupal\Component\Plugin\ConfigurablePluginInterface;
6 use Drupal\Component\Plugin\PluginInspectionInterface;
7 use Drupal\Core\Plugin\PluginFormInterface;
8 use Drupal\Core\Form\FormStateInterface;
9
10 /**
11  * Defines the interface for entity browser displays.
12  *
13  * Display plugins determine how a complete entity browser is delivered to the
14  * user. They wrap around and encapsulate the entity browser. Examples include:
15  *
16  * - Displaying the entity browser on its own standalone page.
17  * - Displaying the entity browser in an iframe.
18  * - Displaying the entity browser in a modal dialog box.
19  */
20 interface DisplayInterface extends PluginInspectionInterface, ConfigurablePluginInterface, PluginFormInterface {
21
22   /**
23    * Returns the display label.
24    *
25    * @return string
26    *   The display label.
27    */
28   public function label();
29
30   /**
31    * Displays entity browser.
32    *
33    * This is the "entry point" for every non-entity browser code to interact
34    * with it. It will take care about displaying entity browser in one way or
35    * another.
36    *
37    * @param array $element
38    *   A form element array containing basic properties for the entity browser
39    *   element:
40    *   - #eb_parents: The 'parents' space for the field in the form.
41    * @param \Drupal\Core\Form\FormStateInterface $form_state
42    *   The form state object.
43    * @param array $complete_form
44    *   The form structure where entity browser is being attached to.
45    * @param array $persistent_data
46    *   (optional) Extra information to send to the Entity Browser Widget. This
47    *   is needed as the widget may display after a new bootstrap, which would
48    *   discard the current form state. Arbitrary values can be added and used
49    *   by widgets, if needed.
50    *   Expected array keys:
51    *     @type \Drupal\Core\Entity\EntityInterface[] $selected_entities
52    *       An array of currently selected entities.
53    *     @type array $validators
54    *       An associative array mapping EntityBrowserWidgetValidation IDs to
55    *       an array of options to pass to the plugin's validate method.
56    *
57    * @return array
58    *   An array suitable for drupal_render().
59    */
60   public function displayEntityBrowser(array $element, FormStateInterface $form_state, array &$complete_form, array $persistent_data = []);
61
62   /**
63    * Indicates completed selection.
64    *
65    * Entity browser will call this function when selection is done. Display
66    * plugin is responsible for fetching selected entities and sending them to
67    * the initiating code.
68    *
69    * @param \Drupal\Core\Entity\EntityInterface[] $entities
70    *   Array of selected entities.
71    */
72   public function selectionCompleted(array $entities);
73
74   /**
75    * Gets the uuid for this display.
76    *
77    * @return string
78    *   The uuid string.
79    */
80   public function getUuid();
81
82   /**
83    * Sets the uuid for this display.
84    *
85    * @param string $uuid
86    *   The uuid string.
87    */
88   public function setUuid($uuid);
89
90 }