3 namespace Drupal\entity_browser;
5 use Drupal\Component\Plugin\ConfigurablePluginInterface;
6 use Drupal\Component\Plugin\PluginInspectionInterface;
7 use Drupal\Core\Form\FormStateInterface;
8 use Drupal\Core\Plugin\PluginFormInterface;
11 * Defines the interface for entity browser widgets.
13 * Entity browser widgets present a form for actually selecting entities in an
14 * entity browser. Once entities have been selected, they are delivered upstream
15 * to the entity browser's selection display plugin.
17 interface WidgetInterface extends PluginInspectionInterface, ConfigurablePluginInterface, PluginFormInterface {
20 * Returns the widget id.
28 * Returns the widget UUID.
33 public function uuid();
36 * Returns the widget label.
41 public function label();
44 * Sets the widget's label.
46 * @param string $label
49 * @return \Drupal\entity_browser\WidgetInterface
52 public function setLabel($label);
55 * Returns the widget's weight.
60 public function getWeight();
63 * Sets the widget's weight.
68 * @return \Drupal\entity_browser\WidgetInterface
71 public function setWeight($weight);
74 * Returns widget form.
76 * @param array $original_form
77 * Entire form bult up to this point. Form elements for widget should generally
78 * not be added directly to it but returned from funciton as a separated
80 * @param \Drupal\Core\Form\FormStateInterface $form_state
82 * @param array $additional_widget_parameters
83 * Additional parameters that we want to pass to the widget.
88 public function getForm(array &$original_form, FormStateInterface $form_state, array $additional_widget_parameters);
95 * @param \Drupal\Core\Form\FormStateInterface $form_state
98 public function validate(array &$form, FormStateInterface $form_state);
103 * @param array $element
104 * Widget part of the form.
107 * @param \Drupal\Core\Form\FormStateInterface $form_state
110 public function submit(array &$element, array &$form, FormStateInterface $form_state);
113 * Returns if widget requires JS commands support by selection display.
116 * True is auto selection is enabled and add/remove of entities will be done
117 * over javascript events on selection display.
119 public function requiresJsCommands();
122 * Defines if the widget is visible / accessible in a given context.
124 * @return \Drupal\Core\Access\AccessResultInterface
127 public function access();