SelectionTrait.php in Drupal 8
File
core/lib/Drupal/Core/Entity/EntityReferenceSelection/SelectionTrait.php
View source
<?php
namespace Drupal\Core\Entity\EntityReferenceSelection;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Session\AccountInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
@trigger_error(__NAMESPACE__ . '\\SelectionTrait is deprecated in drupal:8.7.0 and will be removed before drupal:9.0.0. A custom constructor must be implemented instead. See https://www.drupal.org/node/3030634', E_USER_DEPRECATED);
trait SelectionTrait {
protected $entityManager;
protected $moduleHandler;
protected $currentUser;
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityManagerInterface $entity_manager, ModuleHandlerInterface $module_handler, AccountInterface $current_user) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->entityManager = $entity_manager;
$this->moduleHandler = $module_handler;
$this->currentUser = $current_user;
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('entity.manager'), $container
->get('module_handler'), $container
->get('current_user'));
}
}
Traits
Name |
Description |
SelectionTrait |
Provides common methods and injects services for core selection handlers. |