diff --git a/core/core.services.yml b/core/core.services.yml index 8a7aa2f..9bf08f9 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -492,7 +492,7 @@ services: arguments: ['@theme_handler', '@config.factory', '@config.installer', '@module_handler', '@config.manager', '@asset.css.collection_optimizer', '@router.builder', '@logger.channel.default', '@state'] entity.manager: class: Drupal\Core\Entity\EntityManager - arguments: ['@entity_type.manager', '@entity_type.repository', '@entity_type.bundle.manager', '@entity_display.repository', '@entity_field.manager', '@entity_definition.repository', '@entity.repository', '@entity_type.listener', '@entity_bundle.listener', '@field_storage_definition.listener', '@field_definition.listener'] + arguments: ['@entity_type.manager', '@entity_type.repository', '@entity_type.bundle.info', '@entity_display.repository', '@entity_field_definition.repository', '@entity_definition.repository', '@entity.repository', '@entity_type.listener', '@entity_bundle.listener', '@field_storage_definition.listener', '@field_definition.listener'] # @todo Remove this tag in https://www.drupal.org/node/2549143. tags: - { name: plugin_manager_cache_clear } @@ -505,8 +505,8 @@ services: entity_type.repository: class: Drupal\Core\Entity\EntityTypeRepository arguments: ['@entity_type.manager'] - entity_type.bundle.manager: - class: Drupal\Core\Entity\EntityTypeBundleManager + entity_type.bundle.info: + class: Drupal\Core\Entity\EntityTypeBundleInfo arguments: ['@entity_type.manager', '@language_manager', '@module_handler', '@typed_data_manager', '@cache.discovery'] entity.repository: class: Drupal\Core\Entity\EntityRepository @@ -514,15 +514,15 @@ services: entity_display.repository: class: Drupal\Core\Entity\EntityDisplayRepository arguments: ['@entity_type.manager', '@module_handler', '@cache.discovery', '@language_manager'] - entity_field.manager: - class: Drupal\Core\Entity\EntityFieldManager - arguments: ['@entity_type.manager', '@entity_type.bundle.manager', '@entity_display.repository', '@typed_data_manager', '@language_manager', '@keyvalue', '@module_handler', '@cache.discovery'] + entity_field_definition.repository: + class: Drupal\Core\Entity\EntityFieldDefinitionRepository + arguments: ['@entity_type.manager', '@entity_type.bundle.info', '@entity_display.repository', '@typed_data_manager', '@language_manager', '@keyvalue', '@module_handler', '@cache.discovery'] entity_type.listener: class: Drupal\Core\Entity\EntityTypeListener - arguments: ['@entity_type.manager', '@entity_field.manager', '@event_dispatcher', '@entity_definition.repository'] + arguments: ['@entity_type.manager', '@entity_field_definition.repository', '@event_dispatcher', '@entity_definition.repository'] entity_bundle.listener: class: Drupal\Core\Entity\EntityBundleListener - arguments: ['@entity_type.manager', '@entity_type.bundle.manager', '@entity_field.manager', '@module_handler'] + arguments: ['@entity_type.manager', '@entity_type.bundle.info', '@entity_field_definition.repository', '@module_handler'] entity_route_subscriber: class: Drupal\Core\EventSubscriber\EntityRouteProviderSubscriber arguments: ['@entity.manager'] @@ -532,14 +532,14 @@ services: class: Drupal\Core\Entity\EntityDefinitionUpdateManager arguments: ['@entity.manager'] entity_definition.repository: - class: Drupal\Core\Entity\EntityInstalledDefinitionRepository + class: Drupal\Core\Entity\EntityDefinitionRepository arguments: ['@keyvalue'] field_storage_definition.listener: class: Drupal\Core\Field\FieldStorageDefinitionListener - arguments: ['@entity_type.manager', '@event_dispatcher', '@entity_definition.repository', '@entity_field.manager'] + arguments: ['@entity_type.manager', '@event_dispatcher', '@entity_definition.repository', '@entity_field_definition.repository'] field_definition.listener: class: Drupal\Core\Field\FieldDefinitionListener - arguments: ['@entity_type.manager', '@entity_field.manager', '@keyvalue', '@cache.discovery'] + arguments: ['@entity_type.manager', '@entity_field_definition.repository', '@keyvalue', '@cache.discovery'] entity.form_builder: class: Drupal\Core\Entity\EntityFormBuilder arguments: ['@entity.manager', '@form_builder'] diff --git a/core/lib/Drupal/Core/Entity/EntityBundleListener.php b/core/lib/Drupal/Core/Entity/EntityBundleListener.php index 78f3ad7..efaeab6 100644 --- a/core/lib/Drupal/Core/Entity/EntityBundleListener.php +++ b/core/lib/Drupal/Core/Entity/EntityBundleListener.php @@ -22,18 +22,18 @@ class EntityBundleListener implements EntityBundleListenerInterface { protected $entityTypeManager; /** - * The entity type bundle manager. + * The entity type bundle info. * - * @var \Drupal\Core\Entity\EntityTypeBundleManagerInterface + * @var \Drupal\Core\Entity\EntityTypeBundleInfoInterface */ - protected $entityTypeBundleManager; + protected $entityTypeBundleInfo; /** - * The entity field manager. + * The entity field definition repository. * - * @var \Drupal\Core\Entity\EntityFieldManagerInterface + * @var \Drupal\Core\Entity\EntityFieldDefinitionRepositoryInterface */ - protected $entityFieldManager; + protected $entityFieldDefinitionRepository; /** * The module handler. @@ -47,17 +47,17 @@ class EntityBundleListener implements EntityBundleListenerInterface { * * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager * The entity type manager. - * @param \Drupal\Core\Entity\EntityTypeBundleManagerInterface $entity_type_bundle_manager - * The entity type bundle manager. - * @param \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager - * The entity field manager. + * @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface $entity_type_bundle_info + * The entity type bundle info. + * @param \Drupal\Core\Entity\EntityFieldDefinitionRepositoryInterface $entity_field_definition_repository + * The entity field definition repository. * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler. */ - public function __construct(EntityTypeManagerInterface $entity_type_manager, EntityTypeBundleManagerInterface $entity_type_bundle_manager, EntityFieldManagerInterface $entity_field_manager, ModuleHandlerInterface $module_handler) { + public function __construct(EntityTypeManagerInterface $entity_type_manager, EntityTypeBundleInfoInterface $entity_type_bundle_info, EntityFieldDefinitionRepositoryInterface $entity_field_definition_repository, ModuleHandlerInterface $module_handler) { $this->entityTypeManager = $entity_type_manager; - $this->entityTypeBundleManager = $entity_type_bundle_manager; - $this->entityFieldManager = $entity_field_manager; + $this->entityTypeBundleInfo = $entity_type_bundle_info; + $this->entityFieldDefinitionRepository = $entity_field_definition_repository; $this->moduleHandler = $module_handler; } @@ -65,7 +65,7 @@ public function __construct(EntityTypeManagerInterface $entity_type_manager, Ent * {@inheritdoc} */ public function onBundleCreate($bundle, $entity_type_id) { - $this->entityTypeBundleManager->clearCachedBundles(); + $this->entityTypeBundleInfo->clearCachedBundles(); // Notify the entity storage. $storage = $this->entityTypeManager->getStorage($entity_type_id); if ($storage instanceof EntityBundleListenerInterface) { @@ -79,7 +79,7 @@ public function onBundleCreate($bundle, $entity_type_id) { * {@inheritdoc} */ public function onBundleDelete($bundle, $entity_type_id) { - $this->entityTypeBundleManager->clearCachedBundles(); + $this->entityTypeBundleInfo->clearCachedBundles(); // Notify the entity storage. $storage = $this->entityTypeManager->getStorage($entity_type_id); if ($storage instanceof EntityBundleListenerInterface) { @@ -87,7 +87,7 @@ public function onBundleDelete($bundle, $entity_type_id) { } // Invoke hook_entity_bundle_delete() hook. $this->moduleHandler->invokeAll('entity_bundle_delete', [$entity_type_id, $bundle]); - $this->entityFieldManager->clearCachedFieldDefinitions(); + $this->entityFieldDefinitionRepository->clearCachedFieldDefinitions(); } } diff --git a/core/lib/Drupal/Core/Entity/EntityInstalledDefinitionRepository.php b/core/lib/Drupal/Core/Entity/EntityDefinitionRepository.php similarity index 91% rename from core/lib/Drupal/Core/Entity/EntityInstalledDefinitionRepository.php rename to core/lib/Drupal/Core/Entity/EntityDefinitionRepository.php index 78e04f0..9bc3d9b 100644 --- a/core/lib/Drupal/Core/Entity/EntityInstalledDefinitionRepository.php +++ b/core/lib/Drupal/Core/Entity/EntityDefinitionRepository.php @@ -2,7 +2,7 @@ /** * @file - * Contains \Drupal\Core\Entity\EntityInstalledDefinitionRepository. + * Contains \Drupal\Core\Entity\EntityDefinitionRepository. */ namespace Drupal\Core\Entity; @@ -11,9 +11,9 @@ use Drupal\Core\KeyValueStore\KeyValueFactoryInterface; /** - * Provides a repository for installed entity definitions. + * Provides a repository for entity definitions. */ -class EntityInstalledDefinitionRepository implements EntityInstalledDefinitionRepositoryInterface { +class EntityDefinitionRepository implements EntityDefinitionRepositoryInterface { /** * The key-value factory. @@ -23,7 +23,7 @@ class EntityInstalledDefinitionRepository implements EntityInstalledDefinitionRe protected $keyValueFactory; /** - * Constructs a new EntityInstalledDefinitionRepository. + * Constructs a new EntityDefinitionRepository. * * @param \Drupal\Core\KeyValueStore\KeyValueFactoryInterface $key_value_factory * The key-value factory. diff --git a/core/lib/Drupal/Core/Entity/EntityInstalledDefinitionRepositoryInterface.php b/core/lib/Drupal/Core/Entity/EntityDefinitionRepositoryInterface.php similarity index 95% rename from core/lib/Drupal/Core/Entity/EntityInstalledDefinitionRepositoryInterface.php rename to core/lib/Drupal/Core/Entity/EntityDefinitionRepositoryInterface.php index 326adba..0c43dc6 100644 --- a/core/lib/Drupal/Core/Entity/EntityInstalledDefinitionRepositoryInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityDefinitionRepositoryInterface.php @@ -2,7 +2,7 @@ /** * @file - * Contains \Drupal\Core\Entity\EntityInstalledDefinitionRepositoryInterface. + * Contains \Drupal\Core\Entity\EntityDefinitionRepositoryInterface. */ namespace Drupal\Core\Entity; @@ -10,9 +10,9 @@ use Drupal\Core\Field\FieldStorageDefinitionInterface; /** - * Provides an interface for an installed entity definition repository. + * Provides an interface for an entity definition repository. */ -interface EntityInstalledDefinitionRepositoryInterface { +interface EntityDefinitionRepositoryInterface { /** * Gets the entity type definition in its most recently installed state. diff --git a/core/lib/Drupal/Core/Entity/EntityFieldManager.php b/core/lib/Drupal/Core/Entity/EntityFieldDefinitionRepository.php similarity index 95% rename from core/lib/Drupal/Core/Entity/EntityFieldManager.php rename to core/lib/Drupal/Core/Entity/EntityFieldDefinitionRepository.php index 9aa8d23..25b3c04 100644 --- a/core/lib/Drupal/Core/Entity/EntityFieldManager.php +++ b/core/lib/Drupal/Core/Entity/EntityFieldDefinitionRepository.php @@ -2,7 +2,7 @@ /** * @file - * Contains \Drupal\Core\Entity\EntityFieldManager. + * Contains \Drupal\Core\Entity\EntityFieldDefinitionRepository. */ namespace Drupal\Core\Entity; @@ -18,12 +18,12 @@ use Drupal\Core\TypedData\TypedDataManager; /** - * Manages the discovery of entity fields. + * Provides a repository for entity fields (field definitions and their storage). * * This includes field definitions, base field definitions, and field storage * definitions. */ -class EntityFieldManager implements EntityFieldManagerInterface { +class EntityFieldDefinitionRepository implements EntityFieldDefinitionRepositoryInterface { use CacheBackendTrait; use StringTranslationTrait; @@ -115,11 +115,11 @@ class EntityFieldManager implements EntityFieldManagerInterface { protected $entityTypeManager; /** - * The entity type bundle manager. + * The entity type bundle info. * - * @var \Drupal\Core\Entity\EntityTypeBundleManagerInterface + * @var \Drupal\Core\Entity\EntityTypeBundleInfoInterface */ - protected $entityTypeBundleManager; + protected $entityTypeBundleInfo; /** * The entity display repository. @@ -129,12 +129,12 @@ class EntityFieldManager implements EntityFieldManagerInterface { protected $entityDisplayRepository; /** - * Constructs a new EntityFieldManager. + * Constructs a new EntityFieldDefinitionRepository. * * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager * The entity type manager. - * @param \Drupal\Core\Entity\EntityTypeBundleManagerInterface $entity_type_bundle_manager - * The entity type bundle manager. + * @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface $entity_type_bundle_info + * The entity type bundle info. * @param \Drupal\Core\Entity\EntityDisplayRepositoryInterface $entity_display_repository * The entity display repository. * @param \Drupal\Core\TypedData\TypedDataManager $typed_data_manager @@ -148,9 +148,9 @@ class EntityFieldManager implements EntityFieldManagerInterface { * @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend * The cache backend. */ - public function __construct(EntityTypeManagerInterface $entity_type_manager, EntityTypeBundleManagerInterface $entity_type_bundle_manager, EntityDisplayRepositoryInterface $entity_display_repository, TypedDataManager $typed_data_manager, LanguageManagerInterface $language_manager, KeyValueFactoryInterface $key_value_factory, ModuleHandlerInterface $module_handler, CacheBackendInterface $cache_backend) { + public function __construct(EntityTypeManagerInterface $entity_type_manager, EntityTypeBundleInfoInterface $entity_type_bundle_info, EntityDisplayRepositoryInterface $entity_display_repository, TypedDataManager $typed_data_manager, LanguageManagerInterface $language_manager, KeyValueFactoryInterface $key_value_factory, ModuleHandlerInterface $module_handler, CacheBackendInterface $cache_backend) { $this->entityTypeManager = $entity_type_manager; - $this->entityTypeBundleManager = $entity_type_bundle_manager; + $this->entityTypeBundleInfo = $entity_type_bundle_info; $this->entityDisplayRepository = $entity_display_repository; $this->typedDataManager = $typed_data_manager; @@ -441,7 +441,7 @@ public function getFieldMap() { // types for this to become a bottleneck. foreach ($this->entityTypeManager->getDefinitions() as $entity_type_id => $entity_type) { if ($entity_type->isSubclassOf(FieldableEntityInterface::class)) { - $bundles = array_keys($this->entityTypeBundleManager->getBundleInfo($entity_type_id)); + $bundles = array_keys($this->entityTypeBundleInfo->getBundleInfo($entity_type_id)); foreach ($this->getBaseFieldDefinitions($entity_type_id) as $field_name => $base_field_definition) { $this->fieldMap[$entity_type_id][$field_name] = [ 'type' => $base_field_definition->getType(), diff --git a/core/lib/Drupal/Core/Entity/EntityFieldManagerInterface.php b/core/lib/Drupal/Core/Entity/EntityFieldDefinitionRepositoryInterface.php similarity index 96% rename from core/lib/Drupal/Core/Entity/EntityFieldManagerInterface.php rename to core/lib/Drupal/Core/Entity/EntityFieldDefinitionRepositoryInterface.php index 5db64dd..9c04105 100644 --- a/core/lib/Drupal/Core/Entity/EntityFieldManagerInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityFieldDefinitionRepositoryInterface.php @@ -2,15 +2,15 @@ /** * @file - * Contains \Drupal\Core\Entity\EntityFieldManagerInterface. + * Contains \Drupal\Core\Entity\EntityFieldDefinitionRepositoryInterface. */ namespace Drupal\Core\Entity; /** - * Provides an interface for an entity field manager. + * Provides an interface for an entity field definition repository. */ -interface EntityFieldManagerInterface { +interface EntityFieldDefinitionRepositoryInterface { /** * Gets the base field definitions for a content entity type. diff --git a/core/lib/Drupal/Core/Entity/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php index 246ee7f..a85f733 100644 --- a/core/lib/Drupal/Core/Entity/EntityManager.php +++ b/core/lib/Drupal/Core/Entity/EntityManager.php @@ -37,11 +37,11 @@ class EntityManager implements EntityManagerInterface { protected $entityTypeRepository; /** - * The entity type bundle manager. + * The entity type bundle info. * - * @var \Drupal\Core\Entity\EntityTypeBundleManagerInterface + * @var \Drupal\Core\Entity\EntityTypeBundleInfoInterface */ - protected $entityTypeBundleManager; + protected $entityTypeBundleInfo; /** * The entity display repository. @@ -51,11 +51,11 @@ class EntityManager implements EntityManagerInterface { protected $entityDisplayRepository; /** - * The entity field manager. + * The entity field definition repository. * - * @var \Drupal\Core\Entity\EntityFieldManagerInterface + * @var \Drupal\Core\Entity\EntityFieldDefinitionRepositoryInterface */ - protected $entityFieldManager; + protected $entityFieldDefinitionRepository; /** * The entity type listener. @@ -67,9 +67,9 @@ class EntityManager implements EntityManagerInterface { /** * The entity definition manager. * - * @var \Drupal\Core\Entity\EntityInstalledDefinitionRepositoryInterface + * @var \Drupal\Core\Entity\EntityDefinitionRepositoryInterface */ - protected $entityInstalledDefinitionRepository; + protected $entityDefinitionRepository; /** * The entity bundle listener. @@ -106,13 +106,13 @@ class EntityManager implements EntityManagerInterface { * The entity type manager. * @param \Drupal\Core\Entity\EntityTypeRepositoryInterface $entity_type_repository * The entity type repository. - * @param \Drupal\Core\Entity\EntityTypeBundleManagerInterface $entity_type_bundle_manager - * The entity type bundle manager. + * @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface $entity_type_bundle_info + * The entity type bundle info. * @param \Drupal\Core\Entity\EntityDisplayRepositoryInterface $entity_display_repository * The entity display repository. - * @param \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager - * The entity field manager. - * @param \Drupal\Core\Entity\EntityInstalledDefinitionRepositoryInterface $entity_installed_definition_repository + * @param \Drupal\Core\Entity\EntityFieldDefinitionRepositoryInterface $entity_field_definition_repository + * The entity field definition repository. + * @param \Drupal\Core\Entity\EntityDefinitionRepositoryInterface $entity_definition_repository * The entity definition repository. * @param \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository * The entity repository. @@ -125,14 +125,14 @@ class EntityManager implements EntityManagerInterface { * @param \Drupal\Core\Field\FieldDefinitionListenerInterface $field_definition_listener * The field definition listener. */ - public function __construct(EntityTypeManagerInterface $entity_type_manager, EntityTypeRepositoryInterface $entity_type_repository, EntityTypeBundleManagerInterface $entity_type_bundle_manager, EntityDisplayRepositoryInterface $entity_display_repository, EntityFieldManagerInterface $entity_field_manager, EntityInstalledDefinitionRepositoryInterface $entity_installed_definition_repository, EntityRepositoryInterface $entity_repository, EntityTypeListenerInterface $entity_type_listener, EntityBundleListenerInterface $entity_bundle_listener, FieldStorageDefinitionListenerInterface $field_storage_definition_listener, FieldDefinitionListenerInterface $field_definition_listener) { + public function __construct(EntityTypeManagerInterface $entity_type_manager, EntityTypeRepositoryInterface $entity_type_repository, EntityTypeBundleInfoInterface $entity_type_bundle_info, EntityDisplayRepositoryInterface $entity_display_repository, EntityFieldDefinitionRepositoryInterface $entity_field_definition_repository, EntityDefinitionRepositoryInterface $entity_definition_repository, EntityRepositoryInterface $entity_repository, EntityTypeListenerInterface $entity_type_listener, EntityBundleListenerInterface $entity_bundle_listener, FieldStorageDefinitionListenerInterface $field_storage_definition_listener, FieldDefinitionListenerInterface $field_definition_listener) { $this->entityTypeManager = $entity_type_manager; $this->entityTypeRepository = $entity_type_repository; - $this->entityTypeBundleManager = $entity_type_bundle_manager; + $this->entityTypeBundleInfo = $entity_type_bundle_info; $this->entityDisplayRepository = $entity_display_repository; - $this->entityFieldManager = $entity_field_manager; - $this->entityInstalledDefinitionRepository = $entity_installed_definition_repository; + $this->entityFieldDefinitionRepository = $entity_field_definition_repository; + $this->entityDefinitionRepository = $entity_definition_repository; $this->entityRepository = $entity_repository; $this->entityTypeListener = $entity_type_listener; @@ -153,8 +153,8 @@ public function clearCachedDefinitions() { // @todo None of these are plugin managers, and they should not co-opt // this method for managing its caches. Remove in // https://www.drupal.org/node/2549143. - $this->entityTypeBundleManager->clearCachedBundles(); - $this->entityFieldManager->clearCachedFieldDefinitions(); + $this->entityTypeBundleInfo->clearCachedBundles(); + $this->entityFieldDefinitionRepository->clearCachedFieldDefinitions(); $this->entityTypeRepository->clearCachedDefinitions(); } @@ -254,7 +254,7 @@ public function createHandlerInstance($class, EntityTypeInterface $definition = * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0. */ public function getBaseFieldDefinitions($entity_type_id) { - return $this->entityFieldManager->getBaseFieldDefinitions($entity_type_id); + return $this->entityFieldDefinitionRepository->getBaseFieldDefinitions($entity_type_id); } /** @@ -263,7 +263,7 @@ public function getBaseFieldDefinitions($entity_type_id) { * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0. */ public function getFieldDefinitions($entity_type_id, $bundle) { - return $this->entityFieldManager->getFieldDefinitions($entity_type_id, $bundle); + return $this->entityFieldDefinitionRepository->getFieldDefinitions($entity_type_id, $bundle); } /** @@ -272,7 +272,7 @@ public function getFieldDefinitions($entity_type_id, $bundle) { * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0. */ public function getFieldStorageDefinitions($entity_type_id) { - return $this->entityFieldManager->getFieldStorageDefinitions($entity_type_id); + return $this->entityFieldDefinitionRepository->getFieldStorageDefinitions($entity_type_id); } /** @@ -281,7 +281,7 @@ public function getFieldStorageDefinitions($entity_type_id) { * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0. */ public function setFieldMap(array $field_map) { - return $this->entityFieldManager->setFieldMap($field_map); + return $this->entityFieldDefinitionRepository->setFieldMap($field_map); } /** @@ -290,7 +290,7 @@ public function setFieldMap(array $field_map) { * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0. */ public function getFieldMap() { - return $this->entityFieldManager->getFieldMap(); + return $this->entityFieldDefinitionRepository->getFieldMap(); } /** @@ -299,7 +299,7 @@ public function getFieldMap() { * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0. */ public function getFieldMapByFieldType($field_type) { - return $this->entityFieldManager->getFieldMapByFieldType($field_type); + return $this->entityFieldDefinitionRepository->getFieldMapByFieldType($field_type); } /** @@ -335,7 +335,7 @@ public function onFieldDefinitionDelete(FieldDefinitionInterface $field_definiti * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0. */ public function clearCachedFieldDefinitions() { - return $this->entityFieldManager->clearCachedFieldDefinitions(); + return $this->entityFieldDefinitionRepository->clearCachedFieldDefinitions(); } /** @@ -344,7 +344,7 @@ public function clearCachedFieldDefinitions() { * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0. */ public function clearCachedBundles() { - $this->entityTypeBundleManager->clearCachedBundles(); + $this->entityTypeBundleInfo->clearCachedBundles(); } /** @@ -353,7 +353,7 @@ public function clearCachedBundles() { * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0. */ public function getBundleInfo($entity_type) { - return $this->entityTypeBundleManager->getBundleInfo($entity_type); + return $this->entityTypeBundleInfo->getBundleInfo($entity_type); } /** @@ -362,14 +362,14 @@ public function getBundleInfo($entity_type) { * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0. */ public function getAllBundleInfo() { - return $this->entityTypeBundleManager->getAllBundleInfo(); + return $this->entityTypeBundleInfo->getAllBundleInfo(); } /** * {@inheritdoc} */ public function getExtraFields($entity_type_id, $bundle) { - return $this->entityFieldManager->getExtraFields($entity_type_id, $bundle); + return $this->entityFieldDefinitionRepository->getExtraFields($entity_type_id, $bundle); } /** @@ -574,7 +574,7 @@ public function onBundleDelete($bundle, $entity_type_id) { * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0. */ public function getLastInstalledDefinition($entity_type_id) { - return $this->entityInstalledDefinitionRepository->getLastInstalledDefinition($entity_type_id); + return $this->entityDefinitionRepository->getLastInstalledDefinition($entity_type_id); } /** @@ -583,9 +583,9 @@ public function getLastInstalledDefinition($entity_type_id) { public function useCaches($use_caches = FALSE) { $this->entityTypeManager->useCaches($use_caches); - // @todo EntityFieldManager is not a plugin manager, and should not co-opt + // @todo EntityFieldDefinitionRepository is not a plugin manager, and should not co-opt // this method for managing its caches. - $this->entityFieldManager->useCaches($use_caches); + $this->entityFieldDefinitionRepository->useCaches($use_caches); } /** @@ -594,7 +594,7 @@ public function useCaches($use_caches = FALSE) { * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0. */ public function getLastInstalledFieldStorageDefinitions($entity_type_id) { - return $this->entityInstalledDefinitionRepository->getLastInstalledFieldStorageDefinitions($entity_type_id); + return $this->entityDefinitionRepository->getLastInstalledFieldStorageDefinitions($entity_type_id); } /** diff --git a/core/lib/Drupal/Core/Entity/EntityManagerInterface.php b/core/lib/Drupal/Core/Entity/EntityManagerInterface.php index d415063..8f3b557 100644 --- a/core/lib/Drupal/Core/Entity/EntityManagerInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityManagerInterface.php @@ -15,17 +15,17 @@ * * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0. */ -interface EntityManagerInterface extends EntityTypeListenerInterface, EntityBundleListenerInterface, FieldStorageDefinitionListenerInterface, FieldDefinitionListenerInterface, EntityTypeManagerInterface, EntityTypeRepositoryInterface, EntityTypeBundleManagerInterface, EntityDisplayRepositoryInterface, EntityFieldManagerInterface, EntityRepositoryInterface { +interface EntityManagerInterface extends EntityTypeListenerInterface, EntityBundleListenerInterface, FieldStorageDefinitionListenerInterface, FieldDefinitionListenerInterface, EntityTypeManagerInterface, EntityTypeRepositoryInterface, EntityTypeBundleInfoInterface, EntityDisplayRepositoryInterface, EntityFieldDefinitionRepositoryInterface, EntityRepositoryInterface { /** - * @see \Drupal\Core\Entity\EntityInstalledDefinitionRepositoryInterface::getLastInstalledDefinition() + * @see \Drupal\Core\Entity\EntityDefinitionRepositoryInterface::getLastInstalledDefinition() * * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0. */ public function getLastInstalledDefinition($entity_type_id); /** - * @see \Drupal\Core\Entity\EntityInstalledDefinitionRepositoryInterface::getLastInstalledFieldStorageDefinitions() + * @see \Drupal\Core\Entity\EntityDefinitionRepositoryInterface::getLastInstalledFieldStorageDefinitions() * * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0. */ diff --git a/core/lib/Drupal/Core/Entity/EntityTypeBundleManager.php b/core/lib/Drupal/Core/Entity/EntityTypeBundleInfo.php similarity index 95% rename from core/lib/Drupal/Core/Entity/EntityTypeBundleManager.php rename to core/lib/Drupal/Core/Entity/EntityTypeBundleInfo.php index b994dd6..a98a4f6 100644 --- a/core/lib/Drupal/Core/Entity/EntityTypeBundleManager.php +++ b/core/lib/Drupal/Core/Entity/EntityTypeBundleInfo.php @@ -2,7 +2,7 @@ /** * @file - * Contains \Drupal\Core\Entity\EntityTypeBundleManager. + * Contains \Drupal\Core\Entity\EntityTypeBundleInfo. */ namespace Drupal\Core\Entity; @@ -17,7 +17,7 @@ /** * Provides discovery and retrieval of entity type bundles. */ -class EntityTypeBundleManager implements EntityTypeBundleManagerInterface { +class EntityTypeBundleInfo implements EntityTypeBundleInfoInterface { use CacheBackendTrait; @@ -57,7 +57,7 @@ class EntityTypeBundleManager implements EntityTypeBundleManagerInterface { protected $entityTypeManager; /** - * Constructs a new EntityTypeBundleManager. + * Constructs a new EntityTypeBundleInfo. * * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager * The entity type manager. diff --git a/core/lib/Drupal/Core/Entity/EntityTypeBundleManagerInterface.php b/core/lib/Drupal/Core/Entity/EntityTypeBundleInfoInterface.php similarity index 77% rename from core/lib/Drupal/Core/Entity/EntityTypeBundleManagerInterface.php rename to core/lib/Drupal/Core/Entity/EntityTypeBundleInfoInterface.php index 563f6cd..40b0c1f 100644 --- a/core/lib/Drupal/Core/Entity/EntityTypeBundleManagerInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityTypeBundleInfoInterface.php @@ -2,15 +2,15 @@ /** * @file - * Contains \Drupal\Core\Entity\EntityTypeBundleManagerInterface. + * Contains \Drupal\Core\Entity\EntityTypeBundleInfoInterface. */ namespace Drupal\Core\Entity; /** - * Provides an interface for an entity type bundle manager. + * Provides an interface for an entity type bundle info. */ -interface EntityTypeBundleManagerInterface { +interface EntityTypeBundleInfoInterface { /** * Get the bundle info of all entity types. diff --git a/core/lib/Drupal/Core/Entity/EntityTypeListener.php b/core/lib/Drupal/Core/Entity/EntityTypeListener.php index e7f0546..247fca3 100644 --- a/core/lib/Drupal/Core/Entity/EntityTypeListener.php +++ b/core/lib/Drupal/Core/Entity/EntityTypeListener.php @@ -22,11 +22,11 @@ class EntityTypeListener implements EntityTypeListenerInterface { protected $entityTypeManager; /** - * The entity field manager. + * The entity field definition repository. * - * @var \Drupal\Core\Entity\EntityFieldManagerInterface + * @var \Drupal\Core\Entity\EntityFieldDefinitionRepositoryInterface */ - protected $entityFieldManager; + protected $entityFieldDefinitionRepository; /** * The event dispatcher. @@ -38,27 +38,27 @@ class EntityTypeListener implements EntityTypeListenerInterface { /** * The entity definition repository. * - * @var \Drupal\Core\Entity\EntityInstalledDefinitionRepositoryInterface + * @var \Drupal\Core\Entity\EntityDefinitionRepositoryInterface */ - protected $entityInstalledDefinitionRepository; + protected $entityDefinitionRepository; /** * Constructs a new EntityTypeListener. * * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager * The entity type manager. - * @param \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager - * The entity field manager. + * @param \Drupal\Core\Entity\EntityFieldDefinitionRepositoryInterface $entity_field_definition_repository + * The entity field definition repository. * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher * The event dispatcher. - * @param \Drupal\Core\Entity\EntityInstalledDefinitionRepositoryInterface $entity_installed_definition_repository + * @param \Drupal\Core\Entity\EntityDefinitionRepositoryInterface $entity_definition_repository * The entity definition repository. */ - public function __construct(EntityTypeManagerInterface $entity_type_manager, EntityFieldManagerInterface $entity_field_manager, EventDispatcherInterface $event_dispatcher, EntityInstalledDefinitionRepositoryInterface $entity_installed_definition_repository) { + public function __construct(EntityTypeManagerInterface $entity_type_manager, EntityFieldDefinitionRepositoryInterface $entity_field_definition_repository, EventDispatcherInterface $event_dispatcher, EntityDefinitionRepositoryInterface $entity_definition_repository) { $this->entityTypeManager = $entity_type_manager; - $this->entityFieldManager = $entity_field_manager; + $this->entityFieldDefinitionRepository = $entity_field_definition_repository; $this->eventDispatcher = $event_dispatcher; - $this->entityInstalledDefinitionRepository = $entity_installed_definition_repository; + $this->entityDefinitionRepository = $entity_definition_repository; } /** @@ -76,9 +76,9 @@ public function onEntityTypeCreate(EntityTypeInterface $entity_type) { $this->eventDispatcher->dispatch(EntityTypeEvents::CREATE, new EntityTypeEvent($entity_type)); - $this->entityInstalledDefinitionRepository->setLastInstalledDefinition($entity_type); + $this->entityDefinitionRepository->setLastInstalledDefinition($entity_type); if ($entity_type->isSubclassOf(FieldableEntityInterface::class)) { - $this->entityInstalledDefinitionRepository->setLastInstalledFieldStorageDefinitions($entity_type_id, $this->entityFieldManager->getFieldStorageDefinitions($entity_type_id)); + $this->entityDefinitionRepository->setLastInstalledFieldStorageDefinitions($entity_type_id, $this->entityFieldDefinitionRepository->getFieldStorageDefinitions($entity_type_id)); } } @@ -97,7 +97,7 @@ public function onEntityTypeUpdate(EntityTypeInterface $entity_type, EntityTypeI $this->eventDispatcher->dispatch(EntityTypeEvents::UPDATE, new EntityTypeEvent($entity_type, $original)); - $this->entityInstalledDefinitionRepository->setLastInstalledDefinition($entity_type); + $this->entityDefinitionRepository->setLastInstalledDefinition($entity_type); } /** @@ -115,7 +115,7 @@ public function onEntityTypeDelete(EntityTypeInterface $entity_type) { $this->eventDispatcher->dispatch(EntityTypeEvents::DELETE, new EntityTypeEvent($entity_type)); - $this->entityInstalledDefinitionRepository->deleteLastInstalledDefinition($entity_type_id); + $this->entityDefinitionRepository->deleteLastInstalledDefinition($entity_type_id); } } diff --git a/core/lib/Drupal/Core/Field/FieldDefinitionListener.php b/core/lib/Drupal/Core/Field/FieldDefinitionListener.php index bd303ad..c09b7db 100644 --- a/core/lib/Drupal/Core/Field/FieldDefinitionListener.php +++ b/core/lib/Drupal/Core/Field/FieldDefinitionListener.php @@ -8,7 +8,7 @@ namespace Drupal\Core\Field; use Drupal\Core\Cache\CacheBackendInterface; -use Drupal\Core\Entity\EntityFieldManagerInterface; +use Drupal\Core\Entity\EntityFieldDefinitionRepositoryInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\KeyValueStore\KeyValueFactoryInterface; @@ -39,27 +39,27 @@ class FieldDefinitionListener implements FieldDefinitionListenerInterface { protected $cacheBackend; /** - * The entity field manager. + * The entity field definition repository. * - * @var \Drupal\Core\Entity\EntityFieldManagerInterface + * @var \Drupal\Core\Entity\EntityFieldDefinitionRepositoryInterface */ - protected $entityFieldManager; + protected $entityFieldDefinitionRepository; /** * Constructs a new FieldDefinitionListener. * * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager * The entity type manager. - * @param \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager - * The entity field manager. + * @param \Drupal\Core\Entity\EntityFieldDefinitionRepositoryInterface $entity_field_definition_repository + * The entity field definition repository. * @param \Drupal\Core\KeyValueStore\KeyValueFactoryInterface $key_value_factory * The key-value factory. * @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend * The cache backend. */ - public function __construct(EntityTypeManagerInterface $entity_type_manager, EntityFieldManagerInterface $entity_field_manager, KeyValueFactoryInterface $key_value_factory, CacheBackendInterface $cache_backend) { + public function __construct(EntityTypeManagerInterface $entity_type_manager, EntityFieldDefinitionRepositoryInterface $entity_field_definition_repository, KeyValueFactoryInterface $key_value_factory, CacheBackendInterface $cache_backend) { $this->entityTypeManager = $entity_type_manager; - $this->entityFieldManager = $entity_field_manager; + $this->entityFieldDefinitionRepository = $entity_field_definition_repository; $this->keyValueFactory = $key_value_factory; $this->cacheBackend = $cache_backend; } @@ -93,7 +93,7 @@ public function onFieldDefinitionCreate(FieldDefinitionInterface $field_definiti // If the field map is initialized, update it as well, so that calls to it // do not have to rebuild it again. - if ($field_map = $this->entityFieldManager->getFieldMap()) { + if ($field_map = $this->entityFieldDefinitionRepository->getFieldMap()) { if (!isset($field_map[$entity_type_id][$field_name])) { // This field did not exist yet, initialize it with the type and empty // bundle list. @@ -103,7 +103,7 @@ public function onFieldDefinitionCreate(FieldDefinitionInterface $field_definiti ]; } $field_map[$entity_type_id][$field_name]['bundles'][$bundle] = $bundle; - $this->entityFieldManager->setFieldMap($field_map); + $this->entityFieldDefinitionRepository->setFieldMap($field_map); } } @@ -140,12 +140,12 @@ public function onFieldDefinitionDelete(FieldDefinitionInterface $field_definiti // If the field map is initialized, update it as well, so that calls to it // do not have to rebuild it again. - if ($field_map = $this->entityFieldManager->getFieldMap()) { + if ($field_map = $this->entityFieldDefinitionRepository->getFieldMap()) { unset($field_map[$entity_type_id][$field_name]['bundles'][$bundle]); if (empty($field_map[$entity_type_id][$field_name]['bundles'])) { unset($field_map[$entity_type_id][$field_name]); } - $this->entityFieldManager->setFieldMap($field_map); + $this->entityFieldDefinitionRepository->setFieldMap($field_map); } } diff --git a/core/lib/Drupal/Core/Field/FieldStorageDefinitionListener.php b/core/lib/Drupal/Core/Field/FieldStorageDefinitionListener.php index e0dafe5..38393e7 100644 --- a/core/lib/Drupal/Core/Field/FieldStorageDefinitionListener.php +++ b/core/lib/Drupal/Core/Field/FieldStorageDefinitionListener.php @@ -7,8 +7,8 @@ namespace Drupal\Core\Field; -use Drupal\Core\Entity\EntityInstalledDefinitionRepositoryInterface; -use Drupal\Core\Entity\EntityFieldManagerInterface; +use Drupal\Core\Entity\EntityDefinitionRepositoryInterface; +use Drupal\Core\Entity\EntityFieldDefinitionRepositoryInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; @@ -34,16 +34,16 @@ class FieldStorageDefinitionListener implements FieldStorageDefinitionListenerIn /** * The entity definition manager. * - * @var \Drupal\Core\Entity\EntityInstalledDefinitionRepositoryInterface + * @var \Drupal\Core\Entity\EntityDefinitionRepositoryInterface */ - protected $entityInstalledDefinitionRepository; + protected $entityDefinitionRepository; /** - * The entity field manager. + * The entity field definition repository. * - * @var \Drupal\Core\Entity\EntityFieldManagerInterface + * @var \Drupal\Core\Entity\EntityFieldDefinitionRepositoryInterface */ - protected $entityFieldManager; + protected $entityFieldDefinitionRepository; /** * Constructs a new FieldStorageDefinitionListener. @@ -52,16 +52,16 @@ class FieldStorageDefinitionListener implements FieldStorageDefinitionListenerIn * The entity type manager. * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher * The event dispatcher. - * @param \Drupal\Core\Entity\EntityInstalledDefinitionRepositoryInterface $entity_installed_definition_repository + * @param \Drupal\Core\Entity\EntityDefinitionRepositoryInterface $entity_definition_repository * The entity definition repository. - * @param \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager - * The entity field manager. + * @param \Drupal\Core\Entity\EntityFieldDefinitionRepositoryInterface $entity_field_definition_repository + * The entity field definition repository. */ - public function __construct(EntityTypeManagerInterface $entity_type_manager, EventDispatcherInterface $event_dispatcher, EntityInstalledDefinitionRepositoryInterface $entity_installed_definition_repository, EntityFieldManagerInterface $entity_field_manager) { + public function __construct(EntityTypeManagerInterface $entity_type_manager, EventDispatcherInterface $event_dispatcher, EntityDefinitionRepositoryInterface $entity_definition_repository, EntityFieldDefinitionRepositoryInterface $entity_field_definition_repository) { $this->entityTypeManager = $entity_type_manager; $this->eventDispatcher = $event_dispatcher; - $this->entityInstalledDefinitionRepository = $entity_installed_definition_repository; - $this->entityFieldManager = $entity_field_manager; + $this->entityDefinitionRepository = $entity_definition_repository; + $this->entityFieldDefinitionRepository = $entity_field_definition_repository; } /** @@ -79,8 +79,8 @@ public function onFieldStorageDefinitionCreate(FieldStorageDefinitionInterface $ $this->eventDispatcher->dispatch(FieldStorageDefinitionEvents::CREATE, new FieldStorageDefinitionEvent($storage_definition)); - $this->entityInstalledDefinitionRepository->setLastInstalledFieldStorageDefinition($storage_definition); - $this->entityFieldManager->clearCachedFieldDefinitions(); + $this->entityDefinitionRepository->setLastInstalledFieldStorageDefinition($storage_definition); + $this->entityFieldDefinitionRepository->clearCachedFieldDefinitions(); } /** @@ -98,8 +98,8 @@ public function onFieldStorageDefinitionUpdate(FieldStorageDefinitionInterface $ $this->eventDispatcher->dispatch(FieldStorageDefinitionEvents::UPDATE, new FieldStorageDefinitionEvent($storage_definition, $original)); - $this->entityInstalledDefinitionRepository->setLastInstalledFieldStorageDefinition($storage_definition); - $this->entityFieldManager->clearCachedFieldDefinitions(); + $this->entityDefinitionRepository->setLastInstalledFieldStorageDefinition($storage_definition); + $this->entityFieldDefinitionRepository->clearCachedFieldDefinitions(); } /** @@ -117,8 +117,8 @@ public function onFieldStorageDefinitionDelete(FieldStorageDefinitionInterface $ $this->eventDispatcher->dispatch(FieldStorageDefinitionEvents::DELETE, new FieldStorageDefinitionEvent($storage_definition)); - $this->entityInstalledDefinitionRepository->deleteLastInstalledFieldStorageDefinition($storage_definition); - $this->entityFieldManager->clearCachedFieldDefinitions(); + $this->entityDefinitionRepository->deleteLastInstalledFieldStorageDefinition($storage_definition); + $this->entityFieldDefinitionRepository->clearCachedFieldDefinitions(); } } diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityFieldDefinitionRepositoryTest.php similarity index 87% rename from core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php rename to core/tests/Drupal/Tests/Core/Entity/EntityFieldDefinitionRepositoryTest.php index bc62920..64c7f57 100644 --- a/core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/EntityFieldDefinitionRepositoryTest.php @@ -2,7 +2,7 @@ /** * @file - * Contains \Drupal\Tests\Core\Entity\EntityFieldManagerTest. + * Contains \Drupal\Tests\Core\Entity\EntityFieldDefinitionRepositoryTest. */ namespace Drupal\Tests\Core\Entity; @@ -15,9 +15,9 @@ use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\ContentEntityTypeInterface; use Drupal\Core\Entity\EntityDisplayRepositoryInterface; -use Drupal\Core\Entity\EntityFieldManager; +use Drupal\Core\Entity\EntityFieldDefinitionRepository; use Drupal\Core\Entity\EntityInterface; -use Drupal\Core\Entity\EntityTypeBundleManagerInterface; +use Drupal\Core\Entity\EntityTypeBundleInfoInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Entity\EntityTypeRepositoryInterface; @@ -39,10 +39,10 @@ use Symfony\Component\DependencyInjection\ContainerInterface; /** - * @coversDefaultClass \Drupal\Core\Entity\EntityFieldManager + * @coversDefaultClass \Drupal\Core\Entity\EntityFieldDefinitionRepository * @group Entity */ -class EntityFieldManagerTest extends UnitTestCase { +class EntityFieldDefinitionRepositoryTest extends UnitTestCase { /** * The typed data manager. @@ -108,11 +108,11 @@ class EntityFieldManagerTest extends UnitTestCase { protected $entityTypeRepository; /** - * The entity type bundle manager. + * The entity type bundle info. * - * @var \Drupal\Core\Entity\EntityTypeBundleManagerInterface|\Prophecy\Prophecy\ProphecyInterface + * @var \Drupal\Core\Entity\EntityTypeBundleInfoInterface|\Prophecy\Prophecy\ProphecyInterface */ - protected $entityTypeBundleManager; + protected $entityTypeBundleInfo; /** * The entity display repository. @@ -122,11 +122,11 @@ class EntityFieldManagerTest extends UnitTestCase { protected $entityDisplayRepository; /** - * The entity field manager under test. + * The entity field definition repository under test. * - * @var \Drupal\Core\Entity\EntityFieldManager + * @var \Drupal\Core\Entity\EntityFieldDefinitionRepository */ - protected $entityFieldManager; + protected $entityFieldDefinitionRepository; /** * The dependency injection container. @@ -173,10 +173,10 @@ public function setUp() { $this->entityTypeManager = $this->prophesize(EntityTypeManagerInterface::class); $this->entityTypeRepository = $this->prophesize(EntityTypeRepositoryInterface::class); - $this->entityTypeBundleManager = $this->prophesize(EntityTypeBundleManagerInterface::class); + $this->entityTypeBundleInfo = $this->prophesize(EntityTypeBundleInfoInterface::class); $this->entityDisplayRepository = $this->prophesize(EntityDisplayRepositoryInterface::class); - $this->entityFieldManager = new TestEntityFieldManager($this->entityTypeManager->reveal(), $this->entityTypeBundleManager->reveal(), $this->entityDisplayRepository->reveal(), $this->typedDataManager->reveal(), $this->languageManager->reveal(), $this->keyValueFactory->reveal(), $this->moduleHandler->reveal(), $this->cacheBackend->reveal()); + $this->entityFieldDefinitionRepository = new TestEntityFieldDefinitionRepository($this->entityTypeManager->reveal(), $this->entityTypeBundleInfo->reveal(), $this->entityDisplayRepository->reveal(), $this->typedDataManager->reveal(), $this->languageManager->reveal(), $this->keyValueFactory->reveal(), $this->moduleHandler->reveal(), $this->cacheBackend->reveal()); } /** @@ -226,7 +226,7 @@ public function testGetBaseFieldDefinitions() { $field_definition = $this->setUpEntityWithFieldDefinition(); $expected = ['id' => $field_definition]; - $this->assertSame($expected, $this->entityFieldManager->getBaseFieldDefinitions('test_entity_type')); + $this->assertSame($expected, $this->entityFieldDefinitionRepository->getBaseFieldDefinitions('test_entity_type')); } /** @@ -239,7 +239,7 @@ public function testGetFieldDefinitions() { $field_definition = $this->setUpEntityWithFieldDefinition(); $expected = ['id' => $field_definition]; - $this->assertSame($expected, $this->entityFieldManager->getFieldDefinitions('test_entity_type', 'test_entity_bundle')); + $this->assertSame($expected, $this->entityFieldDefinitionRepository->getFieldDefinitions('test_entity_type', 'test_entity_bundle')); } /** @@ -264,7 +264,7 @@ public function testGetFieldStorageDefinitions() { 'id' => $field_definition, 'field_storage' => $field_storage_definition->reveal(), ]; - $this->assertSame($expected, $this->entityFieldManager->getFieldStorageDefinitions('test_entity_type')); + $this->assertSame($expected, $this->entityFieldDefinitionRepository->getFieldStorageDefinitions('test_entity_type')); } /** @@ -286,7 +286,7 @@ public function testGetBaseFieldDefinitionsTranslatableEntityTypeDefaultLangcode $this->entityType->isTranslatable()->willReturn(TRUE); - $definitions = $this->entityFieldManager->getBaseFieldDefinitions('test_entity_type'); + $definitions = $this->entityFieldDefinitionRepository->getBaseFieldDefinitions('test_entity_type'); $this->assertTrue(isset($definitions[$default_langcode_key])); } @@ -333,7 +333,7 @@ public function testGetBaseFieldDefinitionsTranslatableEntityTypeLangcode($provi $this->entityType->isTranslatable()->willReturn(TRUE); $this->entityType->getLabel()->willReturn('Test'); - $this->entityFieldManager->getBaseFieldDefinitions('test_entity_type'); + $this->entityFieldDefinitionRepository->getBaseFieldDefinitions('test_entity_type'); } /** @@ -372,9 +372,9 @@ public function testGetBaseFieldDefinitionsWithCaching() { }) ->shouldBeCalled(); - $this->assertSame($expected, $this->entityFieldManager->getBaseFieldDefinitions('test_entity_type')); - $this->entityFieldManager->testClearEntityFieldInfo(); - $this->assertSame($expected, $this->entityFieldManager->getBaseFieldDefinitions('test_entity_type')); + $this->assertSame($expected, $this->entityFieldDefinitionRepository->getBaseFieldDefinitions('test_entity_type')); + $this->entityFieldDefinitionRepository->testClearEntityFieldInfo(); + $this->assertSame($expected, $this->entityFieldDefinitionRepository->getBaseFieldDefinitions('test_entity_type')); } /** @@ -402,9 +402,9 @@ public function testGetFieldDefinitionsWithCaching() { }) ->shouldBeCalled(); - $this->assertSame($expected, $this->entityFieldManager->getFieldDefinitions('test_entity_type', 'test_bundle')); - $this->entityFieldManager->testClearEntityFieldInfo(); - $this->assertSame($expected, $this->entityFieldManager->getFieldDefinitions('test_entity_type', 'test_bundle')); + $this->assertSame($expected, $this->entityFieldDefinitionRepository->getFieldDefinitions('test_entity_type', 'test_bundle')); + $this->entityFieldDefinitionRepository->testClearEntityFieldInfo(); + $this->assertSame($expected, $this->entityFieldDefinitionRepository->getFieldDefinitions('test_entity_type', 'test_bundle')); } /** @@ -442,9 +442,9 @@ public function testGetFieldStorageDefinitionsWithCaching() { ->shouldBeCalled(); - $this->assertSame($expected, $this->entityFieldManager->getFieldStorageDefinitions('test_entity_type')); - $this->entityFieldManager->testClearEntityFieldInfo(); - $this->assertSame($expected, $this->entityFieldManager->getFieldStorageDefinitions('test_entity_type')); + $this->assertSame($expected, $this->entityFieldDefinitionRepository->getFieldStorageDefinitions('test_entity_type')); + $this->entityFieldDefinitionRepository->testClearEntityFieldInfo(); + $this->assertSame($expected, $this->entityFieldDefinitionRepository->getFieldStorageDefinitions('test_entity_type')); } /** @@ -461,7 +461,7 @@ public function testGetBaseFieldDefinitionsInvalidDefinition() { $this->entityType->isTranslatable()->willReturn(TRUE); $this->entityType->getLabel()->willReturn('the_label'); - $this->entityFieldManager->getBaseFieldDefinitions('test_entity_type'); + $this->entityFieldDefinitionRepository->getBaseFieldDefinitions('test_entity_type'); } /** @@ -492,7 +492,7 @@ public function testGetFieldDefinitionsProvider() { $this->moduleHandler->invoke($module, 'entity_base_field_info', [$this->entityType])->willReturn([$field_definition->reveal()]); $this->moduleHandler->invoke($module, 'entity_bundle_field_info', Argument::type('array'))->willReturn([$field_definition->reveal()]); - $this->entityFieldManager->getFieldDefinitions('test_entity_type', 'test_bundle'); + $this->entityFieldDefinitionRepository->getFieldDefinitions('test_entity_type', 'test_bundle'); } /** @@ -564,7 +564,7 @@ public function testClearCachedFieldDefinitions() { $this->typedDataManager->clearCachedDefinitions()->shouldBeCalled(); - $this->entityFieldManager->clearCachedFieldDefinitions(); + $this->entityFieldDefinitionRepository->clearCachedFieldDefinitions(); } /** @@ -605,14 +605,14 @@ function testGetExtraFields() { $this->cacheBackend->set($cache_id, $processed_hook_bundle_extra_fields[$entity_type_id][$bundle], Cache::PERMANENT, ['entity_field_info'])->shouldBeCalled(); - $this->assertSame($processed_hook_bundle_extra_fields[$entity_type_id][$bundle], $this->entityFieldManager->getExtraFields($entity_type_id, $bundle)); + $this->assertSame($processed_hook_bundle_extra_fields[$entity_type_id][$bundle], $this->entityFieldDefinitionRepository->getExtraFields($entity_type_id, $bundle)); } /** * @covers ::getFieldMap */ public function testGetFieldMap() { - $this->entityTypeBundleManager->getBundleInfo('test_entity_type')->willReturn([])->shouldBeCalled(); + $this->entityTypeBundleInfo->getBundleInfo('test_entity_type')->willReturn([])->shouldBeCalled(); // Set up a content entity type. $entity_type = $this->prophesize(ContentEntityTypeInterface::class); @@ -660,9 +660,9 @@ public function testGetFieldMap() { $override_entity_type->isSubclassOf(FieldableEntityInterface::class)->willReturn(FALSE); - // Set up the entity type bundle manager to return two bundles for the + // Set up the entity type bundle info to return two bundles for the // fieldable entity type. - $this->entityTypeBundleManager->getBundleInfo('test_entity_type')->willReturn([ + $this->entityTypeBundleInfo->getBundleInfo('test_entity_type')->willReturn([ 'first_bundle' => 'first_bundle', 'second_bundle' => 'second_bundle', ])->shouldBeCalled(); @@ -680,7 +680,7 @@ public function testGetFieldMap() { ], ] ]; - $this->assertEquals($expected, $this->entityFieldManager->getFieldMap()); + $this->assertEquals($expected, $this->entityFieldDefinitionRepository->getFieldMap()); } /** @@ -703,8 +703,8 @@ public function testGetFieldMapFromCache() { $this->cacheBackend->get('entity_field_map')->willReturn((object) ['data' => $expected]); // Call the field map twice to make sure the static cache works. - $this->assertEquals($expected, $this->entityFieldManager->getFieldMap()); - $this->assertEquals($expected, $this->entityFieldManager->getFieldMap()); + $this->assertEquals($expected, $this->entityFieldDefinitionRepository->getFieldMap()); + $this->assertEquals($expected, $this->entityFieldDefinitionRepository->getFieldMap()); } /** @@ -715,9 +715,9 @@ public function testGetFieldMapByFieldType() { $entity_type = $this->prophesize(ContentEntityTypeInterface::class); $entity_class = EntityManagerTestEntity::class; - // Set up the entity type bundle manager to return two bundles for the + // Set up the entity type bundle info to return two bundles for the // fieldable entity type. - $this->entityTypeBundleManager->getBundleInfo('test_entity_type')->willReturn([ + $this->entityTypeBundleInfo->getBundleInfo('test_entity_type')->willReturn([ 'first_bundle' => 'first_bundle', 'second_bundle' => 'second_bundle', ])->shouldBeCalled(); @@ -759,13 +759,13 @@ public function testGetFieldMapByFieldType() { $override_entity_type->isSubclassOf(FieldableEntityInterface::class)->willReturn(FALSE)->shouldBeCalled(); - $integerFields = $this->entityFieldManager->getFieldMapByFieldType('integer'); + $integerFields = $this->entityFieldDefinitionRepository->getFieldMapByFieldType('integer'); $this->assertCount(1, $integerFields['test_entity_type']); $this->assertArrayNotHasKey('non_fieldable', $integerFields); $this->assertArrayHasKey('id', $integerFields['test_entity_type']); $this->assertArrayNotHasKey('by_bundle', $integerFields['test_entity_type']); - $stringFields = $this->entityFieldManager->getFieldMapByFieldType('string'); + $stringFields = $this->entityFieldDefinitionRepository->getFieldMapByFieldType('string'); $this->assertCount(1, $stringFields['test_entity_type']); $this->assertArrayNotHasKey('non_fieldable', $stringFields); $this->assertArrayHasKey('by_bundle', $stringFields['test_entity_type']); @@ -774,7 +774,7 @@ public function testGetFieldMapByFieldType() { } -class TestEntityFieldManager extends EntityFieldManager { +class TestEntityFieldDefinitionRepository extends EntityFieldDefinitionRepository { /** * Allows the static caches to be cleared. diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php index 95a912f..49bf8cd 100644 --- a/core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php @@ -8,12 +8,12 @@ namespace Drupal\Tests\Core\Entity; use Drupal\Core\Entity\EntityBundleListenerInterface; -use Drupal\Core\Entity\EntityInstalledDefinitionRepositoryInterface; +use Drupal\Core\Entity\EntityDefinitionRepositoryInterface; use Drupal\Core\Entity\EntityDisplayRepositoryInterface; -use Drupal\Core\Entity\EntityFieldManagerInterface; +use Drupal\Core\Entity\EntityFieldDefinitionRepositoryInterface; use Drupal\Core\Entity\EntityManager; use Drupal\Core\Entity\EntityRepositoryInterface; -use Drupal\Core\Entity\EntityTypeBundleManagerInterface; +use Drupal\Core\Entity\EntityTypeBundleInfoInterface; use Drupal\Core\Entity\EntityTypeListenerInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Entity\EntityTypeRepositoryInterface; @@ -50,11 +50,11 @@ class EntityManagerTest extends UnitTestCase { protected $entityTypeRepository; /** - * The entity type bundle manager. + * The entity type bundle info. * - * @var \Drupal\Core\Entity\EntityTypeBundleManagerInterface|\Prophecy\Prophecy\ProphecyInterface + * @var \Drupal\Core\Entity\EntityTypeBundleInfoInterface|\Prophecy\Prophecy\ProphecyInterface */ - protected $entityTypeBundleManager; + protected $entityTypeBundleInfo; /** * The entity display repository. @@ -64,11 +64,11 @@ class EntityManagerTest extends UnitTestCase { protected $entityDisplayRepository; /** - * The entity field manager. + * The entity field definition repository. * - * @var \Drupal\Core\Entity\EntityFieldManagerInterface|\Prophecy\Prophecy\ProphecyInterface + * @var \Drupal\Core\Entity\EntityFieldDefinitionRepositoryInterface|\Prophecy\Prophecy\ProphecyInterface */ - protected $entityFieldManager; + protected $entityFieldDefinitionRepository; /** * The entity type listener. @@ -80,9 +80,9 @@ class EntityManagerTest extends UnitTestCase { /** * The entity definition repository. * - * @var \Drupal\Core\Entity\EntityInstalledDefinitionRepositoryInterface|\Prophecy\Prophecy\ProphecyInterface + * @var \Drupal\Core\Entity\EntityDefinitionRepositoryInterface|\Prophecy\Prophecy\ProphecyInterface */ - protected $entityInstalledDefinitionRepository; + protected $entityDefinitionRepository; /** * The entity repository. @@ -120,18 +120,18 @@ protected function setUp() { $this->entityTypeManager = $this->prophesize(EntityTypeManagerInterface::class); $this->entityTypeRepository = $this->prophesize(EntityTypeRepositoryInterface::class); - $this->entityTypeBundleManager = $this->prophesize(EntityTypeBundleManagerInterface::class); + $this->entityTypeBundleInfo = $this->prophesize(EntityTypeBundleInfoInterface::class); $this->entityDisplayRepository = $this->prophesize(EntityDisplayRepositoryInterface::class); - $this->entityFieldManager = $this->prophesize(EntityFieldManagerInterface::class); + $this->entityFieldDefinitionRepository = $this->prophesize(EntityFieldDefinitionRepositoryInterface::class); $this->entityTypeListener = $this->prophesize(EntityTypeListenerInterface::class); - $this->entityInstalledDefinitionRepository = $this->prophesize(EntityInstalledDefinitionRepositoryInterface::class); + $this->entityDefinitionRepository = $this->prophesize(EntityDefinitionRepositoryInterface::class); $this->entityRepository = $this->prophesize(EntityRepositoryInterface::class); $this->entityBundleListener = $this->prophesize(EntityBundleListenerInterface::class); $this->fieldStorageDefinitionListener = $this->prophesize(FieldStorageDefinitionListenerInterface::class); $this->fieldDefinitionListener = $this->prophesize(FieldDefinitionListenerInterface::class); - $this->entityManager = new EntityManager($this->entityTypeManager->reveal(), $this->entityTypeRepository->reveal(), $this->entityTypeBundleManager->reveal(), $this->entityDisplayRepository->reveal(), $this->entityFieldManager->reveal(), $this->entityInstalledDefinitionRepository->reveal(), $this->entityRepository->reveal(), $this->entityTypeListener->reveal(), $this->entityBundleListener->reveal(), $this->fieldStorageDefinitionListener->reveal(), $this->fieldDefinitionListener->reveal()); + $this->entityManager = new EntityManager($this->entityTypeManager->reveal(), $this->entityTypeRepository->reveal(), $this->entityTypeBundleInfo->reveal(), $this->entityDisplayRepository->reveal(), $this->entityFieldDefinitionRepository->reveal(), $this->entityDefinitionRepository->reveal(), $this->entityRepository->reveal(), $this->entityTypeListener->reveal(), $this->entityBundleListener->reveal(), $this->fieldStorageDefinitionListener->reveal(), $this->fieldDefinitionListener->reveal()); } /** @@ -142,8 +142,8 @@ protected function setUp() { public function testClearCachedDefinitions() { $this->entityTypeManager->clearCachedDefinitions()->shouldBeCalled(); $this->entityTypeRepository->clearCachedDefinitions()->shouldBeCalled(); - $this->entityTypeBundleManager->clearCachedBundles()->shouldBeCalled(); - $this->entityFieldManager->clearCachedFieldDefinitions()->shouldBeCalled(); + $this->entityTypeBundleInfo->clearCachedBundles()->shouldBeCalled(); + $this->entityFieldDefinitionRepository->clearCachedFieldDefinitions()->shouldBeCalled(); $this->entityManager->clearCachedDefinitions(); } diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityTypeBundleManagerTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityTypeBundleInfoTest.php similarity index 88% rename from core/tests/Drupal/Tests/Core/Entity/EntityTypeBundleManagerTest.php rename to core/tests/Drupal/Tests/Core/Entity/EntityTypeBundleInfoTest.php index 42ef4a5..2093a44 100644 --- a/core/tests/Drupal/Tests/Core/Entity/EntityTypeBundleManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/EntityTypeBundleInfoTest.php @@ -2,7 +2,7 @@ /** * @file - * Contains \Drupal\Tests\Core\Entity\EntityTypeBundleManagerTest. + * Contains \Drupal\Tests\Core\Entity\EntityTypeBundleInfoTest. */ namespace Drupal\Tests\Core\Entity; @@ -12,7 +12,7 @@ use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Cache\CacheTagsInvalidatorInterface; use Drupal\Core\Entity\EntityInterface; -use Drupal\Core\Entity\EntityTypeBundleManager; +use Drupal\Core\Entity\EntityTypeBundleInfo; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Extension\ModuleHandlerInterface; @@ -24,10 +24,10 @@ use Symfony\Component\DependencyInjection\ContainerInterface; /** - * @coversDefaultClass \Drupal\Core\Entity\EntityTypeBundleManager + * @coversDefaultClass \Drupal\Core\Entity\EntityTypeBundleInfo * @group Entity */ -class EntityTypeBundleManagerTest extends UnitTestCase { +class EntityTypeBundleInfoTest extends UnitTestCase { /** * The module handler. @@ -72,11 +72,11 @@ class EntityTypeBundleManagerTest extends UnitTestCase { protected $languageManager; /** - * The entity type bundle manager under test. + * The entity type bundle info under test. * - * @var \Drupal\Core\Entity\EntityTypeBundleManager + * @var \Drupal\Core\Entity\EntityTypeBundleInfo */ - protected $entityTypeBundleManager; + protected $entityTypeBundleInfo; /** * {@inheritdoc} @@ -108,7 +108,7 @@ protected function setUp() { //$container->get('typed_data_manager')->willReturn($this->typedDataManager->reveal()); \Drupal::setContainer($container->reveal()); - $this->entityTypeBundleManager = new EntityTypeBundleManager($this->entityTypeManager->reveal(), $this->languageManager->reveal(), $this->moduleHandler->reveal(), $this->typedDataManager->reveal(), $this->cacheBackend->reveal()); + $this->entityTypeBundleInfo = new EntityTypeBundleInfo($this->entityTypeManager->reveal(), $this->languageManager->reveal(), $this->moduleHandler->reveal(), $this->typedDataManager->reveal(), $this->cacheBackend->reveal()); } /** @@ -159,7 +159,7 @@ public function testClearCachedBundles() { $this->cacheTagsInvalidator->invalidateTags(['entity_bundles'])->shouldBeCalled(); - $this->entityTypeBundleManager->clearCachedBundles(); + $this->entityTypeBundleInfo->clearCachedBundles(); } /** @@ -186,7 +186,7 @@ public function testGetBundleInfo($entity_type_id, $expected) { 'banana' => $banana, ]); - $bundle_info = $this->entityTypeBundleManager->getBundleInfo($entity_type_id); + $bundle_info = $this->entityTypeBundleInfo->getBundleInfo($entity_type_id); $this->assertSame($expected, $bundle_info); } @@ -259,15 +259,15 @@ public function testGetAllBundleInfo() { ], ], ]; - $bundle_info = $this->entityTypeBundleManager->getAllBundleInfo(); + $bundle_info = $this->entityTypeBundleInfo->getAllBundleInfo(); $this->assertSame($expected, $bundle_info); - $bundle_info = $this->entityTypeBundleManager->getAllBundleInfo(); + $bundle_info = $this->entityTypeBundleInfo->getAllBundleInfo(); $this->assertSame($expected, $bundle_info); - $this->entityTypeBundleManager->clearCachedBundles(); + $this->entityTypeBundleInfo->clearCachedBundles(); - $bundle_info = $this->entityTypeBundleManager->getAllBundleInfo(); + $bundle_info = $this->entityTypeBundleInfo->getAllBundleInfo(); $this->assertSame('cached data', $bundle_info); } diff --git a/core/tests/Drupal/Tests/Core/Field/FieldDefinitionListenerTest.php b/core/tests/Drupal/Tests/Core/Field/FieldDefinitionListenerTest.php index 8ca9ae0..2dfd511 100644 --- a/core/tests/Drupal/Tests/Core/Field/FieldDefinitionListenerTest.php +++ b/core/tests/Drupal/Tests/Core/Field/FieldDefinitionListenerTest.php @@ -10,7 +10,7 @@ use Drupal\Component\Plugin\Exception\PluginNotFoundException; use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Entity\DynamicallyFieldableEntityStorageInterface; -use Drupal\Core\Entity\EntityFieldManagerInterface; +use Drupal\Core\Entity\EntityFieldDefinitionRepositoryInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; @@ -42,11 +42,11 @@ class FieldDefinitionListenerTest extends UnitTestCase { protected $entityTypeManager; /** - * The entity field manager. + * The entity field definition repository. * - * @var \Drupal\Core\Entity\EntityFieldManagerInterface|\Prophecy\Prophecy\ProphecyInterface + * @var \Drupal\Core\Entity\EntityFieldDefinitionRepositoryInterface|\Prophecy\Prophecy\ProphecyInterface */ - protected $entityFieldManager; + protected $entityFieldDefinitionRepository; /** * The cache backend. @@ -70,10 +70,10 @@ protected function setUp() { $this->keyValueFactory = $this->prophesize(KeyValueFactoryInterface::class); $this->entityTypeManager = $this->prophesize(EntityTypeManagerInterface::class); - $this->entityFieldManager = $this->prophesize(EntityFieldManagerInterface::class); + $this->entityFieldDefinitionRepository = $this->prophesize(EntityFieldDefinitionRepositoryInterface::class); $this->cacheBackend = $this->prophesize(CacheBackendInterface::class); - $this->fieldDefinitionListener = new FieldDefinitionListener($this->entityTypeManager->reveal(), $this->entityFieldManager->reveal(), $this->keyValueFactory->reveal(), $this->cacheBackend->reveal()); + $this->fieldDefinitionListener = new FieldDefinitionListener($this->entityTypeManager->reveal(), $this->entityFieldDefinitionRepository->reveal(), $this->keyValueFactory->reveal(), $this->cacheBackend->reveal()); } /**