Unverified Commit f2469de9 authored by alexpott's avatar alexpott

Issue #3087546 by Berdir, alexpott, martin107, jibran: Remove deprecated entity manager

parent 2a009c5e
......@@ -818,8 +818,8 @@
* special methods for accessing commonly-used services, or you can call a
* generic method to access any service. Examples:
* @code
* // Retrieve the entity.manager service object (special method exists).
* $manager = \Drupal::entityManager();
* // Retrieve the entity_type.manager service object (special method exists).
* $entity_type_manager = \Drupal::entityTypeManager();
* // Retrieve the service object for machine name 'foo.bar'.
* $foobar = \Drupal::service('foo.bar');
* @endcode
......
......@@ -553,12 +553,6 @@ services:
theme_installer:
class: Drupal\Core\Extension\ThemeInstaller
arguments: ['@theme_handler', '@config.factory', '@config.installer', '@module_handler', '@config.manager', '@asset.css.collection_optimizer', '@router.builder', '@logger.channel.default', '@state']
# @deprecated in Drupal 8.0.x and will be removed before 9.0.0. Use the other
# entity* services instead.
entity.manager:
class: Drupal\Core\Entity\EntityManager
parent: container.trait
deprecated: The "%service_id%" service is deprecated. You should use the 'entity_type.manager' service instead.
entity.memory_cache:
class: Drupal\Core\Cache\MemoryCache\MemoryCache
entity_type.manager:
......@@ -918,12 +912,6 @@ services:
arguments: ['@state']
tags:
- { name: event_subscriber }
entity.query:
class: Drupal\Core\Entity\Query\QueryFactory
arguments: ['@entity_type.manager']
calls:
- [setContainer, ['@service_container']]
deprecated: The "%service_id%" service is deprecated. Use the 'entity_type.manager' service to get an entity type's storage object and then call \Drupal\Core\Entity\EntityStorageInterface::getQuery() or \Drupal\Core\Entity\EntityStorageInterface::getAggregateQuery() instead. See https://www.drupal.org/node/2849874
entity.query.config:
class: Drupal\Core\Config\Entity\Query\QueryFactory
arguments: ['@config.factory', '@keyvalue', '@config.manager']
......
This diff is collapsed.
......@@ -350,7 +350,6 @@ function install_begin_request($class_loader, &$install_state) {
// Load module basics (needed for hook invokes).
include_once __DIR__ . '/module.inc';
require_once __DIR__ . '/entity.inc';
// Create a minimal mocked container to support calls to t() in the pre-kernel
// base system verification code paths below. The strings are not actually
......
......@@ -257,23 +257,6 @@ public static function currentUser() {
return static::getContainer()->get('current_user');
}
/**
* Retrieves the entity manager service.
*
* @return \Drupal\Core\Entity\EntityManagerInterface
* The entity manager service.
*
* @deprecated in drupal:8.0.0 and is removed from drupal:9.0.0.
* Use \Drupal::entityTypeManager() instead in most cases. If the needed
* method is not on \Drupal\Core\Entity\EntityTypeManagerInterface, see the
* deprecated \Drupal\Core\Entity\EntityManager to find the
* correct interface or service.
*/
public static function entityManager() {
@trigger_error("\Drupal::entityManager() is deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal::entityTypeManager() instead in most cases. If the needed method is not on \Drupal\Core\Entity\EntityTypeManagerInterface, see the deprecated \Drupal\Core\Entity\EntityManager to find the correct interface or service. See https://www.drupal.org/node/2549139", E_USER_DEPRECATED);
return static::getContainer()->get('entity.manager');
}
/**
* Retrieves the entity type manager.
*
......
......@@ -81,7 +81,7 @@ class EmailAction extends ConfigurableActionBase implements ContainerFactoryPlug
* @param \Drupal\Core\Utility\Token $token
* The token service.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity manager.
* The entity type manager.
* @param \Psr\Log\LoggerInterface $logger
* A logger instance.
* @param \Drupal\Core\Mail\MailManagerInterface $mail_manager
......
......@@ -6,8 +6,6 @@
use Drupal\Core\Config\Entity\ConfigDependencyManager;
use Drupal\Core\Config\Entity\ConfigEntityInterface;
use Drupal\Core\Config\Entity\ConfigEntityTypeInterface;
use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Entity\EntityRepositoryInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
......@@ -21,14 +19,8 @@
*/
class ConfigManager implements ConfigManagerInterface {
use StringTranslationTrait;
use DeprecatedServicePropertyTrait;
use StorageCopyTrait;
/**
* {@inheritdoc}
*/
protected $deprecatedProperties = ['entityManager' => 'entity.manager'];
/**
* The entity type manager.
*
......@@ -103,26 +95,14 @@ class ConfigManager implements ConfigManagerInterface {
* @param \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository
* The entity repository.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager, ConfigFactoryInterface $config_factory, TypedConfigManagerInterface $typed_config_manager, TranslationInterface $string_translation, StorageInterface $active_storage, EventDispatcherInterface $event_dispatcher, EntityRepositoryInterface $entity_repository = NULL) {
if ($entity_type_manager instanceof EntityManagerInterface) {
@trigger_error('Passing the entity.manager service to ConfigManager::__construct() is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Pass the new dependencies instead. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
$this->entityTypeManager = \Drupal::entityTypeManager();
}
else {
$this->entityTypeManager = $entity_type_manager;
}
public function __construct(EntityTypeManagerInterface $entity_type_manager, ConfigFactoryInterface $config_factory, TypedConfigManagerInterface $typed_config_manager, TranslationInterface $string_translation, StorageInterface $active_storage, EventDispatcherInterface $event_dispatcher, EntityRepositoryInterface $entity_repository) {
$this->entityTypeManager = $entity_type_manager;
$this->configFactory = $config_factory;
$this->typedConfigManager = $typed_config_manager;
$this->stringTranslation = $string_translation;
$this->activeStorage = $active_storage;
$this->eventDispatcher = $event_dispatcher;
if ($entity_repository) {
$this->entityRepository = $entity_repository;
}
else {
@trigger_error('The entity.repository service must be passed to ConfigManager::__construct(), it is required before Drupal 9.0.0. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
$this->entityRepository = \Drupal::service('entity.repository');
}
$this->entityRepository = $entity_repository;
}
/**
......@@ -148,14 +128,6 @@ public function loadConfigEntityByName($name) {
return NULL;
}
/**
* {@inheritdoc}
*/
public function getEntityManager() {
@trigger_error('ConfigManagerInterface::getEntityManager() is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Use ::getEntityTypeManager() instead. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
return \Drupal::service('entity.manager');
}
/**
* {@inheritdoc}
*/
......
......@@ -29,18 +29,6 @@ public function getEntityTypeIdByName($name);
*/
public function loadConfigEntityByName($name);
/**
* Gets the entity manager.
*
* @return \Drupal\Core\Entity\EntityManagerInterface
* The entity manager.
*
* @deprecated in drupal:8.7.0 and is removed from drupal:9.0.0. Use
* \Drupal\Core\Config\ConfigManagerInterface::getEntityTypeManager()
* instead.
*/
public function getEntityManager();
/**
* Gets the entity type manager.
*
......
......@@ -43,13 +43,6 @@ abstract class ControllerBase implements ContainerInjectionInterface {
use StringTranslationTrait;
use UrlGeneratorTrait;
/**
* The entity manager.
*
* @var \Drupal\Core\Entity\EntityManagerInterface
*/
protected $entityManager;
/**
* The entity type manager.
*
......@@ -120,24 +113,6 @@ public static function create(ContainerInterface $container) {
return new static();
}
/**
* Retrieves the entity manager service.
*
* @return \Drupal\Core\Entity\EntityManagerInterface
* The entity manager service.
*
* @deprecated in drupal:8.0.0 and is removed from drupal:9.0.0.
* Most of the time static::entityTypeManager() is supposed to be used
* instead.
*/
protected function entityManager() {
@trigger_error('ControllerBase::getEntityManager() is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Use ::getEntityTypeManager() instead. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
if (!$this->entityManager) {
$this->entityManager = $this->container()->get('entity.manager');
}
return $this->entityManager;
}
/**
* Retrieves the entity type manager.
*
......
......@@ -566,7 +566,6 @@ public function loadLegacyIncludes() {
require_once $this->root . '/core/includes/form.inc';
require_once $this->root . '/core/includes/errors.inc';
require_once $this->root . '/core/includes/schema.inc';
require_once $this->root . '/core/includes/entity.inc';
}
/**
......
......@@ -53,14 +53,10 @@ class ContentEntityForm extends EntityForm implements ContentEntityFormInterface
* @param \Drupal\Component\Datetime\TimeInterface $time
* The time service.
*/
public function __construct(EntityRepositoryInterface $entity_repository, EntityTypeBundleInfoInterface $entity_type_bundle_info = NULL, TimeInterface $time = NULL) {
if ($entity_repository instanceof EntityManagerInterface) {
@trigger_error('Passing the entity.manager service to ContentEntityForm::__construct() is deprecated in Drupal 8.6.0 and will be removed before Drupal 9.0.0. Pass the entity.repository service instead. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
$this->entityManager = $entity_repository;
}
public function __construct(EntityRepositoryInterface $entity_repository, EntityTypeBundleInfoInterface $entity_type_bundle_info, TimeInterface $time) {
$this->entityRepository = $entity_repository;
$this->entityTypeBundleInfo = $entity_type_bundle_info ?: \Drupal::service('entity_type.bundle.info');
$this->time = $time ?: \Drupal::service('datetime.time');
$this->entityTypeBundleInfo = $entity_type_bundle_info;
$this->time = $time;
}
/**
......
......@@ -5,7 +5,6 @@
use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Cache\MemoryCache\MemoryCacheInterface;
use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\Language\LanguageInterface;
......@@ -16,12 +15,6 @@
* Base class for content entity storage handlers.
*/
abstract class ContentEntityStorageBase extends EntityStorageBase implements ContentEntityStorageInterface, DynamicallyFieldableEntityStorageInterface {
use DeprecatedServicePropertyTrait;
/**
* {@inheritdoc}
*/
protected $deprecatedProperties = ['entityManager' => 'entity.manager'];
/**
* The entity bundle key.
......@@ -72,15 +65,11 @@ abstract class ContentEntityStorageBase extends EntityStorageBase implements Con
* @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface $entity_type_bundle_info
* The entity type bundle info.
*/
public function __construct(EntityTypeInterface $entity_type, EntityFieldManagerInterface $entity_field_manager, CacheBackendInterface $cache, MemoryCacheInterface $memory_cache = NULL, EntityTypeBundleInfoInterface $entity_type_bundle_info = NULL) {
public function __construct(EntityTypeInterface $entity_type, EntityFieldManagerInterface $entity_field_manager, CacheBackendInterface $cache, MemoryCacheInterface $memory_cache, EntityTypeBundleInfoInterface $entity_type_bundle_info) {
parent::__construct($entity_type, $memory_cache);
$this->bundleKey = $this->entityType->getKey('bundle');
$this->entityFieldManager = $entity_field_manager;
$this->cacheBackend = $cache;
if (!$entity_type_bundle_info) {
@trigger_error('Calling ContentEntityStorageBase::__construct() with the $entity_type_bundle_info argument is supported in drupal:8.7.0 and will be required before drupal:9.0.0. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
$entity_type_bundle_info = \Drupal::service('entity_type.bundle.info');
}
$this->entityTypeBundleInfo = $entity_type_bundle_info;
}
......
......@@ -2,7 +2,6 @@
namespace Drupal\Core\Entity;
use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait;
use Drupal\Core\Extension\ModuleUninstallValidatorInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\StringTranslation\TranslationInterface;
......@@ -13,12 +12,6 @@
*/
class ContentUninstallValidator implements ModuleUninstallValidatorInterface {
use StringTranslationTrait;
use DeprecatedServicePropertyTrait;
/**
* {@inheritdoc}
*/
protected $deprecatedProperties = ['entityManager' => 'entity.manager'];
/**
* The entity type manager service.
......@@ -36,13 +29,7 @@ class ContentUninstallValidator implements ModuleUninstallValidatorInterface {
* The string translation service.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager, TranslationInterface $string_translation) {
if ($entity_type_manager instanceof EntityManagerInterface) {
@trigger_error('Passing the entity.manager service to ContentUninstallValidator::__construct() is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Pass the new dependencies instead. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
$this->entityTypeManager = \Drupal::entityTypeManager();
}
else {
$this->entityTypeManager = $entity_type_manager;
}
$this->entityTypeManager = $entity_type_manager;
$this->stringTranslation = $string_translation;
}
......
......@@ -37,7 +37,7 @@ class EntityController implements ContainerInjectionInterface {
use UrlGeneratorTrait;
/**
* The entity manager.
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
......
......@@ -3,7 +3,6 @@
namespace Drupal\Core\Entity\Controller;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Entity\FieldableEntityInterface;
......@@ -15,12 +14,6 @@
* Defines a generic controller to render a single entity.
*/
class EntityViewController implements ContainerInjectionInterface, TrustedCallbackInterface {
use DeprecatedServicePropertyTrait;
/**
* {@inheritdoc}
*/
protected $deprecatedProperties = ['entityManager' => 'entity.manager'];
/**
* The entity type manager.
......
......@@ -20,8 +20,8 @@
* replicate the settings of the 'default' view mode, thus reducing the amount
* of display configurations to keep track of.
*
* @see \Drupal\Core\Entity\EntityManagerInterface::getAllViewModes()
* @see \Drupal\Core\Entity\EntityManagerInterface::getViewModes()
* @see \Drupal\Core\Entity\EntityDisplayRepositoryInterface::getAllViewModes()
* @see \Drupal\Core\Entity\EntityDisplayRepositoryInterface::getViewModes()
* @see hook_entity_view_mode_info_alter()
*
* @ConfigEntityType(
......
......@@ -64,22 +64,6 @@ public function __construct(array $values, $entity_type) {
}
}
/**
* Gets the entity manager.
*
* @return \Drupal\Core\Entity\EntityManagerInterface
*
* @deprecated in drupal:8.0.0 and is removed from drupal:9.0.0.
* Use \Drupal::entityTypeManager() instead in most cases. If the needed
* method is not on \Drupal\Core\Entity\EntityTypeManagerInterface, see the
* deprecated \Drupal\Core\Entity\EntityManager to find the
* correct interface or service.
*/
protected function entityManager() {
@trigger_error('Entity::getEntityManager() is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Use ::getEntityTypeManager() instead. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
return \Drupal::entityManager();
}
/**
* Gets the entity type manager.
*
......
......@@ -3,7 +3,6 @@
namespace Drupal\Core\Entity;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait;
use Drupal\Core\Routing\Access\AccessInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Session\AccountInterface;
......@@ -13,12 +12,6 @@
* Defines an access checker for entity creation.
*/
class EntityCreateAccessCheck implements AccessInterface {
use DeprecatedServicePropertyTrait;
/**
* {@inheritdoc}
*/
protected $deprecatedProperties = ['entityManager' => 'entity.manager'];
/**
* The entity type manager service.
......@@ -41,13 +34,6 @@ class EntityCreateAccessCheck implements AccessInterface {
* The entity type manager service.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager) {
if ($entity_type_manager instanceof EntityManagerInterface) {
@trigger_error('Passing the entity.manager service to EntityCreateAccessCheck::__construct() is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Pass the new dependencies instead. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
$this->entityTypeManager = \Drupal::entityTypeManager();
}
else {
$this->entityTypeManager = $entity_type_manager;
}
$this->entityTypeManager = $entity_type_manager;
}
......
......@@ -2,7 +2,6 @@
namespace Drupal\Core\Entity;
use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait;
use Drupal\Core\Entity\Schema\DynamicallyFieldableEntityStorageSchemaInterface;
use Drupal\Core\Entity\Schema\EntityStorageSchemaInterface;
use Drupal\Core\Field\BaseFieldDefinition;
......@@ -15,12 +14,6 @@
*/
class EntityDefinitionUpdateManager implements EntityDefinitionUpdateManagerInterface {
use StringTranslationTrait;
use DeprecatedServicePropertyTrait;
/**
* {@inheritdoc}
*/
protected $deprecatedProperties = ['entityManager' => 'entity.manager'];
/**
* The entity field manager service.
......@@ -71,46 +64,12 @@ class EntityDefinitionUpdateManager implements EntityDefinitionUpdateManagerInte
* @param \Drupal\Core\Field\FieldStorageDefinitionListenerInterface $field_storage_definition_listener
* The field storage definition listener service.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager, EntityLastInstalledSchemaRepositoryInterface $entity_last_installed_schema_repository = NULL, EntityFieldManagerInterface $entity_field_manager = NULL, EntityTypeListenerInterface $entity_type_listener = NULL, FieldStorageDefinitionListenerInterface $field_storage_definition_listener = NULL) {
if ($entity_type_manager instanceof EntityManagerInterface) {
@trigger_error('Passing the entity.manager service to EntityDefinitionUpdateManager::__construct() is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Pass the new dependencies instead. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
$this->entityTypeManager = \Drupal::entityTypeManager();
}
else {
$this->entityTypeManager = $entity_type_manager;
}
if ($entity_last_installed_schema_repository) {
$this->entityLastInstalledSchemaRepository = $entity_last_installed_schema_repository;
}
else {
@trigger_error('The entity.last_installed_schema.repository service must be passed to EntityDefinitionUpdateManager::__construct(), it is required before Drupal 9.0.0. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
$this->entityLastInstalledSchemaRepository = \Drupal::service('entity.last_installed_schema.repository');
}
if ($entity_field_manager) {
$this->entityFieldManager = $entity_field_manager;
}
else {
@trigger_error('The entity_field.manager service must be passed to EntityDefinitionUpdateManager::__construct(), it is required before Drupal 9.0.0. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
$this->entityFieldManager = \Drupal::service('entity_field.manager');
}
if ($entity_type_listener) {
$this->entityTypeListener = $entity_type_listener;
}
else {
@trigger_error('The entity_type.listener service must be passed to EntityDefinitionUpdateManager::__construct(), it is required before Drupal 9.0.0. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
$this->entityTypeListener = \Drupal::service('entity_type.listener');
}
if ($field_storage_definition_listener) {
$this->fieldStorageDefinitionListener = $field_storage_definition_listener;
}
else {
@trigger_error('The field_storage_definition.listener service must be passed to EntityDefinitionUpdateManager::__construct(), it is required before Drupal 9.0.0. See https://www.drupal.org/node/2549139.', E_USER_DEPRECATED);
$this->fieldStorageDefinitionListener = \Drupal::service('field_storage_definition.listener');
}
public function __construct(EntityTypeManagerInterface $entity_type_manager, EntityLastInstalledSchemaRepositoryInterface $entity_last_installed_schema_repository, EntityFieldManagerInterface $entity_field_manager, EntityTypeListenerInterface $entity_type_listener, FieldStorageDefinitionListenerInterface $field_storage_definition_listener) {
$this->entityTypeManager = $entity_type_manager;
$this->entityLastInstalledSchemaRepository = $entity_last_installed_schema_repository;
$this->entityFieldManager = $entity_field_manager;
$this->entityTypeListener = $entity_type_listener;
$this->fieldStorageDefinitionListener = $field_storage_definition_listener;
}
/**
......
......@@ -19,9 +19,9 @@
* specified by the current codebase. It also has create/update/delete methods
* to bring the former up to date with the latter.
*
* However, it is not the responsibility of the entity manager to decide how to
* report the differences or when to apply each update. This interface is for
* managing that.
* However, it is not the responsibility of entity last installed schema repository
* to decide how to report the differences or when to apply each update. This
* interface is for managing that.
*
* This interface also provides methods to retrieve instances of the definitions
* to be updated ready to be manipulated. In fact when definitions change in
......
......@@ -32,18 +32,6 @@ class EntityForm extends FormBase implements EntityFormInterface {
*/
protected $moduleHandler;
/**
* The entity manager.
*
* This member exists for BC reasons and should be removed when the
* drupal:9.0.0 branch opens.
*
* @var \Drupal\Core\Entity\EntityManagerInterface
*
* @see https://www.drupal.org/node/2549139
*/
private $privateEntityManager;
/**
* The entity type manager.
*
......@@ -58,32 +46,6 @@ class EntityForm extends FormBase implements EntityFormInterface {
*/
protected $entity;
/**
* {@inheritdoc}
*/
public function __get($name) {
// Removing core's usage of ::setEntityManager means that this deprecated
// service wont be set. We provide it here for backwards compatibility.
if ($name === 'entityManager') {
@trigger_error('EntityForm::entityManager is deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use EntityForm::entityTypeManager instead. See https://www.drupal.org/node/2549139', E_USER_DEPRECATED);
return $this->privateEntityManager ?: \Drupal::entityManager();
}
}
/**
* {@inheritdoc}
*/
public function __set($name, $value) {
// We've changed the entityManager property from protected to private so
// access is funnelled through __get above. This method is provided for BC
// purposes, in case any extended class attempts to set the previously
// accessible property directly.
if ($name === 'entityManager') {
@trigger_error('EntityForm::entityManager is deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use EntityForm::entityTypeManager instead. See https://www.drupal.org/node/2549139', E_USER_DEPRECATED);