From c9b25308c8553bdf533224a0c8ae73a7faf59605 Mon Sep 17 00:00:00 2001
From: webchick <drupal@webchick.net>
Date: Mon, 16 Mar 2015 13:40:52 -0700
Subject: [PATCH] Issue #2452957 by claudiu.cristea: Remove node & taxonomy
 term hardcoding of bundle names in SelectionBase

---
 .../Plugin/EntityReferenceSelection/SelectionBase.php | 11 +----------
 .../Plugin/EntityReferenceSelection/NodeSelection.php | 10 ++++++++++
 .../Plugin/EntityReferenceSelection/TermSelection.php |  1 +
 3 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/SelectionBase.php b/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/SelectionBase.php
index 07ec8cd16cb5..f33fe2ac7d5a 100644
--- a/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/SelectionBase.php
+++ b/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/SelectionBase.php
@@ -124,18 +124,9 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
         $bundle_options[$bundle_name] = $bundle_info['label'];
       }
 
-      $target_bundles_title = $this->t('Bundles');
-      // Default core entity types with sensible labels.
-      if ($entity_type_id == 'node') {
-        $target_bundles_title = $this->t('Content types');
-      }
-      elseif ($entity_type_id == 'taxonomy_term') {
-        $target_bundles_title = $this->t('Vocabularies');
-      }
-
       $form['target_bundles'] = array(
         '#type' => 'checkboxes',
-        '#title' => $target_bundles_title,
+        '#title' => $this->t('Bundles'),
         '#options' => $bundle_options,
         '#default_value' => (!empty($selection_handler_settings['target_bundles'])) ? $selection_handler_settings['target_bundles'] : array(),
         '#required' => TRUE,
diff --git a/core/modules/node/src/Plugin/EntityReferenceSelection/NodeSelection.php b/core/modules/node/src/Plugin/EntityReferenceSelection/NodeSelection.php
index b5db19ab68a1..c2b6f3a09460 100644
--- a/core/modules/node/src/Plugin/EntityReferenceSelection/NodeSelection.php
+++ b/core/modules/node/src/Plugin/EntityReferenceSelection/NodeSelection.php
@@ -8,6 +8,7 @@
 namespace Drupal\node\Plugin\EntityReferenceSelection;
 
 use Drupal\Core\Entity\Plugin\EntityReferenceSelection\SelectionBase;
+use Drupal\Core\Form\FormStateInterface;
 
 /**
  * Provides specific access control for the node entity type.
@@ -22,6 +23,15 @@
  */
 class NodeSelection extends SelectionBase {
 
+  /**
+   * {@inheritdoc}
+   */
+  public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
+    $form = parent::buildConfigurationForm($form, $form_state);
+    $form['target_bundles']['#title'] = $this->t('Content types');
+    return $form;
+  }
+
   /**
    * {@inheritdoc}
    */
diff --git a/core/modules/taxonomy/src/Plugin/EntityReferenceSelection/TermSelection.php b/core/modules/taxonomy/src/Plugin/EntityReferenceSelection/TermSelection.php
index 9bb31b124af1..61281fb992c3 100644
--- a/core/modules/taxonomy/src/Plugin/EntityReferenceSelection/TermSelection.php
+++ b/core/modules/taxonomy/src/Plugin/EntityReferenceSelection/TermSelection.php
@@ -39,6 +39,7 @@ public function entityQueryAlter(SelectInterface $query) {
   public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
     $form = parent::buildConfigurationForm($form, $form_state);
 
+    $form['target_bundles']['#title'] = $this->t('Vocabularies');
     // @todo: Currently allow auto-create only on taxonomy terms.
     $form['auto_create'] = array(
       '#type' => 'checkbox',
-- 
GitLab