From 12d7ed53087a469ef8f87476c2849f7b24bfbbb7 Mon Sep 17 00:00:00 2001 From: Lee Rowlands <lee.rowlands@previousnext.com.au> Date: Thu, 11 Apr 2019 18:51:08 +1000 Subject: [PATCH] Issue #3042545 by Berdir, martin107: Update last injected entity managers --- .../Core/Action/Plugin/Action/EmailAction.php | 8 ++--- .../Plugin/DataType/Deriver/EntityDeriver.php | 25 ++++++++----- .../Derivative/DefaultSelectionDeriver.php | 27 ++++++++------ .../src/Plugin/views/argument/Fid.php | 27 ++++++++------ .../src/Plugin/views/argument/Iid.php | 25 ++++++++----- core/modules/block/src/BlockForm.php | 15 +++++--- .../src/Plugin/migrate/source/d7/Color.php | 13 +++++-- core/modules/field/src/FieldConfigStorage.php | 23 +++++++----- .../field/src/FieldStorageConfigStorage.php | 23 +++++++----- .../field_ui/src/FieldUiPermissions.php | 27 ++++++++------ .../Plugin/Derivative/FieldUiLocalAction.php | 27 ++++++++------ .../file/src/Plugin/views/argument/Fid.php | 27 ++++++++------ core/modules/filter/src/FilterPermissions.php | 25 ++++++++----- .../LanguageNegotiationContentEntity.php | 25 ++++++++----- .../Plugin/Deriver/MenuLinkContentDeriver.php | 29 +++++++++------ .../Plugin/migrate/source/DrupalSqlBase.php | 21 +++++++---- .../src/Plugin/migrate/source/EmptySource.php | 23 +++++++----- .../src/Plugin/migrate/source/Variable.php | 6 ++-- .../migrate/source/d6/VariableTranslation.php | 6 ++-- .../migrate/source/d7/VariableTranslation.php | 6 ++-- .../node/src/Plugin/Search/NodeSearch.php | 35 +++++++++++-------- .../src/Plugin/migrate/source/d6/Node.php | 6 ++-- .../src/Plugin/migrate/source/d7/Node.php | 6 ++-- .../rest/src/Plugin/Deriver/EntityDeriver.php | 25 ++++++++----- .../taxonomy/src/TaxonomyPermissions.php | 23 +++++++----- .../src/Form/UserMultipleCancelConfirm.php | 29 +++++++++------ .../user/src/Plugin/Search/UserSearch.php | 27 ++++++++------ .../src/Plugin/views/argument/RolesRid.php | 10 +++--- .../src/Plugin/views/field/Permissions.php | 10 +++--- .../ViewsEntityArgumentValidator.php | 27 ++++++++------ .../src/Plugin/Derivative/ViewsEntityRow.php | 27 ++++++++------ .../views/src/Plugin/Menu/ViewsMenuLink.php | 25 ++++++++----- .../views/src/Plugin/views/display/Block.php | 25 ++++++++----- .../views/src/Plugin/views/filter/Bundle.php | 27 ++++++++------ 34 files changed, 446 insertions(+), 264 deletions(-) diff --git a/core/lib/Drupal/Core/Action/Plugin/Action/EmailAction.php b/core/lib/Drupal/Core/Action/Plugin/Action/EmailAction.php index 0f8a4575febf..4fe6bc757cd4 100644 --- a/core/lib/Drupal/Core/Action/Plugin/Action/EmailAction.php +++ b/core/lib/Drupal/Core/Action/Plugin/Action/EmailAction.php @@ -6,7 +6,7 @@ use Drupal\Component\Utility\EmailValidatorInterface; use Drupal\Core\Access\AccessResult; use Drupal\Core\Action\ConfigurableActionBase; -use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageManagerInterface; use Drupal\Core\Mail\MailManagerInterface; @@ -80,7 +80,7 @@ class EmailAction extends ConfigurableActionBase implements ContainerFactoryPlug * The plugin implementation definition. * @param \Drupal\Core\Utility\Token $token * The token service. - * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager + * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager * The entity manager. * @param \Psr\Log\LoggerInterface $logger * A logger instance. @@ -91,11 +91,11 @@ class EmailAction extends ConfigurableActionBase implements ContainerFactoryPlug * @param \Drupal\Component\Utility\EmailValidatorInterface $email_validator * The email validator. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, Token $token, EntityManagerInterface $entity_manager, LoggerInterface $logger, MailManagerInterface $mail_manager, LanguageManagerInterface $language_manager, EmailValidatorInterface $email_validator) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, Token $token, EntityTypeManagerInterface $entity_type_manager, LoggerInterface $logger, MailManagerInterface $mail_manager, LanguageManagerInterface $language_manager, EmailValidatorInterface $email_validator) { parent::__construct($configuration, $plugin_id, $plugin_definition); $this->token = $token; - $this->storage = $entity_manager->getStorage('user'); + $this->storage = $entity_type_manager->getStorage('user'); $this->logger = $logger; $this->mailManager = $mail_manager; $this->languageManager = $language_manager; diff --git a/core/lib/Drupal/Core/Entity/Plugin/DataType/Deriver/EntityDeriver.php b/core/lib/Drupal/Core/Entity/Plugin/DataType/Deriver/EntityDeriver.php index 38ac960cc17a..faca77bd219d 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/DataType/Deriver/EntityDeriver.php +++ b/core/lib/Drupal/Core/Entity/Plugin/DataType/Deriver/EntityDeriver.php @@ -3,7 +3,8 @@ namespace Drupal\Core\Entity\Plugin\DataType\Deriver; use Drupal\Core\Config\Entity\ConfigEntityInterface; -use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Entity\EntityTypeBundleInfoInterface; use Drupal\Core\Entity\Plugin\DataType\ConfigEntityAdapter; use Drupal\Core\Entity\Plugin\DataType\EntityAdapter; @@ -14,6 +15,12 @@ * Provides data type plugins for each existing entity type and bundle. */ class EntityDeriver implements ContainerDeriverInterface { + use DeprecatedServicePropertyTrait; + + /** + * {@inheritdoc} + */ + protected $deprecatedProperties = ['entityManager' => 'entity.manager']; /** * List of derivative definitions. @@ -30,11 +37,11 @@ class EntityDeriver implements ContainerDeriverInterface { protected $basePluginId; /** - * The entity manager. + * The entity type manager. * - * @var \Drupal\Core\Entity\EntityManagerInterface + * @var \Drupal\Core\Entity\EntityTypeManagerInterface */ - protected $entityManager; + protected $entityTypeManager; /** * The bundle info service. @@ -48,12 +55,12 @@ class EntityDeriver implements ContainerDeriverInterface { * * @param string $base_plugin_id * The base plugin ID. - * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager - * The entity manager. + * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager + * The entity type manager. */ - public function __construct($base_plugin_id, EntityManagerInterface $entity_manager, EntityTypeBundleInfoInterface $bundle_info_service) { + public function __construct($base_plugin_id, EntityTypeManagerInterface $entity_type_manager, EntityTypeBundleInfoInterface $bundle_info_service) { $this->basePluginId = $base_plugin_id; - $this->entityManager = $entity_manager; + $this->entityTypeManager = $entity_type_manager; $this->bundleInfoService = $bundle_info_service; } @@ -88,7 +95,7 @@ public function getDerivativeDefinitions($base_plugin_definition) { // Also keep the 'entity' defined as is. $this->derivatives[''] = $base_plugin_definition; // Add definitions for each entity type and bundle. - foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) { + foreach ($this->entityTypeManager->getDefinitions() as $entity_type_id => $entity_type) { $class = $entity_type->entityClassImplements(ConfigEntityInterface::class) ? ConfigEntityAdapter::class : EntityAdapter::class; $this->derivatives[$entity_type_id] = [ 'class' => $class, diff --git a/core/lib/Drupal/Core/Entity/Plugin/Derivative/DefaultSelectionDeriver.php b/core/lib/Drupal/Core/Entity/Plugin/Derivative/DefaultSelectionDeriver.php index d8d21fdbef2f..ae58b864001e 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/Derivative/DefaultSelectionDeriver.php +++ b/core/lib/Drupal/Core/Entity/Plugin/Derivative/DefaultSelectionDeriver.php @@ -3,7 +3,8 @@ namespace Drupal\Core\Entity\Plugin\Derivative; use Drupal\Component\Plugin\Derivative\DeriverBase; -use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -17,22 +18,28 @@ * @see plugin_api */ class DefaultSelectionDeriver extends DeriverBase implements ContainerDeriverInterface { + use DeprecatedServicePropertyTrait; /** - * The entity manager + * {@inheritdoc} + */ + protected $deprecatedProperties = ['entityManager' => 'entity.manager']; + + /** + * The entity type manager. * - * @var \Drupal\Core\Entity\EntityManagerInterface + * @var \Drupal\Core\Entity\EntityTypeManagerInterface */ - protected $entityManager; + protected $entityTypeManager; /** * Creates an SelectionBase object. * - * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager - * The entity manager. + * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager + * The entity type manager. */ - public function __construct(EntityManagerInterface $entity_manager) { - $this->entityManager = $entity_manager; + public function __construct(EntityTypeManagerInterface $entity_type_manager) { + $this->entityTypeManager = $entity_type_manager; } /** @@ -40,7 +47,7 @@ public function __construct(EntityManagerInterface $entity_manager) { */ public static function create(ContainerInterface $container, $base_plugin_id) { return new static( - $container->get('entity.manager') + $container->get('entity_type.manager') ); } @@ -48,7 +55,7 @@ public static function create(ContainerInterface $container, $base_plugin_id) { * {@inheritdoc} */ public function getDerivativeDefinitions($base_plugin_definition) { - foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) { + foreach ($this->entityTypeManager->getDefinitions() as $entity_type_id => $entity_type) { $this->derivatives[$entity_type_id] = $base_plugin_definition; $this->derivatives[$entity_type_id]['entity_types'] = [$entity_type_id]; $this->derivatives[$entity_type_id]['label'] = t('@entity_type selection', ['@entity_type' => $entity_type->getLabel()]); diff --git a/core/modules/aggregator/src/Plugin/views/argument/Fid.php b/core/modules/aggregator/src/Plugin/views/argument/Fid.php index 2e4cb7488674..9466e86dba1b 100644 --- a/core/modules/aggregator/src/Plugin/views/argument/Fid.php +++ b/core/modules/aggregator/src/Plugin/views/argument/Fid.php @@ -2,7 +2,8 @@ namespace Drupal\aggregator\Plugin\views\argument; -use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\views\Plugin\views\argument\NumericArgument; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -14,13 +15,19 @@ * @ViewsArgument("aggregator_fid") */ class Fid extends NumericArgument { + use DeprecatedServicePropertyTrait; /** - * The entity manager service. + * {@inheritdoc} + */ + protected $deprecatedProperties = ['entityManager' => 'entity.manager']; + + /** + * The entity type manager. * - * @var \Drupal\Core\Entity\EntityManagerInterface + * @var \Drupal\Core\Entity\EntityTypeManagerInterface */ - protected $entityManager; + protected $entityTypeManager; /** * Constructs a \Drupal\aggregator\Plugin\views\argument\Fid object. @@ -31,19 +38,19 @@ class Fid extends NumericArgument { * The plugin_id for the plugin instance. * @param mixed $plugin_definition * The plugin implementation definition. - * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager - * The entity manager. + * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_manager + * The entity type manager. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityManagerInterface $entity_manager) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_manager) { parent::__construct($configuration, $plugin_id, $plugin_definition); - $this->entityManager = $entity_manager; + $this->entityTypeManager = $entity_manager; } /** * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { - return new static($configuration, $plugin_id, $plugin_definition, $container->get('entity.manager')); + return new static($configuration, $plugin_id, $plugin_definition, $container->get('entity_type.manager')); } /** @@ -52,7 +59,7 @@ public static function create(ContainerInterface $container, array $configuratio public function titleQuery() { $titles = []; - $feeds = $this->entityManager->getStorage('aggregator_feed')->loadMultiple($this->value); + $feeds = $this->entityTypeManager->getStorage('aggregator_feed')->loadMultiple($this->value); foreach ($feeds as $feed) { $titles[] = $feed->label(); } diff --git a/core/modules/aggregator/src/Plugin/views/argument/Iid.php b/core/modules/aggregator/src/Plugin/views/argument/Iid.php index 4f4e79a8de17..4a51897b2215 100644 --- a/core/modules/aggregator/src/Plugin/views/argument/Iid.php +++ b/core/modules/aggregator/src/Plugin/views/argument/Iid.php @@ -2,7 +2,8 @@ namespace Drupal\aggregator\Plugin\views\argument; -use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\views\Plugin\views\argument\NumericArgument; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -14,13 +15,19 @@ * @ViewsArgument("aggregator_iid") */ class Iid extends NumericArgument { + use DeprecatedServicePropertyTrait; /** - * The entity manager service. + * {@inheritdoc} + */ + protected $deprecatedProperties = ['entityManager' => 'entity.manager']; + + /** + * The entity type manager. * - * @var \Drupal\Core\Entity\EntityManagerInterface + * @var \Drupal\Core\Entity\EntityTypeManagerInterface */ - protected $entityManager; + protected $entityTypeManager; /** * Constructs a \Drupal\aggregator\Plugin\views\argument\Iid object. @@ -31,12 +38,12 @@ class Iid extends NumericArgument { * The plugin_id for the plugin instance. * @param mixed $plugin_definition * The plugin implementation definition. - * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager - * The entity manager. + * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager + * The entity type manager. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityManagerInterface $entity_manager) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager) { parent::__construct($configuration, $plugin_id, $plugin_definition); - $this->entityManager = $entity_manager; + $this->entityTypeManager = $entity_type_manager; } /** @@ -52,7 +59,7 @@ public static function create(ContainerInterface $container, array $configuratio public function titleQuery() { $titles = []; - $items = $this->entityManager->getStorage('aggregator_item')->loadMultiple($this->value); + $items = $this->entityTypeManager->getStorage('aggregator_item')->loadMultiple($this->value); foreach ($items as $feed) { $titles[] = $feed->label(); } diff --git a/core/modules/block/src/BlockForm.php b/core/modules/block/src/BlockForm.php index 6998a64d4691..5dc017fde1f6 100644 --- a/core/modules/block/src/BlockForm.php +++ b/core/modules/block/src/BlockForm.php @@ -3,10 +3,11 @@ namespace Drupal\block; use Drupal\Component\Utility\Html; +use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait; use Drupal\Core\Plugin\PluginFormFactoryInterface; use Drupal\Core\Block\BlockPluginInterface; use Drupal\Core\Entity\EntityForm; -use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Executable\ExecutableManagerInterface; use Drupal\Core\Extension\ThemeHandlerInterface; use Drupal\Core\Form\FormStateInterface; @@ -23,6 +24,12 @@ * @internal */ class BlockForm extends EntityForm { + use DeprecatedServicePropertyTrait; + + /** + * {@inheritdoc} + */ + protected $deprecatedProperties = ['entityManager' => 'entity.manager']; /** * The block entity. @@ -76,7 +83,7 @@ class BlockForm extends EntityForm { /** * Constructs a BlockForm object. * - * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager + * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager * The entity manager. * @param \Drupal\Core\Executable\ExecutableManagerInterface $manager * The ConditionManager for building the visibility UI. @@ -89,8 +96,8 @@ class BlockForm extends EntityForm { * @param \Drupal\Core\Plugin\PluginFormFactoryInterface $plugin_form_manager * The plugin form manager. */ - public function __construct(EntityManagerInterface $entity_manager, ExecutableManagerInterface $manager, ContextRepositoryInterface $context_repository, LanguageManagerInterface $language, ThemeHandlerInterface $theme_handler, PluginFormFactoryInterface $plugin_form_manager) { - $this->storage = $entity_manager->getStorage('block'); + public function __construct(EntityTypeManagerInterface $entity_type_manager, ExecutableManagerInterface $manager, ContextRepositoryInterface $context_repository, LanguageManagerInterface $language, ThemeHandlerInterface $theme_handler, PluginFormFactoryInterface $plugin_form_manager) { + $this->storage = $entity_type_manager->getStorage('block'); $this->manager = $manager; $this->contextRepository = $context_repository; $this->language = $language; diff --git a/core/modules/color/src/Plugin/migrate/source/d7/Color.php b/core/modules/color/src/Plugin/migrate/source/d7/Color.php index e713f0e27645..94f0867f245e 100644 --- a/core/modules/color/src/Plugin/migrate/source/d7/Color.php +++ b/core/modules/color/src/Plugin/migrate/source/d7/Color.php @@ -2,10 +2,11 @@ namespace Drupal\color\Plugin\migrate\source\d7; +use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait; use Drupal\Core\Extension\ThemeHandler; use Drupal\migrate\Row; use Drupal\migrate_drupal\Plugin\migrate\source\VariableMultiRow; -use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\State\StateInterface; use Drupal\migrate\Plugin\MigrationInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -19,6 +20,12 @@ * ) */ class Color extends VariableMultiRow { + use DeprecatedServicePropertyTrait; + + /** + * {@inheritdoc} + */ + protected $deprecatedProperties = ['entityManager' => 'entity.manager']; /** * The theme handler. @@ -30,8 +37,8 @@ class Color extends VariableMultiRow { /** * {@inheritdoc} */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, StateInterface $state, EntityManagerInterface $entity_manager, ThemeHandler $theme_handler) { - parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $state, $entity_manager); + public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, StateInterface $state, EntityTypeManagerInterface $entity_type_manager, ThemeHandler $theme_handler) { + parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $state, $entity_type_manager); $this->themeHandler = $theme_handler; } diff --git a/core/modules/field/src/FieldConfigStorage.php b/core/modules/field/src/FieldConfigStorage.php index 2794674bddb9..d9f545b68cd3 100644 --- a/core/modules/field/src/FieldConfigStorage.php +++ b/core/modules/field/src/FieldConfigStorage.php @@ -4,7 +4,8 @@ use Drupal\Core\Cache\MemoryCache\MemoryCacheInterface; use Drupal\Core\Config\Config; -use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Field\DeletedFieldsRepositoryInterface; use Drupal\Core\Field\FieldConfigStorageBase; @@ -18,13 +19,19 @@ * Storage handler for field config. */ class FieldConfigStorage extends FieldConfigStorageBase { + use DeprecatedServicePropertyTrait; /** - * The entity manager. + * {@inheritdoc} + */ + protected $deprecatedProperties = ['entityManager' => 'entity.manager']; + + /** + * The entity type manager. * - * @var \Drupal\Core\Entity\EntityManagerInterface + * @var \Drupal\Core\Entity\EntityTypeManagerInterface */ - protected $entityManager; + protected $entityTypeManager; /** * The field type plugin manager. @@ -51,8 +58,8 @@ class FieldConfigStorage extends FieldConfigStorageBase { * The UUID service. * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager * The language manager. - * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager - * The entity manager. + * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager + * The entity type manager. * @param \Drupal\Core\Field\FieldTypePluginManagerInterface $field_type_manager * The field type plugin manager. * @param \Drupal\Core\Field\DeletedFieldsRepositoryInterface $deleted_fields_repository @@ -60,9 +67,9 @@ class FieldConfigStorage extends FieldConfigStorageBase { * @param \Drupal\Core\Cache\MemoryCache\MemoryCacheInterface $memory_cache * The memory cache. */ - public function __construct(EntityTypeInterface $entity_type, ConfigFactoryInterface $config_factory, UuidInterface $uuid_service, LanguageManagerInterface $language_manager, EntityManagerInterface $entity_manager, FieldTypePluginManagerInterface $field_type_manager, DeletedFieldsRepositoryInterface $deleted_fields_repository, MemoryCacheInterface $memory_cache) { + public function __construct(EntityTypeInterface $entity_type, ConfigFactoryInterface $config_factory, UuidInterface $uuid_service, LanguageManagerInterface $language_manager, EntityTypeManagerInterface $entity_type_manager, FieldTypePluginManagerInterface $field_type_manager, DeletedFieldsRepositoryInterface $deleted_fields_repository, MemoryCacheInterface $memory_cache) { parent::__construct($entity_type, $config_factory, $uuid_service, $language_manager, $memory_cache); - $this->entityManager = $entity_manager; + $this->entityTypeManager = $entity_type_manager; $this->fieldTypeManager = $field_type_manager; $this->deletedFieldsRepository = $deleted_fields_repository; } diff --git a/core/modules/field/src/FieldStorageConfigStorage.php b/core/modules/field/src/FieldStorageConfigStorage.php index 4d23c9eedbb8..dab6c6990b31 100644 --- a/core/modules/field/src/FieldStorageConfigStorage.php +++ b/core/modules/field/src/FieldStorageConfigStorage.php @@ -5,8 +5,9 @@ use Drupal\Component\Uuid\UuidInterface; use Drupal\Core\Cache\MemoryCache\MemoryCacheInterface; use Drupal\Core\Config\Entity\ConfigEntityStorage; +use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait; use Drupal\Core\Entity\EntityInterface; -use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Field\DeletedFieldsRepositoryInterface; use Drupal\Core\Field\FieldTypePluginManagerInterface; @@ -19,6 +20,12 @@ * Storage handler for "field storage" configuration entities. */ class FieldStorageConfigStorage extends ConfigEntityStorage { + use DeprecatedServicePropertyTrait; + + /** + * {@inheritdoc} + */ + protected $deprecatedProperties = ['entityManager' => 'entity.manager']; /** * The module handler. @@ -28,11 +35,11 @@ class FieldStorageConfigStorage extends ConfigEntityStorage { protected $moduleHandler; /** - * The entity manager. + * The entity type manager. * - * @var \Drupal\Core\Entity\EntityManagerInterface + * @var \Drupal\Core\Entity\EntityTypeManagerInterface */ - protected $entityManager; + protected $entityTypeManager; /** * The field type plugin manager. @@ -59,8 +66,8 @@ class FieldStorageConfigStorage extends ConfigEntityStorage { * The UUID service. * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager * The language manager. - * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager - * The entity manager. + * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager + * The entity type manager. * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler. * @param \Drupal\Core\Field\FieldTypePluginManagerInterface $field_type_manager @@ -70,9 +77,9 @@ class FieldStorageConfigStorage extends ConfigEntityStorage { * @param \Drupal\Core\Cache\MemoryCache\MemoryCacheInterface $memory_cache * The memory cache. */ - public function __construct(EntityTypeInterface $entity_type, ConfigFactoryInterface $config_factory, UuidInterface $uuid_service, LanguageManagerInterface $language_manager, EntityManagerInterface $entity_manager, ModuleHandlerInterface $module_handler, FieldTypePluginManagerInterface $field_type_manager, DeletedFieldsRepositoryInterface $deleted_fields_repository, MemoryCacheInterface $memory_cache) { + public function __construct(EntityTypeInterface $entity_type, ConfigFactoryInterface $config_factory, UuidInterface $uuid_service, LanguageManagerInterface $language_manager, EntityTypeManagerInterface $entity_type_manager, ModuleHandlerInterface $module_handler, FieldTypePluginManagerInterface $field_type_manager, DeletedFieldsRepositoryInterface $deleted_fields_repository, MemoryCacheInterface $memory_cache) { parent::__construct($entity_type, $config_factory, $uuid_service, $language_manager, $memory_cache); - $this->entityManager = $entity_manager; + $this->entityTypeManager = $entity_type_manager; $this->moduleHandler = $module_handler; $this->fieldTypeManager = $field_type_manager; $this->deletedFieldsRepository = $deleted_fields_repository; diff --git a/core/modules/field_ui/src/FieldUiPermissions.php b/core/modules/field_ui/src/FieldUiPermissions.php index a127fcc71b9b..553b7d6e962f 100644 --- a/core/modules/field_ui/src/FieldUiPermissions.php +++ b/core/modules/field_ui/src/FieldUiPermissions.php @@ -3,7 +3,8 @@ namespace Drupal\field_ui; use Drupal\Core\DependencyInjection\ContainerInjectionInterface; -use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -13,29 +14,35 @@ class FieldUiPermissions implements ContainerInjectionInterface { use StringTranslationTrait; + use DeprecatedServicePropertyTrait; /** - * The entity manager. + * {@inheritdoc} + */ + protected $deprecatedProperties = ['entityManager' => 'entity.manager']; + + /** + * The entity type manager. * - * @var \Drupal\Core\Entity\EntityManagerInterface + * @var \Drupal\Core\Entity\EntityTypeManagerInterface */ - protected $entityManager; + protected $entityTypeManager; /** * Constructs a new FieldUiPermissions instance. * - * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager - * The entity manager. + * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager + * The entity type manager. */ - public function __construct(EntityManagerInterface $entity_manager) { - $this->entityManager = $entity_manager; + public function __construct(EntityTypeManagerInterface $entity_type_manager) { + $this->entityTypeManager = $entity_type_manager; } /** * {@inheritdoc} */ public static function create(ContainerInterface $container) { - return new static($container->get('entity.manager')); + return new static($container->get('entity_type.manager')); } /** @@ -46,7 +53,7 @@ public static function create(ContainerInterface $container) { public function fieldPermissions() { $permissions = []; - foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) { + foreach ($this->entityTypeManager->getDefinitions() as $entity_type_id => $entity_type) { if ($entity_type->get('field_ui_base_route')) { // Create a permission for each fieldable entity to manage // the fields and the display. diff --git a/core/modules/field_ui/src/Plugin/Derivative/FieldUiLocalAction.php b/core/modules/field_ui/src/Plugin/Derivative/FieldUiLocalAction.php index b92d702590dd..59310f27e060 100644 --- a/core/modules/field_ui/src/Plugin/Derivative/FieldUiLocalAction.php +++ b/core/modules/field_ui/src/Plugin/Derivative/FieldUiLocalAction.php @@ -3,7 +3,8 @@ namespace Drupal\field_ui\Plugin\Derivative; use Drupal\Component\Plugin\Derivative\DeriverBase; -use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface; use Drupal\Core\Routing\RouteProviderInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; @@ -15,25 +16,31 @@ class FieldUiLocalAction extends DeriverBase implements ContainerDeriverInterface { use StringTranslationTrait; + use DeprecatedServicePropertyTrait; /** - * The entity manager + * {@inheritdoc} + */ + protected $deprecatedProperties = ['entityManager' => 'entity.manager']; + + /** + * The entity type manager. * - * @var \Drupal\Core\Entity\EntityManagerInterface + * @var \Drupal\Core\Entity\EntityTypeManagerInterface */ - protected $entityManager; + protected $entityTypeManager; /** * Constructs a FieldUiLocalAction object. * * @param \Drupal\Core\Routing\RouteProviderInterface $route_provider * The route provider to load routes by name. - * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager - * The entity manager. + * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_manager + * The entity type manager. */ - public function __construct(RouteProviderInterface $route_provider, EntityManagerInterface $entity_manager) { + public function __construct(RouteProviderInterface $route_provider, EntityTypeManagerInterface $entity_manager) { $this->routeProvider = $route_provider; - $this->entityManager = $entity_manager; + $this->entityTypeManager = $entity_manager; } /** @@ -42,7 +49,7 @@ public function __construct(RouteProviderInterface $route_provider, EntityManage public static function create(ContainerInterface $container, $base_plugin_id) { return new static( $container->get('router.route_provider'), - $container->get('entity.manager') + $container->get('entity_type.manager') ); } @@ -52,7 +59,7 @@ public static function create(ContainerInterface $container, $base_plugin_id) { public function getDerivativeDefinitions($base_plugin_definition) { $this->derivatives = []; - foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) { + foreach ($this->entityTypeManager->getDefinitions() as $entity_type_id => $entity_type) { if ($entity_type->get('field_ui_base_route')) { $this->derivatives["field_storage_config_add_$entity_type_id"] = [ 'route_name' => "field_ui.field_storage_config_add_$entity_type_id", diff --git a/core/modules/file/src/Plugin/views/argument/Fid.php b/core/modules/file/src/Plugin/views/argument/Fid.php index 1654fcc2e3e5..87e3e289b1f7 100644 --- a/core/modules/file/src/Plugin/views/argument/Fid.php +++ b/core/modules/file/src/Plugin/views/argument/Fid.php @@ -2,7 +2,8 @@ namespace Drupal\file\Plugin\views\argument; -use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\views\Plugin\views\argument\NumericArgument; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -15,13 +16,19 @@ * @ViewsArgument("file_fid") */ class Fid extends NumericArgument implements ContainerFactoryPluginInterface { + use DeprecatedServicePropertyTrait; /** - * The entity manager service + * {@inheritdoc} + */ + protected $deprecatedProperties = ['entityManager' => 'entity.manager']; + + /** + * The entity type manager. * - * @var \Drupal\Core\Entity\EntityManagerInterface + * @var \Drupal\Core\Entity\EntityTypeManagerInterface */ - protected $entityManager; + protected $entityTypeManager; /** * Constructs a Drupal\file\Plugin\views\argument\Fid object. @@ -32,12 +39,12 @@ class Fid extends NumericArgument implements ContainerFactoryPluginInterface { * The plugin_id for the plugin instance. * @param mixed $plugin_definition * The plugin implementation definition. - * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager - * The entity manager. + * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager + * The entity type manager. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityManagerInterface $entity_manager) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager) { parent::__construct($configuration, $plugin_id, $plugin_definition); - $this->entityManager = $entity_manager; + $this->entityTypeManager = $entity_type_manager; } /** @@ -48,7 +55,7 @@ public static function create(ContainerInterface $container, array $configuratio $configuration, $plugin_id, $plugin_definition, - $container->get('entity.manager') + $container->get('entity_type.manager') ); } @@ -56,7 +63,7 @@ public static function create(ContainerInterface $container, array $configuratio * Override the behavior of titleQuery(). Get the filenames. */ public function titleQuery() { - $storage = $this->entityManager->getStorage('file'); + $storage = $this->entityTypeManager->getStorage('file'); $fids = $storage->getQuery() ->condition('fid', $this->value, 'IN') ->execute(); diff --git a/core/modules/filter/src/FilterPermissions.php b/core/modules/filter/src/FilterPermissions.php index 7002bb27c117..ea9b0aeeb995 100644 --- a/core/modules/filter/src/FilterPermissions.php +++ b/core/modules/filter/src/FilterPermissions.php @@ -3,7 +3,8 @@ namespace Drupal\filter; use Drupal\Core\DependencyInjection\ContainerInjectionInterface; -use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -13,22 +14,28 @@ class FilterPermissions implements ContainerInjectionInterface { use StringTranslationTrait; + use DeprecatedServicePropertyTrait; /** - * The entity manager. + * {@inheritdoc} + */ + protected $deprecatedProperties = ['entityManager' => 'entity.manager']; + + /** + * The entity type manager. * - * @var \Drupal\Core\Entity\EntityManagerInterface + * @var \Drupal\Core\Entity\EntityTypeManagerInterface */ - protected $entityManager; + protected $entityTypeManager; /** * Constructs a new FilterPermissions instance. * - * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager - * The entity manager. + * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager + * The entity type manager. */ - public function __construct(EntityManagerInterface $entity_manager) { - $this->entityManager = $entity_manager; + public function __construct(EntityTypeManagerInterface $entity_type_manager) { + $this->entityTypeManager = $entity_type_manager; } /** @@ -48,7 +55,7 @@ public function permissions() { // Generate permissions for each text format. Warn the administrator that any // of them are potentially unsafe. /** @var \Drupal\filter\FilterFormatInterface[] $formats */ - $formats = $this->entityManager->getStorage('filter_format')->loadByProperties(['status' => TRUE]); + $formats = $this->entityTypeManager->getStorage('filter_format')->loadByProperties(['status' => TRUE]); uasort($formats, 'Drupal\Core\Config\Entity\ConfigEntityBase::sort'); foreach ($formats as $format) { if ($permission = $format->getPermissionName()) { diff --git a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationContentEntity.php b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationContentEntity.php index 9218899b1ca9..e99a4013584b 100644 --- a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationContentEntity.php +++ b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationContentEntity.php @@ -2,8 +2,9 @@ namespace Drupal\language\Plugin\LanguageNegotiation; +use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait; use Drupal\Core\Entity\ContentEntityInterface; -use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\PathProcessor\OutboundPathProcessorInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Render\BubbleableMetadata; @@ -27,6 +28,12 @@ * ) */ class LanguageNegotiationContentEntity extends LanguageNegotiationMethodBase implements OutboundPathProcessorInterface, LanguageSwitcherInterface, ContainerFactoryPluginInterface { + use DeprecatedServicePropertyTrait; + + /** + * {@inheritdoc} + */ + protected $deprecatedProperties = ['entityManager' => 'entity.manager']; /** * The language negotiation method ID. @@ -62,20 +69,20 @@ class LanguageNegotiationContentEntity extends LanguageNegotiationMethodBase imp protected $paths; /** - * The entity manager. + * The entity type manager. * - * @var \Drupal\Core\Entity\EntityManagerInterface + * @var \Drupal\Core\Entity\EntityTypeManagerInterface */ - protected $entityManager; + protected $entityTypeManager; /** * Constructs a new LanguageNegotiationContentEntity instance. * - * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager - * The entity manager. + * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager + * The entity type manager. */ - public function __construct(EntityManagerInterface $entity_manager) { - $this->entityManager = $entity_manager; + public function __construct(EntityTypeManagerInterface $entity_type_manager) { + $this->entityTypeManager = $entity_type_manager; $this->paths = new \SplObjectStorage(); } @@ -261,7 +268,7 @@ protected function getContentEntityTypeIdForCurrentRequest(Request $request) { protected function getContentEntityPaths() { if (!isset($this->contentEntityPaths)) { $this->contentEntityPaths = []; - $entity_types = $this->entityManager->getDefinitions(); + $entity_types = $this->entityTypeManager->getDefinitions(); foreach ($entity_types as $entity_type_id => $entity_type) { if ($entity_type->entityClassImplements(ContentEntityInterface::class)) { $entity_paths = array_fill_keys($entity_type->getLinkTemplates(), $entity_type_id); diff --git a/core/modules/menu_link_content/src/Plugin/Deriver/MenuLinkContentDeriver.php b/core/modules/menu_link_content/src/Plugin/Deriver/MenuLinkContentDeriver.php index c53f1327cb95..515c251c4105 100644 --- a/core/modules/menu_link_content/src/Plugin/Deriver/MenuLinkContentDeriver.php +++ b/core/modules/menu_link_content/src/Plugin/Deriver/MenuLinkContentDeriver.php @@ -3,7 +3,8 @@ namespace Drupal\menu_link_content\Plugin\Deriver; use Drupal\Component\Plugin\Derivative\DeriverBase; -use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Menu\MenuLinkManagerInterface; use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -15,13 +16,19 @@ * compared to entity referenced ones. */ class MenuLinkContentDeriver extends DeriverBase implements ContainerDeriverInterface { + use DeprecatedServicePropertyTrait; /** - * The entity manager. + * {@inheritdoc} + */ + protected $deprecatedProperties = ['entityManager' => 'entity.manager']; + + /** + * The entity type manager. * - * @var \Drupal\Core\Entity\EntityManagerInterface + * @var \Drupal\Core\Entity\EntityTypeManagerInterface */ - protected $entityManager; + protected $entityTypeManager; /** * The menu link manager. @@ -33,13 +40,13 @@ class MenuLinkContentDeriver extends DeriverBase implements ContainerDeriverInte /** * Constructs a MenuLinkContentDeriver instance. * - * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager - * The entity manager. + * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager + * The entity type manager. * @param \Drupal\Core\Menu\MenuLinkManagerInterface $menu_link_manager * The menu link manager. */ - public function __construct(EntityManagerInterface $entity_manager, MenuLinkManagerInterface $menu_link_manager) { - $this->entityManager = $entity_manager; + public function __construct(EntityTypeManagerInterface $entity_type_manager, MenuLinkManagerInterface $menu_link_manager) { + $this->entityTypeManager = $entity_type_manager; $this->menuLinkManager = $menu_link_manager; } @@ -48,7 +55,7 @@ public function __construct(EntityManagerInterface $entity_manager, MenuLinkMana */ public static function create(ContainerInterface $container, $base_plugin_id) { return new static( - $container->get('entity.manager'), + $container->get('entity_type.manager'), $container->get('plugin.manager.menu.link') ); } @@ -58,11 +65,11 @@ public static function create(ContainerInterface $container, $base_plugin_id) { */ public function getDerivativeDefinitions($base_plugin_definition) { // Get all custom menu links which should be rediscovered. - $entity_ids = $this->entityManager->getStorage('menu_link_content')->getQuery() + $entity_ids = $this->entityTypeManager->getStorage('menu_link_content')->getQuery() ->condition('rediscover', TRUE) ->execute(); $plugin_definitions = []; - $menu_link_content_entities = $this->entityManager->getStorage('menu_link_content')->loadMultiple($entity_ids); + $menu_link_content_entities = $this->entityTypeManager->getStorage('menu_link_content')->loadMultiple($entity_ids); /** @var \Drupal\menu_link_content\MenuLinkContentInterface $menu_link_content */ foreach ($menu_link_content_entities as $menu_link_content) { $plugin_definitions[$menu_link_content->uuid()] = $menu_link_content->getPluginDefinition(); diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/source/DrupalSqlBase.php b/core/modules/migrate_drupal/src/Plugin/migrate/source/DrupalSqlBase.php index 15acb0213fb6..1e402f3dcec2 100644 --- a/core/modules/migrate_drupal/src/Plugin/migrate/source/DrupalSqlBase.php +++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/DrupalSqlBase.php @@ -3,8 +3,9 @@ namespace Drupal\migrate_drupal\Plugin\migrate\source; use Drupal\Component\Plugin\DependentPluginInterface; +use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait; use Drupal\Core\Entity\DependencyTrait; -use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\State\StateInterface; use Drupal\migrate\Plugin\MigrationInterface; @@ -30,6 +31,12 @@ abstract class DrupalSqlBase extends SqlBase implements ContainerFactoryPluginInterface, DependentPluginInterface { use DependencyTrait; + use DeprecatedServicePropertyTrait; + + /** + * {@inheritdoc} + */ + protected $deprecatedProperties = ['entityManager' => 'entity.manager']; /** * The contents of the system table. @@ -46,18 +53,18 @@ abstract class DrupalSqlBase extends SqlBase implements ContainerFactoryPluginIn protected $requirements = TRUE; /** - * The entity manager. + * The entity type manager. * - * @var \Drupal\Core\Entity\EntityManagerInterface + * @var \Drupal\Core\Entity\EntityTypeManagerInterface */ - protected $entityManager; + protected $entityTypeManager; /** * {@inheritdoc} */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, StateInterface $state, EntityManagerInterface $entity_manager) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, StateInterface $state, EntityTypeManagerInterface $entity_type_manager) { parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $state); - $this->entityManager = $entity_manager; + $this->entityTypeManager = $entity_type_manager; } /** @@ -176,7 +183,7 @@ protected function variableGet($name, $default) { public function calculateDependencies() { // Generic handling for Drupal source plugin constants. if (isset($this->configuration['constants']['entity_type'])) { - $this->addDependency('module', $this->entityManager->getDefinition($this->configuration['constants']['entity_type'])->getProvider()); + $this->addDependency('module', $this->entityTypeManager->getDefinition($this->configuration['constants']['entity_type'])->getProvider()); } if (isset($this->configuration['constants']['module'])) { $this->addDependency('module', $this->configuration['constants']['module']); diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/source/EmptySource.php b/core/modules/migrate_drupal/src/Plugin/migrate/source/EmptySource.php index 0c49d048cd6d..1eb93af69295 100644 --- a/core/modules/migrate_drupal/src/Plugin/migrate/source/EmptySource.php +++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/EmptySource.php @@ -3,11 +3,12 @@ namespace Drupal\migrate_drupal\Plugin\migrate\source; use Drupal\Component\Plugin\DependentPluginInterface; +use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait; use Drupal\Core\Entity\DependencyTrait; use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\migrate\Plugin\MigrationInterface; use Drupal\migrate\Plugin\migrate\source\EmptySource as BaseEmptySource; -use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; /** @@ -21,20 +22,26 @@ class EmptySource extends BaseEmptySource implements ContainerFactoryPluginInterface, DependentPluginInterface { use DependencyTrait; + use DeprecatedServicePropertyTrait; /** - * The entity manager. + * {@inheritdoc} + */ + protected $deprecatedProperties = ['entityManager' => 'entity.manager']; + + /** + * The entity type manager. * - * @var \Drupal\Core\Entity\EntityManagerInterface + * @var \Drupal\Core\Entity\EntityTypeManagerInterface */ - protected $entityManager; + protected $entityTypeManager; /** * {@inheritdoc} */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityManagerInterface $entity_manager) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityTypeManagerInterface $entity_manager) { parent::__construct($configuration, $plugin_id, $plugin_definition, $migration); - $this->entityManager = $entity_manager; + $this->entityTypeManager = $entity_manager; } /** @@ -46,7 +53,7 @@ public static function create(ContainerInterface $container, array $configuratio $plugin_id, $plugin_definition, $migration, - $container->get('entity.manager') + $container->get('entity_type.manager') ); } @@ -56,7 +63,7 @@ public static function create(ContainerInterface $container, array $configuratio public function calculateDependencies() { // The empty source plugin supports the entity_type constant. if (isset($this->configuration['constants']['entity_type'])) { - $this->addDependency('module', $this->entityManager->getDefinition($this->configuration['constants']['entity_type'])->getProvider()); + $this->addDependency('module', $this->entityTypeManager->getDefinition($this->configuration['constants']['entity_type'])->getProvider()); } return $this->dependencies; } diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/source/Variable.php b/core/modules/migrate_drupal/src/Plugin/migrate/source/Variable.php index a585510b0fd3..c901b85c11e8 100644 --- a/core/modules/migrate_drupal/src/Plugin/migrate/source/Variable.php +++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/Variable.php @@ -2,7 +2,7 @@ namespace Drupal\migrate_drupal\Plugin\migrate\source; -use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\State\StateInterface; use Drupal\migrate\Plugin\MigrationInterface; @@ -29,8 +29,8 @@ class Variable extends DrupalSqlBase { /** * {@inheritdoc} */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, StateInterface $state, EntityManagerInterface $entity_manager) { - parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $state, $entity_manager); + public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, StateInterface $state, EntityTypeManagerInterface $entity_type_manager) { + parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $state, $entity_type_manager); $this->variables = $this->configuration['variables']; } diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/VariableTranslation.php b/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/VariableTranslation.php index e11a305c8b9d..38ce1137b938 100644 --- a/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/VariableTranslation.php +++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/d6/VariableTranslation.php @@ -2,7 +2,7 @@ namespace Drupal\migrate_drupal\Plugin\migrate\source\d6; -use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\State\StateInterface; use Drupal\migrate\Plugin\MigrationInterface; use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase; @@ -27,8 +27,8 @@ class VariableTranslation extends DrupalSqlBase { /** * {@inheritdoc} */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, StateInterface $state, EntityManagerInterface $entity_manager) { - parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $state, $entity_manager); + public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, StateInterface $state, EntityTypeManagerInterface $entity_type_manager) { + parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $state, $entity_type_manager); $this->variables = $this->configuration['variables']; } diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/source/d7/VariableTranslation.php b/core/modules/migrate_drupal/src/Plugin/migrate/source/d7/VariableTranslation.php index 4df6a8702dc6..dd68dbeaa8d5 100644 --- a/core/modules/migrate_drupal/src/Plugin/migrate/source/d7/VariableTranslation.php +++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/d7/VariableTranslation.php @@ -2,7 +2,7 @@ namespace Drupal\migrate_drupal\Plugin\migrate\source\d7; -use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\State\StateInterface; use Drupal\migrate\Plugin\MigrationInterface; use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase; @@ -26,8 +26,8 @@ class VariableTranslation extends DrupalSqlBase { /** * {@inheritdoc} */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, StateInterface $state, EntityManagerInterface $entity_manager) { - parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $state, $entity_manager); + public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, StateInterface $state, EntityTypeManagerInterface $entity_type_manager) { + parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $state, $entity_type_manager); $this->variables = $this->configuration['variables']; } diff --git a/core/modules/node/src/Plugin/Search/NodeSearch.php b/core/modules/node/src/Plugin/Search/NodeSearch.php index e4d5a0e7fc8e..1065568c9d28 100644 --- a/core/modules/node/src/Plugin/Search/NodeSearch.php +++ b/core/modules/node/src/Plugin/Search/NodeSearch.php @@ -9,7 +9,8 @@ use Drupal\Core\Database\Database; use Drupal\Core\Database\Query\SelectExtender; use Drupal\Core\Database\StatementInterface; -use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageInterface; @@ -34,6 +35,12 @@ * ) */ class NodeSearch extends ConfigurableSearchPluginBase implements AccessibleInterface, SearchIndexingInterface { + use DeprecatedServicePropertyTrait; + + /** + * {@inheritdoc} + */ + protected $deprecatedProperties = ['entityManager' => 'entity.manager']; /** * The current database connection. @@ -50,11 +57,11 @@ class NodeSearch extends ConfigurableSearchPluginBase implements AccessibleInter protected $databaseReplica; /** - * An entity manager object. + * The entity type manager. * - * @var \Drupal\Core\Entity\EntityManagerInterface + * @var \Drupal\Core\Entity\EntityTypeManagerInterface */ - protected $entityManager; + protected $entityTypeManager; /** * A module manager object. @@ -139,7 +146,7 @@ public static function create(ContainerInterface $container, array $configuratio $plugin_id, $plugin_definition, $container->get('database'), - $container->get('entity.manager'), + $container->get('entity_type.manager'), $container->get('module_handler'), $container->get('config.factory')->get('search.settings'), $container->get('language_manager'), @@ -161,8 +168,8 @@ public static function create(ContainerInterface $container, array $configuratio * The plugin implementation definition. * @param \Drupal\Core\Database\Connection $database * The current database connection. - * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager - * An entity manager object. + * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager + * The entity type manager. * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * A module manager object. * @param \Drupal\Core\Config\Config $search_settings @@ -178,10 +185,10 @@ public static function create(ContainerInterface $container, array $configuratio * @param \Drupal\Core\Database\Connection|null $database_replica * (Optional) the replica database connection. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, Connection $database, EntityManagerInterface $entity_manager, ModuleHandlerInterface $module_handler, Config $search_settings, LanguageManagerInterface $language_manager, RendererInterface $renderer, MessengerInterface $messenger, AccountInterface $account = NULL, Connection $database_replica = NULL) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, Connection $database, EntityTypeManagerInterface $entity_type_manager, ModuleHandlerInterface $module_handler, Config $search_settings, LanguageManagerInterface $language_manager, RendererInterface $renderer, MessengerInterface $messenger, AccountInterface $account = NULL, Connection $database_replica = NULL) { $this->database = $database; $this->databaseReplica = $database_replica ?: $database; - $this->entityManager = $entity_manager; + $this->entityTypeManager = $entity_type_manager; $this->moduleHandler = $module_handler; $this->searchSettings = $search_settings; $this->languageManager = $language_manager; @@ -339,8 +346,8 @@ protected function findResults() { protected function prepareResults(StatementInterface $found) { $results = []; - $node_storage = $this->entityManager->getStorage('node'); - $node_render = $this->entityManager->getViewBuilder('node'); + $node_storage = $this->entityTypeManager->getStorage('node'); + $node_render = $this->entityTypeManager->getViewBuilder('node'); $keys = $this->keywords; foreach ($found as $item) { @@ -350,7 +357,7 @@ protected function prepareResults(StatementInterface $found) { $build = $node_render->view($node, 'search_result', $item->langcode); /** @var \Drupal\node\NodeTypeInterface $type*/ - $type = $this->entityManager->getStorage('node_type')->load($node->bundle()); + $type = $this->entityTypeManager->getStorage('node_type')->load($node->bundle()); unset($build['#theme']); $build['#pre_render'][] = [$this, 'removeSubmittedInfo']; @@ -470,7 +477,7 @@ public function updateIndex() { return; } - $node_storage = $this->entityManager->getStorage('node'); + $node_storage = $this->entityTypeManager->getStorage('node'); foreach ($node_storage->loadMultiple($nids) as $node) { $this->indexNode($node); } @@ -484,7 +491,7 @@ public function updateIndex() { */ protected function indexNode(NodeInterface $node) { $languages = $node->getTranslationLanguages(); - $node_render = $this->entityManager->getViewBuilder('node'); + $node_render = $this->entityTypeManager->getViewBuilder('node'); foreach ($languages as $language) { $node = $node->getTranslation($language->getId()); diff --git a/core/modules/node/src/Plugin/migrate/source/d6/Node.php b/core/modules/node/src/Plugin/migrate/source/d6/Node.php index d20545f2e27c..f5eb9cc64bd8 100644 --- a/core/modules/node/src/Plugin/migrate/source/d6/Node.php +++ b/core/modules/node/src/Plugin/migrate/source/d6/Node.php @@ -3,7 +3,7 @@ namespace Drupal\node\Plugin\migrate\source\d6; use Drupal\Core\Database\Query\SelectInterface; -use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Extension\ModuleHandler; use Drupal\Core\State\StateInterface; use Drupal\migrate\Plugin\MigrationInterface; @@ -51,8 +51,8 @@ class Node extends DrupalSqlBase { /** * {@inheritdoc} */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, StateInterface $state, EntityManagerInterface $entity_manager, ModuleHandler $module_handler) { - parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $state, $entity_manager); + public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, StateInterface $state, EntityTypeManagerInterface $entity_type_manager, ModuleHandler $module_handler) { + parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $state, $entity_type_manager); $this->moduleHandler = $module_handler; } diff --git a/core/modules/node/src/Plugin/migrate/source/d7/Node.php b/core/modules/node/src/Plugin/migrate/source/d7/Node.php index 931a2b94311c..4542fde47cf9 100644 --- a/core/modules/node/src/Plugin/migrate/source/d7/Node.php +++ b/core/modules/node/src/Plugin/migrate/source/d7/Node.php @@ -6,7 +6,7 @@ use Drupal\migrate\Row; use Drupal\migrate_drupal\Plugin\migrate\source\d7\FieldableEntity; use Drupal\Core\Database\Query\SelectInterface; -use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Extension\ModuleHandler; use Drupal\Core\State\StateInterface; use Drupal\migrate\Plugin\MigrationInterface; @@ -31,8 +31,8 @@ class Node extends FieldableEntity { /** * {@inheritdoc} */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, StateInterface $state, EntityManagerInterface $entity_manager, ModuleHandlerInterface $module_handler) { - parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $state, $entity_manager); + public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, StateInterface $state, EntityTypeManagerInterface $entity_type_manager, ModuleHandlerInterface $module_handler) { + parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $state, $entity_type_manager); $this->moduleHandler = $module_handler; } diff --git a/core/modules/rest/src/Plugin/Deriver/EntityDeriver.php b/core/modules/rest/src/Plugin/Deriver/EntityDeriver.php index e631f5da3ee4..6d79589d14d3 100644 --- a/core/modules/rest/src/Plugin/Deriver/EntityDeriver.php +++ b/core/modules/rest/src/Plugin/Deriver/EntityDeriver.php @@ -2,7 +2,8 @@ namespace Drupal\rest\Plugin\Deriver; -use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -12,6 +13,12 @@ * @see \Drupal\rest\Plugin\rest\resource\EntityResource */ class EntityDeriver implements ContainerDeriverInterface { + use DeprecatedServicePropertyTrait; + + /** + * {@inheritdoc} + */ + protected $deprecatedProperties = ['entityManager' => 'entity.manager']; /** * List of derivative definitions. @@ -21,20 +28,20 @@ class EntityDeriver implements ContainerDeriverInterface { protected $derivatives; /** - * The entity manager. + * The entity type manager. * - * @var \Drupal\Core\Entity\EntityManagerInterface + * @var \Drupal\Core\Entity\EntityTypeManagerInterface */ - protected $entityManager; + protected $entityTypeManager; /** * Constructs an EntityDeriver object. * - * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager - * The entity manager. + * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager + * The entity type manager. */ - public function __construct(EntityManagerInterface $entity_manager) { - $this->entityManager = $entity_manager; + public function __construct(EntityTypeManagerInterface $entity_type_manager) { + $this->entityTypeManager = $entity_type_manager; } /** @@ -64,7 +71,7 @@ public function getDerivativeDefinition($derivative_id, $base_plugin_definition) public function getDerivativeDefinitions($base_plugin_definition) { if (!isset($this->derivatives)) { // Add in the default plugin configuration and the resource type. - foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) { + foreach ($this->entityTypeManager->getDefinitions() as $entity_type_id => $entity_type) { if ($entity_type->isInternal()) { continue; } diff --git a/core/modules/taxonomy/src/TaxonomyPermissions.php b/core/modules/taxonomy/src/TaxonomyPermissions.php index 1772a34f97b5..6a0b0d69a263 100644 --- a/core/modules/taxonomy/src/TaxonomyPermissions.php +++ b/core/modules/taxonomy/src/TaxonomyPermissions.php @@ -3,7 +3,8 @@ namespace Drupal\taxonomy; use Drupal\Core\DependencyInjection\ContainerInjectionInterface; -use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\taxonomy\Entity\Vocabulary; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -16,22 +17,28 @@ class TaxonomyPermissions implements ContainerInjectionInterface { use StringTranslationTrait; + use DeprecatedServicePropertyTrait; /** - * The entity manager. + * {@inheritdoc} + */ + protected $deprecatedProperties = ['entityManager' => 'entity.manager']; + + /** + * The entity type manager. * - * @var \Drupal\Core\Entity\EntityManagerInterface + * @var \Drupal\Core\Entity\EntityTypeManagerInterface */ - protected $entityManager; + protected $entityTypeManager; /** * Constructs a TaxonomyPermissions instance. * - * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager - * The entity manager. + * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager + * The entity type manager. */ - public function __construct(EntityManagerInterface $entity_manager) { - $this->entityManager = $entity_manager; + public function __construct(EntityTypeManagerInterface $entity_type_manager) { + $this->entityTypeManager = $entity_type_manager; } /** diff --git a/core/modules/user/src/Form/UserMultipleCancelConfirm.php b/core/modules/user/src/Form/UserMultipleCancelConfirm.php index c0fa97c94c3e..e4bd53436c97 100644 --- a/core/modules/user/src/Form/UserMultipleCancelConfirm.php +++ b/core/modules/user/src/Form/UserMultipleCancelConfirm.php @@ -2,7 +2,8 @@ namespace Drupal\user\Form; -use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Form\ConfirmFormBase; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Messenger\MessengerInterface; @@ -17,6 +18,12 @@ * @internal */ class UserMultipleCancelConfirm extends ConfirmFormBase { + use DeprecatedServicePropertyTrait; + + /** + * {@inheritdoc} + */ + protected $deprecatedProperties = ['entityManager' => 'entity.manager']; /** * The temp store factory. @@ -33,11 +40,11 @@ class UserMultipleCancelConfirm extends ConfirmFormBase { protected $userStorage; /** - * The entity manager. + * The entity type manager. * - * @var \Drupal\Core\Entity\EntityManagerInterface + * @var \Drupal\Core\Entity\EntityTypeManagerInterface */ - protected $entityManager; + protected $entityTypeManager; /** * Constructs a new UserMultipleCancelConfirm. @@ -46,13 +53,13 @@ class UserMultipleCancelConfirm extends ConfirmFormBase { * The temp store factory. * @param \Drupal\user\UserStorageInterface $user_storage * The user storage. - * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager - * The entity manager. + * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager + * The entity type manager. */ - public function __construct(PrivateTempStoreFactory $temp_store_factory, UserStorageInterface $user_storage, EntityManagerInterface $entity_manager) { + public function __construct(PrivateTempStoreFactory $temp_store_factory, UserStorageInterface $user_storage, EntityTypeManagerInterface $entity_type_manager) { $this->tempStoreFactory = $temp_store_factory; $this->userStorage = $user_storage; - $this->entityManager = $entity_manager; + $this->entityTypeManager = $entity_type_manager; } /** @@ -61,8 +68,8 @@ public function __construct(PrivateTempStoreFactory $temp_store_factory, UserSto public static function create(ContainerInterface $container) { return new static( $container->get('tempstore.private'), - $container->get('entity.manager')->getStorage('user'), - $container->get('entity.manager') + $container->get('entity_type.manager')->getStorage('user'), + $container->get('entity_type.manager') ); } @@ -207,7 +214,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { // The $user global is not a complete user entity, so load the full // entity. $account = $this->userStorage->load($uid); - $admin_form = $this->entityManager->getFormObject('user', 'cancel'); + $admin_form = $this->entityTypeManager->getFormObject('user', 'cancel'); $admin_form->setEntity($account); // Calling this directly required to init form object with $account. $admin_form->buildForm($admin_form_mock, $admin_form_state); diff --git a/core/modules/user/src/Plugin/Search/UserSearch.php b/core/modules/user/src/Plugin/Search/UserSearch.php index 8bae56510c1f..41edfd9f1e4f 100644 --- a/core/modules/user/src/Plugin/Search/UserSearch.php +++ b/core/modules/user/src/Plugin/Search/UserSearch.php @@ -4,7 +4,8 @@ use Drupal\Core\Access\AccessResult; use Drupal\Core\Database\Connection; -use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Session\AccountInterface; use Drupal\Core\Access\AccessibleInterface; @@ -20,6 +21,12 @@ * ) */ class UserSearch extends SearchPluginBase implements AccessibleInterface { + use DeprecatedServicePropertyTrait; + + /** + * {@inheritdoc} + */ + protected $deprecatedProperties = ['entityManager' => 'entity.manager']; /** * The database connection. @@ -29,11 +36,11 @@ class UserSearch extends SearchPluginBase implements AccessibleInterface { protected $database; /** - * The entity manager. + * The entity type manager. * - * @var \Drupal\Core\Entity\EntityManagerInterface + * @var \Drupal\Core\Entity\EntityTypeManagerInterface */ - protected $entityManager; + protected $entityTypeManager; /** * The module handler. @@ -55,7 +62,7 @@ class UserSearch extends SearchPluginBase implements AccessibleInterface { public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { return new static( $container->get('database'), - $container->get('entity.manager'), + $container->get('entity_type.manager'), $container->get('module_handler'), $container->get('current_user'), $configuration, @@ -69,8 +76,8 @@ public static function create(ContainerInterface $container, array $configuratio * * @param \Drupal\Core\Database\Connection $database * The database connection. - * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager - * The entity manager. + * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager + * The entity type manager. * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler. * @param \Drupal\Core\Session\AccountInterface $current_user @@ -82,9 +89,9 @@ public static function create(ContainerInterface $container, array $configuratio * @param mixed $plugin_definition * The plugin implementation definition. */ - public function __construct(Connection $database, EntityManagerInterface $entity_manager, ModuleHandlerInterface $module_handler, AccountInterface $current_user, array $configuration, $plugin_id, $plugin_definition) { + public function __construct(Connection $database, EntityTypeManagerInterface $entity_type_manager, ModuleHandlerInterface $module_handler, AccountInterface $current_user, array $configuration, $plugin_id, $plugin_definition) { $this->database = $database; - $this->entityManager = $entity_manager; + $this->entityTypeManager = $entity_type_manager; $this->moduleHandler = $module_handler; $this->currentUser = $current_user; parent::__construct($configuration, $plugin_id, $plugin_definition); @@ -141,7 +148,7 @@ public function execute() { ->limit(15) ->execute() ->fetchCol(); - $accounts = $this->entityManager->getStorage('user')->loadMultiple($uids); + $accounts = $this->entityTypeManager->getStorage('user')->loadMultiple($uids); foreach ($accounts as $account) { $result = [ diff --git a/core/modules/user/src/Plugin/views/argument/RolesRid.php b/core/modules/user/src/Plugin/views/argument/RolesRid.php index ff9bf5ec82b0..4d909dcbd92f 100644 --- a/core/modules/user/src/Plugin/views/argument/RolesRid.php +++ b/core/modules/user/src/Plugin/views/argument/RolesRid.php @@ -2,7 +2,7 @@ namespace Drupal\user\Plugin\views\argument; -use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\views\Plugin\views\argument\ManyToOne; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -31,13 +31,13 @@ class RolesRid extends ManyToOne { * The plugin_id for the plugin instance. * @param mixed $plugin_definition * The plugin implementation definition. - * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager - * The entity manager. + * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager + * The entity type manager. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityManagerInterface $entity_manager) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager) { parent::__construct($configuration, $plugin_id, $plugin_definition); - $this->roleStorage = $entity_manager->getStorage('user_role'); + $this->roleStorage = $entity_type_manager->getStorage('user_role'); } /** diff --git a/core/modules/user/src/Plugin/views/field/Permissions.php b/core/modules/user/src/Plugin/views/field/Permissions.php index bab5503ba85e..ac8c3184c465 100644 --- a/core/modules/user/src/Plugin/views/field/Permissions.php +++ b/core/modules/user/src/Plugin/views/field/Permissions.php @@ -2,7 +2,7 @@ namespace Drupal\user\Plugin\views\field; -use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\ViewExecutable; @@ -43,13 +43,13 @@ class Permissions extends PrerenderList { * The plugin implementation definition. * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler. - * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager - * The entity manager + * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager + * The entity type manager. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, ModuleHandlerInterface $module_handler, EntityManagerInterface $entity_manager) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, ModuleHandlerInterface $module_handler, EntityTypeManagerInterface $entity_type_manager) { parent::__construct($configuration, $plugin_id, $plugin_definition); - $this->roleStorage = $entity_manager->getStorage('user_role'); + $this->roleStorage = $entity_type_manager->getStorage('user_role'); $this->moduleHandler = $module_handler; } diff --git a/core/modules/views/src/Plugin/Derivative/ViewsEntityArgumentValidator.php b/core/modules/views/src/Plugin/Derivative/ViewsEntityArgumentValidator.php index 539eb4798722..03e847425a4c 100644 --- a/core/modules/views/src/Plugin/Derivative/ViewsEntityArgumentValidator.php +++ b/core/modules/views/src/Plugin/Derivative/ViewsEntityArgumentValidator.php @@ -3,7 +3,8 @@ namespace Drupal\views\Plugin\Derivative; use Drupal\Component\Plugin\Derivative\DeriverBase; -use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\Core\StringTranslation\TranslationInterface; @@ -18,6 +19,12 @@ */ class ViewsEntityArgumentValidator extends DeriverBase implements ContainerDeriverInterface { use StringTranslationTrait; + use DeprecatedServicePropertyTrait; + + /** + * {@inheritdoc} + */ + protected $deprecatedProperties = ['entityManager' => 'entity.manager']; /** * The base plugin ID this derivative is for. @@ -27,11 +34,11 @@ class ViewsEntityArgumentValidator extends DeriverBase implements ContainerDeriv protected $basePluginId; /** - * The entity manager. + * The entity type manager. * - * @var \Drupal\Core\Entity\EntityManagerInterface + * @var \Drupal\Core\Entity\EntityTypeManagerInterface */ - protected $entityManager; + protected $entityTypeManager; /** * List of derivative definitions. @@ -45,14 +52,14 @@ class ViewsEntityArgumentValidator extends DeriverBase implements ContainerDeriv * * @param string $base_plugin_id * The base plugin ID. - * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager - * The entity manager. + * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager + * The entity type manager. * @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation * The string translation. */ - public function __construct($base_plugin_id, EntityManagerInterface $entity_manager, TranslationInterface $string_translation) { + public function __construct($base_plugin_id, EntityTypeManagerInterface $entity_type_manager, TranslationInterface $string_translation) { $this->basePluginId = $base_plugin_id; - $this->entityManager = $entity_manager; + $this->entityTypeManager = $entity_type_manager; $this->stringTranslation = $string_translation; } @@ -62,7 +69,7 @@ public function __construct($base_plugin_id, EntityManagerInterface $entity_mana public static function create(ContainerInterface $container, $base_plugin_id) { return new static( $base_plugin_id, - $container->get('entity.manager'), + $container->get('entity_type.manager'), $container->get('string_translation') ); } @@ -71,7 +78,7 @@ public static function create(ContainerInterface $container, $base_plugin_id) { * {@inheritdoc} */ public function getDerivativeDefinitions($base_plugin_definition) { - $entity_types = $this->entityManager->getDefinitions(); + $entity_types = $this->entityTypeManager->getDefinitions(); $this->derivatives = []; foreach ($entity_types as $entity_type_id => $entity_type) { $this->derivatives[$entity_type_id] = [ diff --git a/core/modules/views/src/Plugin/Derivative/ViewsEntityRow.php b/core/modules/views/src/Plugin/Derivative/ViewsEntityRow.php index 67e7c33fd629..bdbeacc35c84 100644 --- a/core/modules/views/src/Plugin/Derivative/ViewsEntityRow.php +++ b/core/modules/views/src/Plugin/Derivative/ViewsEntityRow.php @@ -2,7 +2,8 @@ namespace Drupal\views\Plugin\Derivative; -use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface; use Drupal\views\ViewsData; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -15,6 +16,12 @@ * @see \Drupal\views\Plugin\views\row\EntityRow */ class ViewsEntityRow implements ContainerDeriverInterface { + use DeprecatedServicePropertyTrait; + + /** + * {@inheritdoc} + */ + protected $deprecatedProperties = ['entityManager' => 'entity.manager']; /** * Stores all entity row plugin information. @@ -31,11 +38,11 @@ class ViewsEntityRow implements ContainerDeriverInterface { protected $basePluginId; /** - * The entity manager. + * The entity type manager. * - * @var \Drupal\Core\Entity\EntityManagerInterface + * @var \Drupal\Core\Entity\EntityTypeManagerInterface */ - protected $entityManager; + protected $entityTypeManager; /** * The views data service. @@ -49,14 +56,14 @@ class ViewsEntityRow implements ContainerDeriverInterface { * * @param string $base_plugin_id * The base plugin ID. - * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager - * The entity manager. + * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager + * The entity type manager. * @param \Drupal\views\ViewsData $views_data * The views data service. */ - public function __construct($base_plugin_id, EntityManagerInterface $entity_manager, ViewsData $views_data) { + public function __construct($base_plugin_id, EntityTypeManagerInterface $entity_type_manager, ViewsData $views_data) { $this->basePluginId = $base_plugin_id; - $this->entityManager = $entity_manager; + $this->entityTypeManager = $entity_type_manager; $this->viewsData = $views_data; } @@ -86,9 +93,9 @@ public function getDerivativeDefinition($derivative_id, $base_plugin_definition) * {@inheritdoc} */ public function getDerivativeDefinitions($base_plugin_definition) { - foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) { + foreach ($this->entityTypeManager->getDefinitions() as $entity_type_id => $entity_type) { // Just add support for entity types which have a views integration. - if (($base_table = $entity_type->getBaseTable()) && $this->viewsData->get($base_table) && $this->entityManager->hasHandler($entity_type_id, 'view_builder')) { + if (($base_table = $entity_type->getBaseTable()) && $this->viewsData->get($base_table) && $this->entityTypeManager->hasHandler($entity_type_id, 'view_builder')) { $this->derivatives[$entity_type_id] = [ 'id' => 'entity:' . $entity_type_id, 'provider' => 'views', diff --git a/core/modules/views/src/Plugin/Menu/ViewsMenuLink.php b/core/modules/views/src/Plugin/Menu/ViewsMenuLink.php index 3cbfc84e0a18..ab8c42ac2485 100644 --- a/core/modules/views/src/Plugin/Menu/ViewsMenuLink.php +++ b/core/modules/views/src/Plugin/Menu/ViewsMenuLink.php @@ -2,8 +2,9 @@ namespace Drupal\views\Plugin\Menu; +use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait; use Drupal\Core\Menu\MenuLinkBase; -use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\views\ViewExecutableFactory; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -14,6 +15,12 @@ * @see \Drupal\views\Plugin\Derivative\ViewsMenuLink */ class ViewsMenuLink extends MenuLinkBase implements ContainerFactoryPluginInterface { + use DeprecatedServicePropertyTrait; + + /** + * {@inheritdoc} + */ + protected $deprecatedProperties = ['entityManager' => 'entity.manager']; /** * {@inheritdoc} @@ -29,11 +36,11 @@ class ViewsMenuLink extends MenuLinkBase implements ContainerFactoryPluginInterf ]; /** - * The entity manager. + * The entity type manager. * - * @var \Drupal\Core\Entity\EntityManagerInterface + * @var \Drupal\Core\Entity\EntityTypeManagerInterface */ - protected $entityManager; + protected $entityTypeManager; /** * The view executable factory. @@ -58,15 +65,15 @@ class ViewsMenuLink extends MenuLinkBase implements ContainerFactoryPluginInterf * The plugin_id for the plugin instance. * @param mixed $plugin_definition * The plugin implementation definition. - * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager - * The entity manager + * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager + * The entity type manager. * @param \Drupal\views\ViewExecutableFactory $view_executable_factory * The view executable factory */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityManagerInterface $entity_manager, ViewExecutableFactory $view_executable_factory) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, ViewExecutableFactory $view_executable_factory) { parent::__construct($configuration, $plugin_id, $plugin_definition); - $this->entityManager = $entity_manager; + $this->entityTypeManager = $entity_type_manager; $this->viewExecutableFactory = $view_executable_factory; } @@ -94,7 +101,7 @@ public function loadView() { $metadata = $this->getMetaData(); $view_id = $metadata['view_id']; $display_id = $metadata['display_id']; - $view_entity = $this->entityManager->getStorage('view')->load($view_id); + $view_entity = $this->entityTypeManager->getStorage('view')->load($view_id); $view = $this->viewExecutableFactory->get($view_entity); $view->setDisplay($display_id); $view->initDisplay(); diff --git a/core/modules/views/src/Plugin/views/display/Block.php b/core/modules/views/src/Plugin/views/display/Block.php index e210ee3231ab..384bb75d4449 100644 --- a/core/modules/views/src/Plugin/views/display/Block.php +++ b/core/modules/views/src/Plugin/views/display/Block.php @@ -4,7 +4,8 @@ use Drupal\Component\Plugin\Discovery\CachedDiscoveryInterface; use Drupal\Core\Block\BlockManagerInterface; -use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\Block\ViewsBlock; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -29,6 +30,12 @@ * @see \Drupal\views\Plugin\Derivative\ViewsBlock */ class Block extends DisplayPluginBase { + use DeprecatedServicePropertyTrait; + + /** + * {@inheritdoc} + */ + protected $deprecatedProperties = ['entityManager' => 'entity.manager']; /** * Whether the display allows attachments. @@ -38,11 +45,11 @@ class Block extends DisplayPluginBase { protected $usesAttachments = TRUE; /** - * The entity manager. + * The entity type manager. * - * @var \Drupal\Core\Entity\EntityManagerInterface + * @var \Drupal\Core\Entity\EntityTypeManagerInterface */ - protected $entityManager; + protected $entityTypeManager; /** * The block manager. @@ -60,15 +67,15 @@ class Block extends DisplayPluginBase { * The plugin_id for the plugin instance. * @param mixed $plugin_definition * The plugin implementation definition. - * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager + * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager * The entity manager. * @param \Drupal\Core\Block\BlockManagerInterface $block_manager * The block manager. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityManagerInterface $entity_manager, BlockManagerInterface $block_manager) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, BlockManagerInterface $block_manager) { parent::__construct($configuration, $plugin_id, $plugin_definition); - $this->entityManager = $entity_manager; + $this->entityTypeManager = $entity_type_manager; $this->blockManager = $block_manager; } @@ -371,9 +378,9 @@ public function usesExposed() { public function remove() { parent::remove(); - if ($this->entityManager->hasDefinition('block')) { + if ($this->entityTypeManager->hasDefinition('block')) { $plugin_id = 'views_block:' . $this->view->storage->id() . '-' . $this->display['id']; - foreach ($this->entityManager->getStorage('block')->loadByProperties(['plugin' => $plugin_id]) as $block) { + foreach ($this->entityTypeManager->getStorage('block')->loadByProperties(['plugin' => $plugin_id]) as $block) { $block->delete(); } } diff --git a/core/modules/views/src/Plugin/views/filter/Bundle.php b/core/modules/views/src/Plugin/views/filter/Bundle.php index e14c35aa63c0..d1c9898d16f9 100644 --- a/core/modules/views/src/Plugin/views/filter/Bundle.php +++ b/core/modules/views/src/Plugin/views/filter/Bundle.php @@ -2,7 +2,8 @@ namespace Drupal\views\Plugin\views\filter; -use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Entity\EntityTypeBundleInfoInterface; use Drupal\views\ViewExecutable; use Drupal\views\Plugin\views\display\DisplayPluginBase; @@ -16,6 +17,12 @@ * @ViewsFilter("bundle") */ class Bundle extends InOperator { + use DeprecatedServicePropertyTrait; + + /** + * {@inheritdoc} + */ + protected $deprecatedProperties = ['entityManager' => 'entity.manager']; /** * The entity type for the filter. @@ -32,11 +39,11 @@ class Bundle extends InOperator { protected $entityType; /** - * The entity manager. + * The entity type manager. * - * @var \Drupal\Core\Entity\EntityManagerInterface + * @var \Drupal\Core\Entity\EntityTypeManagerInterface */ - protected $entityManager; + protected $entityTypeManager; /** * The bundle info service. @@ -54,15 +61,15 @@ class Bundle extends InOperator { * The plugin_id for the plugin instance. * @param mixed $plugin_definition * The plugin implementation definition. - * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager - * The entity manager. + * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager + * The entity type manager. * @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface $bundle_info_service * The bundle info service. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityManagerInterface $entity_manager, EntityTypeBundleInfoInterface $bundle_info_service) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, EntityTypeBundleInfoInterface $bundle_info_service) { parent::__construct($configuration, $plugin_id, $plugin_definition); - $this->entityManager = $entity_manager; + $this->entityTypeManager = $entity_type_manager; $this->bundleInfoService = $bundle_info_service; } @@ -86,7 +93,7 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o parent::init($view, $display, $options); $this->entityTypeId = $this->getEntityType(); - $this->entityType = \Drupal::entityManager()->getDefinition($this->entityTypeId); + $this->entityType = \Drupal::entityTypeManager()->getDefinition($this->entityTypeId); $this->real_field = $this->entityType->getKey('bundle'); } @@ -126,7 +133,7 @@ public function calculateDependencies() { $dependencies = parent::calculateDependencies(); $bundle_entity_type = $this->entityType->getBundleEntityType(); - $bundle_entity_storage = $this->entityManager->getStorage($bundle_entity_type); + $bundle_entity_storage = $this->entityTypeManager->getStorage($bundle_entity_type); foreach (array_keys($this->value) as $bundle) { if ($bundle_entity = $bundle_entity_storage->load($bundle)) { -- GitLab