3 namespace Drupal\entity_browser;
5 use Drupal\Component\Plugin\ConfigurablePluginInterface;
6 use Drupal\Component\Plugin\PluginInspectionInterface;
7 use Drupal\Core\Plugin\PluginFormInterface;
8 use Drupal\Core\Form\FormStateInterface;
11 * Defines the interface for entity browser displays.
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:
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.
20 interface DisplayInterface extends PluginInspectionInterface, ConfigurablePluginInterface, PluginFormInterface {
23 * Returns the display label.
28 public function label();
31 * Displays entity browser.
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
37 * @param array $element
38 * A form element array containing basic properties for the entity browser
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.
58 * An array suitable for drupal_render().
60 public function displayEntityBrowser(array $element, FormStateInterface $form_state, array &$complete_form, array $persistent_data = []);
63 * Indicates completed selection.
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.
69 * @param \Drupal\Core\Entity\EntityInterface[] $entities
70 * Array of selected entities.
72 public function selectionCompleted(array $entities);
75 * Gets the uuid for this display.
80 public function getUuid();
83 * Sets the uuid for this display.
88 public function setUuid($uuid);