diff --git a/src/Entity/EntityBrowser.php b/src/Entity/EntityBrowser.php index fc61c91..3961bf9 100644 --- a/src/Entity/EntityBrowser.php +++ b/src/Entity/EntityBrowser.php @@ -9,6 +9,7 @@ use Drupal\Core\Config\Entity\ConfigEntityBase; use Drupal\Core\Entity\EntityWithPluginBagsInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\DefaultPluginBag; use Drupal\Core\Plugin\DefaultSinglePluginBag; use Drupal\entity_browser\EntityBrowserInterface; @@ -251,4 +252,61 @@ public function getWidgetSelector() { return $this->widgetSelectorPluginBag()->get($this->widget_selector); } + + /** + * {@inheritdoc} + */ + public function getSelectedEntities() { + // @TODO Implement it. + } + + /** + * {@inheritdoc} + */ + public function setSelectedEntities(array $entities) { + // @TODO Implement it. + } + + /** + * {@inheritdoc} + */ + public function addSelectedEntities(array $entities) { + // @TODO Implement it. + } + + /** + * {@inheritdoc} + */ + public function selectionCompleted() { + // @TODO Implement it. + } + + /** + * {@inheritdoc} + */ + public function getFormId() { + // @TODO Implement it. + } + + /** + * {@inheritdoc} + */ + public function buildForm(array $form, FormStateInterface $form_state) { + // @TODO Implement it. + } + + /** + * {@inheritdoc} + */ + public function validateForm(array &$form, FormStateInterface $form_state) { + // @TODO Implement it. + } + + /** + * {@inheritdoc} + */ + public function submitForm(array &$form, FormStateInterface $form_state) { + // @TODO Implement it. + } + } diff --git a/src/EntityBrowserDisplayInterface.php b/src/EntityBrowserDisplayInterface.php index 2cbc022..bf7d4e1 100644 --- a/src/EntityBrowserDisplayInterface.php +++ b/src/EntityBrowserDisplayInterface.php @@ -22,4 +22,25 @@ interface EntityBrowserDisplayInterface extends PluginInspectionInterface { */ public function label(); + /** + * Displays entity browser. + * + * This is the "entry point" for every non-entity browser code to interact + * with it. It will take care about displaying entity browser in one way or + * another. + * + * @return array + * An array suitable for drupal_render(). + */ + public function displayEntityBrowser(); + + /** + * Indicates completed selection. + * + * Entity browser will call this function when selection is done. Display + * plugin is responsible for fetching selected entities and sending them to + * the initiating code. + */ + public function selectionCompleted(); + } diff --git a/src/EntityBrowserInterface.php b/src/EntityBrowserInterface.php index 164eed7..823c35e 100644 --- a/src/EntityBrowserInterface.php +++ b/src/EntityBrowserInterface.php @@ -8,11 +8,12 @@ namespace Drupal\entity_browser; use Drupal\Core\Config\Entity\ConfigEntityInterface; +use Drupal\Core\Form\FormInterface; /** * Provides an interface defining an entity browser entity. */ -interface EntityBrowserInterface extends ConfigEntityInterface { +interface EntityBrowserInterface extends ConfigEntityInterface, FormInterface { /** * Returns the entity browser name. @@ -97,4 +98,36 @@ public function getSelectionDisplay(); */ public function getWidgetSelector(); + /** + * Returns currently selected entities. + * + * @return array + * Array of currently selected entities. + */ + public function getSelectedEntities(); + + /** + * Sets currently selected entities. + * + * @param array $entities + * Entities that are currently selected. + */ + public function setSelectedEntities(array $entities); + + /** + * Adds entities to currently selected entities. + * + * @param array $entities + * Entities to be added to the list of currently selected entities. + */ + public function addSelectedEntities(array $entities); + + /** + * Indicates completed selection. + * + * Selection process is done and currently selected entities are sent to the + * initiating code. + */ + public function selectionCompleted(); + } diff --git a/src/EntityBrowserSelectionDisplayInterface.php b/src/EntityBrowserSelectionDisplayInterface.php index 53c05b6..f873631 100644 --- a/src/EntityBrowserSelectionDisplayInterface.php +++ b/src/EntityBrowserSelectionDisplayInterface.php @@ -22,4 +22,12 @@ interface EntityBrowserSelectionDisplayInterface extends PluginInspectionInterfa */ public function label(); + /** + * Returns selection display form. + * + * @return array + * Form structure. + */ + public function getForm(); + } diff --git a/src/EntityBrowserWidgetInterface.php b/src/EntityBrowserWidgetInterface.php index c6470b2..c4ff0ca 100644 --- a/src/EntityBrowserWidgetInterface.php +++ b/src/EntityBrowserWidgetInterface.php @@ -30,4 +30,12 @@ public function label(); */ public function getWeight(); + /** + * Returns widget form. + * + * @return array + * Form structure. + */ + public function getForm(); + } diff --git a/src/EntityBrowserWidgetSelectorInterface.php b/src/EntityBrowserWidgetSelectorInterface.php index 6721e8b..d12c61d 100644 --- a/src/EntityBrowserWidgetSelectorInterface.php +++ b/src/EntityBrowserWidgetSelectorInterface.php @@ -22,4 +22,20 @@ interface EntityBrowserWidgetSelectorInterface extends PluginInspectionInterface */ public function label(); + /** + * Returns widget selector form. + * + * @return array + * Form structure. + */ + public function getForm(); + + /** + * Returns ID of the widget that is currently selected. + * + * @return string + * ID of the currently selected widget. + */ + public function getCurrentWidget(); + } diff --git a/src/Plugin/EntityBrowser/Display/Standalone.php b/src/Plugin/EntityBrowser/Display/Standalone.php index d3d90fd..e37b983 100644 --- a/src/Plugin/EntityBrowser/Display/Standalone.php +++ b/src/Plugin/EntityBrowser/Display/Standalone.php @@ -33,4 +33,19 @@ class Standalone extends PluginBase implements EntityBrowserDisplayInterface { public function label() { return $this->label; } + + /** + * {@inheritdoc} + */ + public function displayEntityBrowser() { + // @TODO Implement it. + } + + /** + * {@inheritdoc} + */ + public function selectionCompleted() { + // @TODO Implement it. + } + } diff --git a/src/Plugin/EntityBrowser/SelectionDisplay/NoDisplay.php b/src/Plugin/EntityBrowser/SelectionDisplay/NoDisplay.php index 246898d..ec02aaf 100644 --- a/src/Plugin/EntityBrowser/SelectionDisplay/NoDisplay.php +++ b/src/Plugin/EntityBrowser/SelectionDisplay/NoDisplay.php @@ -34,4 +34,11 @@ public function label() { $this->label; } + /** + * {@inheritdoc} + */ + public function getForm() { + // @TODO Implement it. + } + } diff --git a/src/Plugin/EntityBrowser/Widget/View.php b/src/Plugin/EntityBrowser/Widget/View.php index 9016f4d..d0ff00b 100644 --- a/src/Plugin/EntityBrowser/Widget/View.php +++ b/src/Plugin/EntityBrowser/Widget/View.php @@ -48,4 +48,11 @@ public function getWeight() { return $this->weight; } + /** + * {@inheritdoc} + */ + public function getForm() { + // @TODO Implement it. + } + } diff --git a/src/Plugin/EntityBrowser/WidgetSelector/Tabs.php b/src/Plugin/EntityBrowser/WidgetSelector/Tabs.php index da15b7c..9b42a03 100644 --- a/src/Plugin/EntityBrowser/WidgetSelector/Tabs.php +++ b/src/Plugin/EntityBrowser/WidgetSelector/Tabs.php @@ -33,4 +33,19 @@ class Tabs extends PluginBase implements EntityBrowserWidgetSelectorInterface { public function label() { return $this->label; } + + /** + * {@inheritdoc} + */ + public function getForm() { + // @TODO Implement it. + } + + /** + * {@inheritdoc} + */ + public function getCurrentWidget() { + // @TODO Implement it. + } + }