Commit ac63952b authored by catch's avatar catch

Issue #2624770 by 20th, Jo Fitzgerald, claudiu.cristea, Berdir, mohit1604,...

Issue #2624770 by 20th, Jo Fitzgerald, claudiu.cristea, Berdir, mohit1604, amateescu, Sutharsan, derheap, Saviktor, Mile23, dawehner, kristiaanvandeneynde, alexpott: Use more specific entity.manager services in core.services.yml
parent d9ccf86f
......@@ -291,7 +291,7 @@ services:
- { name: dynamic_page_cache_response_policy }
config.manager:
class: Drupal\Core\Config\ConfigManager
arguments: ['@entity.manager', '@config.factory', '@config.typed', '@string_translation', '@config.storage', '@event_dispatcher']
arguments: ['@entity_type.manager', '@config.factory', '@config.typed', '@string_translation', '@config.storage', '@event_dispatcher', '@entity.repository']
config.factory:
class: Drupal\Core\Config\ConfigFactory
tags:
......@@ -518,7 +518,7 @@ services:
class: Drupal\Core\Entity\ContentUninstallValidator
tags:
- { name: module_install.uninstall_validator }
arguments: ['@entity.manager', '@string_translation']
arguments: ['@entity_type.manager', '@string_translation']
lazy: true
required_module_uninstall_validator:
class: Drupal\Core\Extension\RequiredModuleUninstallValidator
......@@ -573,12 +573,12 @@ services:
arguments: ['@entity_type.manager', '@entity_type.bundle.info', '@entity_field.manager', '@module_handler']
entity_route_subscriber:
class: Drupal\Core\EventSubscriber\EntityRouteProviderSubscriber
arguments: ['@entity.manager']
arguments: ['@entity_type.manager']
tags:
- { name: event_subscriber }
entity.definition_update_manager:
class: Drupal\Core\Entity\EntityDefinitionUpdateManager
arguments: ['@entity.manager', '@entity.last_installed_schema.repository']
arguments: ['@entity_type.manager', '@entity.last_installed_schema.repository', '@entity_field.manager', '@entity_type.listener', '@field_storage_definition.listener']
entity.last_installed_schema.repository:
class: Drupal\Core\Entity\EntityLastInstalledSchemaRepository
arguments: ['@keyvalue']
......@@ -593,10 +593,10 @@ services:
arguments: ['@entity_type.manager', '@entity_field.manager', '@keyvalue', '@cache.discovery']
entity.form_builder:
class: Drupal\Core\Entity\EntityFormBuilder
arguments: ['@entity.manager', '@form_builder']
arguments: ['@entity_type.manager', '@form_builder']
entity.bundle_config_import_validator:
class: Drupal\Core\Entity\Event\BundleConfigImportValidate
arguments: ['@config.manager', '@entity.manager']
arguments: ['@config.manager', '@entity_type.manager']
tags:
- { name: event_subscriber }
entity.autocomplete_matcher:
......@@ -643,7 +643,7 @@ services:
- { name: needs_destruction }
menu.parent_form_selector:
class: Drupal\Core\Menu\MenuParentFormSelector
arguments: ['@menu.link_tree', '@entity.manager', '@string_translation']
arguments: ['@menu.link_tree', '@entity_type.manager', '@string_translation']
plugin.manager.menu.local_action:
class: Drupal\Core\Menu\LocalActionManager
arguments: ['@http_kernel.controller.argument_resolver', '@request_stack', '@current_route_match', '@router.route_provider', '@module_handler', '@cache.discovery', '@language_manager', '@access_manager', '@current_user']
......@@ -903,7 +903,7 @@ services:
- { name: event_subscriber }
entity.query:
class: Drupal\Core\Entity\Query\QueryFactory
arguments: ['@entity.manager']
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
......@@ -999,7 +999,7 @@ services:
class: Drupal\Core\ParamConverter\EntityConverter
tags:
- { name: paramconverter }
arguments: ['@entity.manager', '@language_manager']
arguments: ['@entity_type.manager', '@language_manager', '@entity.repository']
paramconverter.entity_revision:
class: Drupal\Core\ParamConverter\EntityRevisionParamConverter
tags:
......@@ -1010,7 +1010,7 @@ services:
tags:
# Use a higher priority than EntityConverter, see the class for details.
- { name: paramconverter, priority: 5 }
arguments: ['@entity.manager', '@config.factory', '@router.admin_context']
arguments: ['@entity_type.manager', '@config.factory', '@router.admin_context', '@language_manager', '@entity.repository']
lazy: true
route_subscriber.module:
class: Drupal\Core\EventSubscriber\ModuleRouteSubscriber
......@@ -1019,7 +1019,7 @@ services:
arguments: ['@module_handler']
resolver_manager.entity:
class: Drupal\Core\Entity\EntityResolverManager
arguments: ['@entity.manager', '@class_resolver']
arguments: ['@entity_type.manager', '@class_resolver']
route_subscriber.entity:
class: Drupal\Core\EventSubscriber\EntityRouteAlterSubscriber
tags:
......@@ -1113,7 +1113,7 @@ services:
arguments: ['@http_kernel.controller.argument_resolver', '@form_builder', '@class_resolver']
controller.entity_form:
class: Drupal\Core\Entity\HtmlEntityFormController
arguments: ['@http_kernel.controller.argument_resolver', '@form_builder', '@entity.manager']
arguments: ['@http_kernel.controller.argument_resolver', '@form_builder', '@entity_type.manager']
form_ajax_response_builder:
class: Drupal\Core\Form\FormAjaxResponseBuilder
arguments: ['@main_content_renderer.ajax', '@current_route_match']
......@@ -1157,7 +1157,7 @@ services:
- { name: access_check, applies_to: _entity_access }
access_check.entity_create:
class: Drupal\Core\Entity\EntityCreateAccessCheck
arguments: ['@entity.manager']
arguments: ['@entity_type.manager']
tags:
- { name: access_check, applies_to: _entity_create_access }
access_check.entity_create_any:
......@@ -1412,7 +1412,7 @@ services:
arguments: ['@module_handler']
date.formatter:
class: Drupal\Core\Datetime\DateFormatter
arguments: ['@entity.manager', '@language_manager', '@string_translation', '@config.factory', '@request_stack']
arguments: ['@entity_type.manager', '@language_manager', '@string_translation', '@config.factory', '@request_stack']
feed.bridge.reader:
class: Drupal\Component\Bridge\ZfExtensionManagerSfContainer
calls:
......
......@@ -867,8 +867,8 @@ protected function checkOp($collection, $op, $name) {
// If the target already exists, use the entity storage to delete it
// again, if is a simple config, delete it directly.
if ($entity_type_id = $this->configManager->getEntityTypeIdByName($name)) {
$entity_storage = $this->configManager->getEntityManager()->getStorage($entity_type_id);
$entity_type = $this->configManager->getEntityManager()->getDefinition($entity_type_id);
$entity_storage = $this->configManager->getEntityTypeManager()->getStorage($entity_type_id);
$entity_type = $this->configManager->getEntityTypeManager()->getDefinition($entity_type_id);
$entity = $entity_storage->load($entity_storage->getIDFromConfigName($name, $entity_type->getConfigPrefix()));
$entity->delete();
$this->logError($this->t('Deleted and replaced configuration entity "@name"', ['@name' => $name]));
......@@ -970,7 +970,7 @@ protected function importInvokeOwner($collection, $op, $name) {
}
$method = 'import' . ucfirst($op);
$entity_storage = $this->configManager->getEntityManager()->getStorage($entity_type);
$entity_storage = $this->configManager->getEntityTypeManager()->getStorage($entity_type);
// Call to the configuration entity's storage to handle the configuration
// change.
if (!($entity_storage instanceof ImportableEntityStorageInterface)) {
......@@ -1016,7 +1016,7 @@ protected function importInvokeRename($collection, $rename_name) {
$new_config->setData($data);
}
$entity_storage = $this->configManager->getEntityManager()->getStorage($entity_type_id);
$entity_storage = $this->configManager->getEntityTypeManager()->getStorage($entity_type_id);
// Call to the configuration entity's storage to handle the configuration
// change.
if (!($entity_storage instanceof ImportableEntityStorageInterface)) {
......
......@@ -326,7 +326,7 @@ protected function createConfiguration($collection, array $config_to_create) {
}
/** @var \Drupal\Core\Config\Entity\ConfigEntityStorageInterface $entity_storage */
$entity_storage = $this->configManager
->getEntityManager()
->getEntityTypeManager()
->getStorage($entity_type);
$id = $entity_storage->getIDFromConfigName($name, $entity_storage->getEntityType()->getConfigPrefix());
......
......@@ -6,8 +6,11 @@
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;
use Drupal\Core\Serialization\Yaml;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\StringTranslation\TranslationInterface;
......@@ -18,13 +21,26 @@
*/
class ConfigManager implements ConfigManagerInterface {
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;
/**
* The entity repository.
*
* @var \Drupal\Core\Entity\EntityRepositoryInterface
*/
protected $entityRepository;
/**
* The configuration factory.
......@@ -71,8 +87,8 @@ class ConfigManager implements ConfigManagerInterface {
/**
* Creates ConfigManager objects.
*
* @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\Config\ConfigFactoryInterface $config_factory
* The configuration factory.
* @param \Drupal\Core\Config\TypedConfigManagerInterface $typed_config_manager
......@@ -83,21 +99,36 @@ class ConfigManager implements ConfigManagerInterface {
* The active configuration storage.
* @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher
* The event dispatcher.
* @param \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository
* The entity repository.
*/
public function __construct(EntityManagerInterface $entity_manager, ConfigFactoryInterface $config_factory, TypedConfigManagerInterface $typed_config_manager, TranslationInterface $string_translation, StorageInterface $active_storage, EventDispatcherInterface $event_dispatcher) {
$this->entityManager = $entity_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 = 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;
}
$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');
}
}
/**
* {@inheritdoc}
*/
public function getEntityTypeIdByName($name) {
$entities = array_filter($this->entityManager->getDefinitions(), function (EntityTypeInterface $entity_type) use ($name) {
$entities = array_filter($this->entityTypeManager->getDefinitions(), function (EntityTypeInterface $entity_type) use ($name) {
return ($entity_type instanceof ConfigEntityTypeInterface && $config_prefix = $entity_type->getConfigPrefix()) && strpos($name, $config_prefix . '.') === 0;
});
return key($entities);
......@@ -109,9 +140,9 @@ public function getEntityTypeIdByName($name) {
public function loadConfigEntityByName($name) {
$entity_type_id = $this->getEntityTypeIdByName($name);
if ($entity_type_id) {
$entity_type = $this->entityManager->getDefinition($entity_type_id);
$entity_type = $this->entityTypeManager->getDefinition($entity_type_id);
$id = substr($name, strlen($entity_type->getConfigPrefix()) + 1);
return $this->entityManager->getStorage($entity_type_id)->load($id);
return $this->entityTypeManager->getStorage($entity_type_id)->load($id);
}
return NULL;
}
......@@ -120,7 +151,15 @@ public function loadConfigEntityByName($name) {
* {@inheritdoc}
*/
public function getEntityManager() {
return $this->entityManager;
@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}
*/
public function getEntityTypeManager() {
return $this->entityTypeManager;
}
/**
......@@ -264,7 +303,7 @@ public function findConfigEntityDependents($type, array $names, ConfigDependency
public function findConfigEntityDependentsAsEntities($type, array $names, ConfigDependencyManager $dependency_manager = NULL) {
$dependencies = $this->findConfigEntityDependents($type, $names, $dependency_manager);
$entities = [];
$definitions = $this->entityManager->getDefinitions();
$definitions = $this->entityTypeManager->getDefinitions();
foreach ($dependencies as $config_name => $dependency) {
// Group by entity type to efficient load entities using
// \Drupal\Core\Entity\EntityStorageInterface::loadMultiple().
......@@ -280,7 +319,7 @@ public function findConfigEntityDependentsAsEntities($type, array $names, Config
}
$entities_to_return = [];
foreach ($entities as $entity_type_id => $entities_to_load) {
$storage = $this->entityManager->getStorage($entity_type_id);
$storage = $this->entityTypeManager->getStorage($entity_type_id);
// Remove the keys since there are potential ID clashes from different
// configuration entity types.
$entities_to_return = array_merge($entities_to_return, array_values($storage->loadMultiple($entities_to_load)));
......@@ -440,7 +479,7 @@ protected function callOnDependencyRemoval(ConfigEntityInterface $entity, array
else {
// Ignore the bundle.
list($entity_type_id,, $uuid) = explode(':', $name);
return $this->entityManager->loadEntityByConfigTarget($entity_type_id, $uuid);
return $this->entityRepository->loadEntityByConfigTarget($entity_type_id, $uuid);
}
}, $affected_dependencies[$type]);
}
......@@ -487,7 +526,7 @@ public function findMissingContentDependencies() {
foreach (array_unique($content_dependencies) as $content_dependency) {
// Format of the dependency is entity_type:bundle:uuid.
list($entity_type, $bundle, $uuid) = explode(':', $content_dependency, 3);
if (!$this->entityManager->loadEntityByUuid($entity_type, $uuid)) {
if (!$this->entityRepository->loadEntityByUuid($entity_type, $uuid)) {
$missing_dependencies[$uuid] = [
'entity_type' => $entity_type,
'bundle' => $bundle,
......
......@@ -34,14 +34,26 @@ public function loadConfigEntityByName($name);
*
* @return \Drupal\Core\Entity\EntityManagerInterface
* The entity manager.
*
* @deprecated in Drupal 8.7.x, will be removed before Drupal 9.0.0. Use
* \Drupal\Core\Config\ConfigManagerInterface::getEntityTypeManager()
* instead.
*/
public function getEntityManager();
/**
* Gets the entity type manager.
*
* @return \Drupal\Core\Entity\EntityTypeManagerInterface
* The entity type manager.
*/
public function getEntityTypeManager();
/**
* Gets the config factory.
*
* @return \Drupal\Core\Config\ConfigFactoryInterface
* The entity manager.
* The config factory.
*/
public function getConfigFactory();
......
......@@ -226,7 +226,7 @@ public function onConfigSave(ConfigCrudEvent $event) {
$saved_config = $event->getConfig();
$entity_type_id = $this->configManager->getEntityTypeIdByName($saved_config->getName());
if ($entity_type_id) {
$entity_type = $this->configManager->getEntityManager()->getDefinition($entity_type_id);
$entity_type = $this->configManager->getEntityTypeManager()->getDefinition($entity_type_id);
$this->updateConfigKeyStore($entity_type, $saved_config);
}
}
......@@ -241,7 +241,7 @@ public function onConfigDelete(ConfigCrudEvent $event) {
$saved_config = $event->getConfig();
$entity_type_id = $this->configManager->getEntityTypeIdByName($saved_config->getName());
if ($entity_type_id) {
$entity_type = $this->configManager->getEntityManager()->getDefinition($entity_type_id);
$entity_type = $this->configManager->getEntityTypeManager()->getDefinition($entity_type_id);
$this->deleteConfigKeyStore($entity_type, $saved_config);
}
}
......
......@@ -3,7 +3,7 @@
namespace Drupal\Core\Datetime;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Language\Language;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\StringTranslation\TranslationInterface;
......@@ -78,8 +78,8 @@ class DateFormatter implements DateFormatterInterface {
/**
* Constructs a Date object.
*
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
* The entity manager.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager service.
* @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
* The language manager.
* @param \Drupal\Core\StringTranslation\TranslationInterface $translation
......@@ -89,8 +89,8 @@ class DateFormatter implements DateFormatterInterface {
* @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
* The request stack.
*/
public function __construct(EntityManagerInterface $entity_manager, LanguageManagerInterface $language_manager, TranslationInterface $translation, ConfigFactoryInterface $config_factory, RequestStack $request_stack) {
$this->dateFormatStorage = $entity_manager->getStorage('date_format');
public function __construct(EntityTypeManagerInterface $entity_type_manager, LanguageManagerInterface $language_manager, TranslationInterface $translation, ConfigFactoryInterface $config_factory, RequestStack $request_stack) {
$this->dateFormatStorage = $entity_type_manager->getStorage('date_format');
$this->languageManager = $language_manager;
$this->stringTranslation = $translation;
$this->configFactory = $config_factory;
......
<?php
namespace Drupal\Core\DependencyInjection;
/**
* Provides a standard way to announce deprecated properties.
*/
trait DeprecatedServicePropertyTrait {
/**
* Alows to access deprecated/removed properties.
*
* This method must be public.
*/
public function __get($name) {
if (!isset($this->deprecatedProperties)) {
throw new \LogicException('The deprecatedProperties property must be defined to use this trait.');
}
if (isset($this->deprecatedProperties[$name])) {
$service_name = $this->deprecatedProperties[$name];
$class_name = static::class;
@trigger_error("The property $name ($service_name service) is deprecated in $class_name and will be removed before Drupal 9.0.0.", E_USER_DEPRECATED);
return \Drupal::service($service_name);
}
}
}
......@@ -2,6 +2,7 @@
namespace Drupal\Core\Entity;
use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait;
use Drupal\Core\Extension\ModuleUninstallValidatorInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\StringTranslation\TranslationInterface;
......@@ -12,24 +13,36 @@
*/
class ContentUninstallValidator implements ModuleUninstallValidatorInterface {
use StringTranslationTrait;
use DeprecatedServicePropertyTrait;
/**
* The entity manager.
* {@inheritdoc}
*/
protected $deprecatedProperties = ['entityManager' => 'entity.manager'];
/**
* The entity type manager service.
*
* @var \Drupal\Core\Entity\EntityManagerInterface
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityManager;
protected $entityTypeManager;
/**
* Constructs a new ContentUninstallValidator.
*
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
* The entity manager.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager service.
* @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
* The string translation service.
*/
public function __construct(EntityManagerInterface $entity_manager, TranslationInterface $string_translation) {
$this->entityManager = $entity_manager;
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->stringTranslation = $string_translation;
}
......@@ -37,10 +50,10 @@ public function __construct(EntityManagerInterface $entity_manager, TranslationI
* {@inheritdoc}
*/
public function validate($module) {
$entity_types = $this->entityManager->getDefinitions();
$entity_types = $this->entityTypeManager->getDefinitions();
$reasons = [];
foreach ($entity_types as $entity_type) {
if ($module == $entity_type->getProvider() && $entity_type instanceof ContentEntityTypeInterface && $this->entityManager->getStorage($entity_type->id())->hasData()) {
if ($module == $entity_type->getProvider() && $entity_type instanceof ContentEntityTypeInterface && $this->entityTypeManager->getStorage($entity_type->id())->hasData()) {
$reasons[] = $this->t('There is content for the entity type: @entity_type. <a href=":url">Remove @entity_type_plural</a>.', [
'@entity_type' => $entity_type->getLabel(),
'@entity_type_plural' => $entity_type->getPluralLabel(),
......
......@@ -3,6 +3,7 @@
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;
......@@ -12,13 +13,19 @@
* Defines an access checker for entity creation.
*/
class EntityCreateAccessCheck implements AccessInterface {
use DeprecatedServicePropertyTrait;
/**
* The entity manager.
* {@inheritdoc}
*/
protected $deprecatedProperties = ['entityManager' => 'entity.manager'];
/**
* The entity type manager service.
*
* @var \Drupal\Core\Entity\EntityManagerInterface
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityManager;
protected $entityTypeManager;
/**
* The key used by the routing requirement.
......@@ -30,11 +37,18 @@ class EntityCreateAccessCheck implements AccessInterface {
/**
* Constructs a EntityCreateAccessCheck object.
*
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
* The entity manager.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager service.
*/
public function __construct(EntityManagerInterface $entity_manager) {
$this->entityManager = $entity_manager;
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;
}
/**
......@@ -65,7 +79,7 @@ public function access(Route $route, RouteMatchInterface $route_match, AccountIn
return AccessResult::neutral(sprintf("Could not find '%s' request argument, therefore cannot check create access.", $bundle));
}
}
return $this->entityManager->getAccessControlHandler($entity_type)->createAccess($bundle, $account, [], TRUE);
return $this->entityTypeManager->getAccessControlHandler($entity_type)->createAccess($bundle, $account, [], TRUE);
}
}
......@@ -2,6 +2,7 @@
namespace Drupal\Core\Entity;
use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait;
use Drupal\Core\Form\FormBuilderInterface;
use Drupal\Core\Form\FormState;
......@@ -9,13 +10,19 @@
* Builds entity forms.
*/
class EntityFormBuilder implements EntityFormBuilderInterface {
use DeprecatedServicePropertyTrait;
/**
* The entity manager.
* {@inheritdoc}
*/
protected $deprecatedProperties = ['entityManager' => 'entity.manager'];
/**
* The entity type manager service.
*
* @var \Drupal\Core\Entity\EntityManagerInterface
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityManager;
protected $entityTypeManager;
/**
* The form builder.
......@@ -27,13 +34,19 @@ class EntityFormBuilder implements EntityFormBuilderInterface {
/**
* Constructs a new EntityFormBuilder.
*
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
* The entity manager.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager service.
* @param \Drupal\Core\Form\FormBuilderInterface $form_builder
* The form builder.
*/
public function __construct(EntityManagerInterface $entity_manager, FormBuilderInterface $form_builder) {
$this->entityManager = $entity_manager;
public function __construct(EntityTypeManagerInterface $entity_type_manager, FormBuilderInterface $form_builder) {
if ($entity_type_manager instanceof EntityManagerInterface) {
@trigger_error('Passing the entity.manager service to EntityFormBuilder::__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->formBuilder = $form_builder;
}
......@@ -41,7 +54,7 @@ public function __construct(EntityManagerInterface $entity_manager, FormBuilderI
* {@inheritdoc}
*/
public function getForm(EntityInterface $entity, $operation = 'default', array $form_state_additions = []) {
$form_object = $this->entityManager->getFormObject($entity->getEntityTypeId(), $operation);
$form_object = $this->entityTypeManager->getFormObject($entity->getEntityTypeId(), $operation);
$form_object->setEntity($entity);
$form_state = (new FormState())->setFormState($form_state_additions);
......
......@@ -3,6 +3,7 @@
namespace Drupal\Core\Entity;
use Drupal\Core\DependencyInjection\ClassResolverInterface;
use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait;
use Symfony\Component\Routing\Route;
/**
......@@ -12,13 +13,19 @@
* an entity interface, upcasting is done automatically.
*/
class EntityResolverManager {
use DeprecatedServicePropertyTrait;
/**
* The entity manager.
* {@inheritdoc}
*/
protected $deprecatedProperties = ['entityManager' => 'entity.manager'];
/**
* The entity type manager service.
*
* @var \Drupal\Core\Entity\EntityManagerInterface
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityManager;
protected $entityTypeManager;
/**
* The class resolver.
......@@ -30,13 +37,19 @@ class EntityResolverManager {
/**
* Constructs a new EntityRouteAlterSubscriber.
*
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
* The entity manager.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager service.
* @param \Drupal\Core\DependencyInjection\ClassResolverInterface $class_resolver
* The class resolver.
*/
public function __construct(EntityManagerInterface $entity_manager, ClassResolverInterface $class_resolver) {
$this->entityManager = $entity_manager;
public function __construct(EntityTypeManagerInterface $entity_type_manager, ClassResolverInterface $class_resolver) {
if ($entity_type_manager instanceof EntityManagerInterface) {
@trigger_error('Passing the entity.manager service to EntityResolverManager::__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->classResolver = $class_resolver;
}
......@@ -221,7 +234,7 @@ public function setRouteOptions(Route $route) {
*/
protected function getEntityTypes() {
if (!isset($this->entityTypes)) {
$this->entityTypes = $this->entityManager->getDefinitions();
$this->entityTypes = $this->entityTypeManager->getDefinitions();
}
return $this->entityTypes;
}
......
......@@ -6,12 +6,20 @@
use Drupal\Core\Config\ConfigImportValidateEventSubscriberBase;
use Drupal\Core\Config\ConfigManagerInterface;
use Drupal\Core\Config\Entity\ConfigEntityStorage;
use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
/**
* Entity config importer validation event subscriber.
*/
class BundleConfigImportValidate extends ConfigImportValidateEventSubscriberBase {
use DeprecatedServicePropertyTrait;
/**
* {@inheritdoc}
*/
protected $deprecatedProperties = ['entityManager' => 'entity.manager'];
/**
* The config manager.
......@@ -21,23 +29,29 @@ class BundleConfigImportValidate extends ConfigImportValidateEventSubscriberBase
protected $configManager;
/**
* The entity manager.
* The entity type manager service.
*
* @var \Drupal\Core\Entity\EntityManagerInterface
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityManager;
protected $entityTypeManager;
/**
* Constructs the event subscriber.
*
* @param \Drupal\Core\Config\ConfigManagerInterface $config_manager
* The config manager
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
* The entity manager.