From 6dd2f43c32f39acc48b42bae8c05653cefdb011c Mon Sep 17 00:00:00 2001 From: Janez Urevc Date: Sat, 9 Aug 2014 23:52:25 +0200 Subject: [PATCH 1/4] Issue #2318503 by slashrsm: Define basic interfaces. --- src/EntityBrowserDisplayInterface.php | 21 ++++++++++ src/EntityBrowserInterface.php | 40 +++++++++++++++++++ ...EntityBrowserSelectionDisplayInterface.php | 8 ++++ src/EntityBrowserWidgetInterface.php | 8 ++++ src/EntityBrowserWidgetSelectorInterface.php | 15 +++++++ 5 files changed, 92 insertions(+) diff --git a/src/EntityBrowserDisplayInterface.php b/src/EntityBrowserDisplayInterface.php index 2cbc022..1719eb6 100644 --- a/src/EntityBrowserDisplayInterface.php +++ b/src/EntityBrowserDisplayInterface.php @@ -22,4 +22,25 @@ interface EntityBrowserDisplayInterface extends PluginInspectionInterface { */ public function label(); + /** + * Display 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..a9739ae 100644 --- a/src/EntityBrowserInterface.php +++ b/src/EntityBrowserInterface.php @@ -97,4 +97,44 @@ public function getSelectionDisplay(); */ public function getWidgetSelector(); + /** + * Returns entity browser's form representation. + * + * @return array + * Form structure. + */ + public function getForm(); + + /** + * 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..9620f4f 100644 --- a/src/EntityBrowserWidgetSelectorInterface.php +++ b/src/EntityBrowserWidgetSelectorInterface.php @@ -22,4 +22,19 @@ 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 mixed + */ + public function getCurrentWidget(); + } From 4c5ff3585ae9988bf2b2fd59d7c3a8a98c88cdea Mon Sep 17 00:00:00 2001 From: Janez Urevc Date: Mon, 11 Aug 2014 09:51:47 +0200 Subject: [PATCH 2/4] Issue #2318503 by slashrsm: Fix typos. --- src/EntityBrowserDisplayInterface.php | 2 +- src/EntityBrowserWidgetSelectorInterface.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/EntityBrowserDisplayInterface.php b/src/EntityBrowserDisplayInterface.php index 1719eb6..bf7d4e1 100644 --- a/src/EntityBrowserDisplayInterface.php +++ b/src/EntityBrowserDisplayInterface.php @@ -23,7 +23,7 @@ interface EntityBrowserDisplayInterface extends PluginInspectionInterface { public function label(); /** - * Display entity browser. + * 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 diff --git a/src/EntityBrowserWidgetSelectorInterface.php b/src/EntityBrowserWidgetSelectorInterface.php index 9620f4f..d12c61d 100644 --- a/src/EntityBrowserWidgetSelectorInterface.php +++ b/src/EntityBrowserWidgetSelectorInterface.php @@ -33,7 +33,8 @@ public function getForm(); /** * Returns ID of the widget that is currently selected. * - * @return mixed + * @return string + * ID of the currently selected widget. */ public function getCurrentWidget(); From 25e17450474d2c4188053fe055c6b22222bdc7ce Mon Sep 17 00:00:00 2001 From: Janez Urevc Date: Fri, 15 Aug 2014 15:04:29 +0200 Subject: [PATCH 3/4] Issue #2318503 by slashrsm: Extend FormInterface. --- src/EntityBrowserInterface.php | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/EntityBrowserInterface.php b/src/EntityBrowserInterface.php index a9739ae..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,14 +98,6 @@ public function getSelectionDisplay(); */ public function getWidgetSelector(); - /** - * Returns entity browser's form representation. - * - * @return array - * Form structure. - */ - public function getForm(); - /** * Returns currently selected entities. * From 7e3c423f86f38ad38b0353ec0679b980e6046590 Mon Sep 17 00:00:00 2001 From: Janez Urevc Date: Mon, 18 Aug 2014 18:00:46 +0200 Subject: [PATCH 4/4] Issue #2318503 by slashrsm: Add empty functions to prevent fatals. --- src/Entity/EntityBrowser.php | 58 +++++++++++++++++++ .../EntityBrowser/Display/Standalone.php | 15 +++++ .../SelectionDisplay/NoDisplay.php | 7 +++ src/Plugin/EntityBrowser/Widget/View.php | 7 +++ .../EntityBrowser/WidgetSelector/Tabs.php | 15 +++++ 5 files changed, 102 insertions(+) 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/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. + } + }