diff --git a/core/lib/Drupal/Core/Entity/EntityReferenceSelection/BasicSelectionPluginBase.php b/core/lib/Drupal/Core/Entity/EntityReferenceSelection/SelectionTrait.php similarity index 86% rename from core/lib/Drupal/Core/Entity/EntityReferenceSelection/BasicSelectionPluginBase.php rename to core/lib/Drupal/Core/Entity/EntityReferenceSelection/SelectionTrait.php index 0fc0f30..16eead0 100644 --- a/core/lib/Drupal/Core/Entity/EntityReferenceSelection/BasicSelectionPluginBase.php +++ b/core/lib/Drupal/Core/Entity/EntityReferenceSelection/SelectionTrait.php @@ -4,17 +4,13 @@ use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Extension\ModuleHandlerInterface; -use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Session\AccountInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** - * Provides a base class for core selection handlers. - * - * This base class extends the base selection plugin by providing a list of - * helpful services by default. + * Provides common methods and inject services for core selection handlers. */ -abstract class BasicSelectionPluginBase extends SelectionPluginBase implements ContainerFactoryPluginInterface { +trait SelectionTrait { /** * The entity manager service. diff --git a/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php b/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php index c84f48b..4064e15 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php +++ b/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php @@ -4,10 +4,12 @@ use Drupal\Component\Utility\Html; use Drupal\Core\Database\Query\AlterableInterface; -use Drupal\Core\Entity\EntityReferenceSelection\BasicSelectionPluginBase; +use Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginBase; +use Drupal\Core\Entity\EntityReferenceSelection\SelectionTrait; use Drupal\Core\Entity\EntityReferenceSelection\SelectionWithAutocreateInterface; use Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\user\EntityOwnerInterface; /** @@ -30,7 +32,9 @@ * deriver = "Drupal\Core\Entity\Plugin\Derivative\DefaultSelectionDeriver" * ) */ -class DefaultSelection extends BasicSelectionPluginBase implements SelectionWithAutocreateInterface { +class DefaultSelection extends SelectionPluginBase implements ContainerFactoryPluginInterface, SelectionWithAutocreateInterface { + + use SelectionTrait; /** * {@inheritdoc} diff --git a/core/modules/views/src/Plugin/EntityReferenceSelection/ViewsSelection.php b/core/modules/views/src/Plugin/EntityReferenceSelection/ViewsSelection.php index 759b1b7..af4c737 100644 --- a/core/modules/views/src/Plugin/EntityReferenceSelection/ViewsSelection.php +++ b/core/modules/views/src/Plugin/EntityReferenceSelection/ViewsSelection.php @@ -2,8 +2,10 @@ namespace Drupal\views\Plugin\EntityReferenceSelection; -use Drupal\Core\Entity\EntityReferenceSelection\BasicSelectionPluginBase; +use Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginBase; +use Drupal\Core\Entity\EntityReferenceSelection\SelectionTrait; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Url; use Drupal\views\Views; @@ -17,7 +19,9 @@ * weight = 0 * ) */ -class ViewsSelection extends BasicSelectionPluginBase { +class ViewsSelection extends SelectionPluginBase implements ContainerFactoryPluginInterface { + + use SelectionTrait; /** * The loaded View object.