diff --git a/core/lib/Drupal/Core/Entity/EntityReferenceSelection/SelectionPluginBase.php b/core/lib/Drupal/Core/Entity/EntityReferenceSelection/SelectionPluginBase.php index a550614..68484e1 100644 --- a/core/lib/Drupal/Core/Entity/EntityReferenceSelection/SelectionPluginBase.php +++ b/core/lib/Drupal/Core/Entity/EntityReferenceSelection/SelectionPluginBase.php @@ -4,8 +4,10 @@ use Drupal\Component\Plugin\ConfigurablePluginInterface; use Drupal\Component\Utility\NestedArray; +use Drupal\Core\Database\Query\SelectInterface; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Extension\ModuleHandlerInterface; +use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Plugin\PluginBase; use Drupal\Core\Session\AccountInterface; @@ -122,4 +124,26 @@ public function defaultHandlerSettings() { return []; } + /** + * {@inheritdoc} + */ + public function buildConfigurationForm(array $form, FormStateInterface $form_state) { + return $form; + } + + /** + * {@inheritdoc} + */ + public function validateConfigurationForm(array &$form, FormStateInterface $form_state) { } + + /** + * {@inheritdoc} + */ + public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { } + + /** + * {@inheritdoc} + */ + public function entityQueryAlter(SelectInterface $query) { } + } diff --git a/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/Broken.php b/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/Broken.php index d74fb6e..3686865 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/Broken.php +++ b/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/Broken.php @@ -3,7 +3,7 @@ namespace Drupal\Core\Entity\Plugin\EntityReferenceSelection; use Drupal\Core\Database\Query\SelectInterface; -use Drupal\Core\Entity\EntityReferenceSelection\SelectionInterface; +use Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginBase; use Drupal\Core\Form\FormStateInterface; /** @@ -14,12 +14,13 @@ * label = @Translation("Broken/Missing") * ) */ -class Broken implements SelectionInterface { +class Broken extends SelectionPluginBase { /** * {@inheritdoc} */ public function buildConfigurationForm(array $form, FormStateInterface $form_state) { + $form = parent::buildConfigurationForm($form, $form_state); $form['selection_handler'] = array( '#markup' => t('The selected selection handler is broken.'), ); @@ -29,16 +30,6 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta /** * {@inheritdoc} */ - public function validateConfigurationForm(array &$form, FormStateInterface $form_state) { } - - /** - * {@inheritdoc} - */ - public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { } - - /** - * {@inheritdoc} - */ public function getReferenceableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0) { return array(); } @@ -57,9 +48,4 @@ public function validateReferenceableEntities(array $ids) { return array(); } - /** - * {@inheritdoc} - */ - public function entityQueryAlter(SelectInterface $query) { } - } diff --git a/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php b/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php index b6d8d68..5d25347 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php +++ b/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php @@ -4,7 +4,6 @@ use Drupal\Component\Utility\Html; use Drupal\Core\Database\Query\AlterableInterface; -use Drupal\Core\Database\Query\SelectInterface; use Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginBase; use Drupal\Core\Entity\EntityReferenceSelection\SelectionWithAutocreateInterface; use Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem; @@ -54,6 +53,8 @@ public function defaultHandlerSettings() { * {@inheritdoc} */ public function buildConfigurationForm(array $form, FormStateInterface $form_state) { + $form = parent::buildConfigurationForm($form, $form_state); + $entity_type_id = $this->configuration['target_type']; $selection_handler_settings = $this->configuration['handler_settings']; $entity_type = $this->entityManager->getDefinition($entity_type_id); @@ -186,6 +187,8 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta * {@inheritdoc} */ public function validateConfigurationForm(array &$form, FormStateInterface $form_state) { + parent::validateConfigurationForm($form, $form_state); + // If no checkboxes were checked for 'target_bundles', store NULL ("all // bundles are referenceable") rather than empty array ("no bundle is // referenceable" - typically happens when all referenceable bundles have @@ -200,11 +203,6 @@ public function validateConfigurationForm(array &$form, FormStateInterface $form } /** - * {@inheritdoc} - */ - public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { } - - /** * Form element validation handler; Filters the #value property of an element. */ public static function elementValidateFilter(&$element, FormStateInterface $form_state) { @@ -355,11 +353,6 @@ protected function buildEntityQuery($match = NULL, $match_operator = 'CONTAINS') } /** - * {@inheritdoc} - */ - public function entityQueryAlter(SelectInterface $query) { } - - /** * Helper method: Passes a query to the alteration system again. * * This allows Entity Reference to add a tag to an existing query so it can diff --git a/core/modules/comment/src/Plugin/EntityReferenceSelection/CommentSelection.php b/core/modules/comment/src/Plugin/EntityReferenceSelection/CommentSelection.php index 2492fc4..414c5b2 100644 --- a/core/modules/comment/src/Plugin/EntityReferenceSelection/CommentSelection.php +++ b/core/modules/comment/src/Plugin/EntityReferenceSelection/CommentSelection.php @@ -66,6 +66,8 @@ public function validateReferenceableNewEntities(array $entities) { * {@inheritdoc} */ public function entityQueryAlter(SelectInterface $query) { + parent::entityQueryAlter($query); + $tables = $query->getTables(); $data_table = 'comment_field_data'; if (!isset($tables['comment_field_data']['alias'])) { diff --git a/core/modules/taxonomy/src/Plugin/EntityReferenceSelection/TermSelection.php b/core/modules/taxonomy/src/Plugin/EntityReferenceSelection/TermSelection.php index 3b1c236..028246a 100644 --- a/core/modules/taxonomy/src/Plugin/EntityReferenceSelection/TermSelection.php +++ b/core/modules/taxonomy/src/Plugin/EntityReferenceSelection/TermSelection.php @@ -24,13 +24,6 @@ class TermSelection extends DefaultSelection { /** * {@inheritdoc} */ - public function entityQueryAlter(SelectInterface $query) { - // @todo: How to set access, as vocabulary is now config? - } - - /** - * {@inheritdoc} - */ public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $form = parent::buildConfigurationForm($form, $form_state); diff --git a/core/modules/user/src/Plugin/EntityReferenceSelection/UserSelection.php b/core/modules/user/src/Plugin/EntityReferenceSelection/UserSelection.php index 882465b..2b0e411 100644 --- a/core/modules/user/src/Plugin/EntityReferenceSelection/UserSelection.php +++ b/core/modules/user/src/Plugin/EntityReferenceSelection/UserSelection.php @@ -213,6 +213,8 @@ public function validateReferenceableNewEntities(array $entities) { * {@inheritdoc} */ public function entityQueryAlter(SelectInterface $query) { + parent::entityQueryAlter($query); + // Bail out early if we do not need to match the Anonymous user. $handler_settings = $this->configuration['handler_settings']; if (isset($handler_settings['include_anonymous']) && !$handler_settings['include_anonymous']) { diff --git a/core/modules/views/src/Plugin/EntityReferenceSelection/ViewsSelection.php b/core/modules/views/src/Plugin/EntityReferenceSelection/ViewsSelection.php index 21d45d5..8464b6b 100644 --- a/core/modules/views/src/Plugin/EntityReferenceSelection/ViewsSelection.php +++ b/core/modules/views/src/Plugin/EntityReferenceSelection/ViewsSelection.php @@ -44,6 +44,8 @@ public function defaultHandlerSettings() { * {@inheritdoc} */ public function buildConfigurationForm(array $form, FormStateInterface $form_state) { + $form = parent::buildConfigurationForm($form, $form_state); + $view_settings = $this->getConfiguration()['handler_settings']['view']; $displays = Views::getApplicableViews('entity_reference_display'); // Filter views that list the entity type we want, and group the separate @@ -104,16 +106,6 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta } /** - * {@inheritdoc} - */ - public function validateConfigurationForm(array &$form, FormStateInterface $form_state) { } - - /** - * {@inheritdoc} - */ - public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { } - - /** * Initializes a view. * * @param string|null $match @@ -230,9 +222,4 @@ public static function settingsFormValidate($element, FormStateInterface $form_s $form_state->setValueForElement($element, $value); } - /** - * {@inheritdoc} - */ - public function entityQueryAlter(SelectInterface $query) { } - }