diff --git a/core/core.api.php b/core/core.api.php index 4f937e375f..cfb8800728 100644 --- a/core/core.api.php +++ b/core/core.api.php @@ -1914,7 +1914,7 @@ function hook_cron() { // Long-running operation example, leveraging a queue: // Queue news feeds for updates once their refresh interval has elapsed. $queue = \Drupal::queue('aggregator_feeds'); - $ids = \Drupal::entityManager()->getStorage('aggregator_feed')->getFeedIdsToRefresh(); + $ids = \Drupal::entityTypeManager()->getStorage('aggregator_feed')->getFeedIdsToRefresh(); foreach (Feed::loadMultiple($ids) as $feed) { if ($queue->createItem($feed)) { // Add timestamp to avoid queueing item more than once. diff --git a/core/includes/entity.inc b/core/includes/entity.inc index 0dc4426014..18349f5c91 100644 --- a/core/includes/entity.inc +++ b/core/includes/entity.inc @@ -22,10 +22,10 @@ */ function entity_render_cache_clear() { @trigger_error(__FUNCTION__ . '() is deprecated. Use \Drupal\Core\Entity\EntityViewBuilderInterface::resetCache() on the required entity types or invalidate specific cache tags instead. See https://www.drupal.org/node/3000037', E_USER_DEPRECATED); - $entity_manager = Drupal::entityManager(); - foreach ($entity_manager->getDefinitions() as $entity_type => $info) { - if ($entity_manager->hasHandler($entity_type, 'view_builder')) { - $entity_manager->getViewBuilder($entity_type)->resetCache(); + $entity_type_manager = Drupal::entityTypeManager(); + foreach ($entity_type_manager->getDefinitions() as $entity_type => $info) { + if ($entity_type_manager->hasHandler($entity_type, 'view_builder')) { + $entity_type_manager->getViewBuilder($entity_type)->resetCache(); } } } @@ -51,10 +51,10 @@ function entity_render_cache_clear() { */ function entity_get_bundles($entity_type = NULL) { if (isset($entity_type)) { - return \Drupal::entityManager()->getBundleInfo($entity_type); + return \Drupal::service('entity_type.bundle.info')->getBundleInfo($entity_type); } else { - return \Drupal::entityManager()->getAllBundleInfo(); + return \Drupal::service('entity_type.bundle.info')->getAllBundleInfo(); } } @@ -78,7 +78,7 @@ function entity_get_bundles($entity_type = NULL) { */ function entity_load($entity_type, $id, $reset = FALSE) { @trigger_error('entity_load() is deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use the entity type storage\'s load() method. See https://www.drupal.org/node/2266845', E_USER_DEPRECATED); - $controller = \Drupal::entityManager()->getStorage($entity_type); + $controller = \Drupal::entityTypeManager()->getStorage($entity_type); if ($reset) { $controller->resetCache([$id]); } @@ -111,7 +111,7 @@ function entity_load($entity_type, $id, $reset = FALSE) { * @see \Drupal\Core\Entity\Sql\SqlContentEntityStorage */ function entity_revision_load($entity_type, $revision_id) { - return \Drupal::entityManager() + return \Drupal::entityTypeManager() ->getStorage($entity_type) ->loadRevision($revision_id); } @@ -137,7 +137,7 @@ function entity_revision_load($entity_type, $revision_id) { * @see \Drupal\Core\Entity\EntityStorageInterface::deleteRevision() */ function entity_revision_delete($entity_type, $revision_id) { - \Drupal::entityManager() + \Drupal::entityTypeManager() ->getStorage($entity_type) ->deleteRevision($revision_id); } @@ -177,7 +177,7 @@ function entity_revision_delete($entity_type, $revision_id) { */ function entity_load_multiple($entity_type, array $ids = NULL, $reset = FALSE) { @trigger_error('entity_load_multiple() is deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use the entity type storage\'s loadMultiple() method. See https://www.drupal.org/node/2266845', E_USER_DEPRECATED); - $controller = \Drupal::entityManager()->getStorage($entity_type); + $controller = \Drupal::entityTypeManager()->getStorage($entity_type); if ($reset) { $controller->resetCache($ids); } @@ -210,7 +210,7 @@ function entity_load_multiple($entity_type, array $ids = NULL, $reset = FALSE) { * @see \Drupal\Core\Entity\EntityStorageInterface::loadByProperties() */ function entity_load_multiple_by_properties($entity_type, array $values) { - return \Drupal::entityManager() + return \Drupal::entityTypeManager() ->getStorage($entity_type) ->loadByProperties($values); } @@ -241,7 +241,7 @@ function entity_load_multiple_by_properties($entity_type, array $values) { * @see \Drupal\Core\Entity\EntityStorageInterface::loadUnchanged() */ function entity_load_unchanged($entity_type, $id) { - return \Drupal::entityManager() + return \Drupal::entityTypeManager() ->getStorage($entity_type) ->loadUnchanged($id); } @@ -267,7 +267,7 @@ function entity_load_unchanged($entity_type, $id) { * @see \Drupal\Core\Entity\EntityStorageInterface::delete() */ function entity_delete_multiple($entity_type, array $ids) { - $controller = \Drupal::entityManager()->getStorage($entity_type); + $controller = \Drupal::entityTypeManager()->getStorage($entity_type); $entities = $controller->loadMultiple($ids); $controller->delete($entities); } @@ -297,7 +297,7 @@ function entity_delete_multiple($entity_type, array $ids) { * @see \Drupal\Core\Entity\EntityStorageInterface::create() */ function entity_create($entity_type, array $values = []) { - return \Drupal::entityManager() + return \Drupal::entityTypeManager() ->getStorage($entity_type) ->create($values); } @@ -356,7 +356,7 @@ function entity_page_label(EntityInterface $entity, $langcode = NULL) { * @see \Drupal\Core\Entity\EntityViewBuilderInterface::view() */ function entity_view(EntityInterface $entity, $view_mode, $langcode = NULL, $reset = FALSE) { - $render_controller = \Drupal::entityManager()->getViewBuilder($entity->getEntityTypeId()); + $render_controller = \Drupal::entityTypeManager()->getViewBuilder($entity->getEntityTypeId()); if ($reset) { $render_controller->resetCache([$entity]); } @@ -394,7 +394,7 @@ function entity_view(EntityInterface $entity, $view_mode, $langcode = NULL, $res * @see \Drupal\Core\Entity\EntityViewBuilderInterface::viewMultiple() */ function entity_view_multiple(array $entities, $view_mode, $langcode = NULL, $reset = FALSE) { - $render_controller = \Drupal::entityManager()->getViewBuilder(reset($entities)->getEntityTypeId()); + $render_controller = \Drupal::entityTypeManager()->getViewBuilder(reset($entities)->getEntityTypeId()); if ($reset) { $render_controller->resetCache($entities); } diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index 48cc8fe50f..4cb397de52 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -1621,7 +1621,7 @@ function install_profile_modules(&$install_state) { */ function install_core_entity_type_definitions() { $update_manager = \Drupal::entityDefinitionUpdateManager(); - foreach (\Drupal::entityManager()->getDefinitions() as $entity_type) { + foreach (\Drupal::entityTypeManager()->getDefinitions() as $entity_type) { if ($entity_type->getProvider() == 'core') { $update_manager->installEntityType($entity_type); } diff --git a/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php b/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php index c282427028..cec81ad752 100644 --- a/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php +++ b/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php @@ -95,7 +95,7 @@ public static function collectRenderDisplay(FieldableEntityInterface $entity, $f ->execute(); // Load the first valid candidate display, if any. - $storage = \Drupal::entityManager()->getStorage('entity_form_display'); + $storage = \Drupal::entityTypeManager()->getStorage('entity_form_display'); foreach ($candidate_ids as $candidate_id) { if (isset($results[$candidate_id])) { $display = $storage->load($candidate_id); @@ -211,7 +211,7 @@ public function processForm($element, FormStateInterface $form_state, $form) { } // Hide extra fields. - $extra_fields = \Drupal::entityManager()->getExtraFields($this->targetEntityType, $this->bundle); + $extra_fields = \Drupal::service('entity_field.manager')->getExtraFields($this->targetEntityType, $this->bundle); $extra_fields = isset($extra_fields['form']) ? $extra_fields['form'] : []; foreach ($extra_fields as $extra_field => $info) { if (!$this->getComponent($extra_field)) { diff --git a/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php b/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php index 6783522ac9..6cf38ffc24 100644 --- a/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php +++ b/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php @@ -112,7 +112,7 @@ public static function collectRenderDisplays($entities, $view_mode) { } // Load the selected displays. - $storage = \Drupal::entityManager()->getStorage('entity_view_display'); + $storage = \Drupal::entityTypeManager()->getStorage('entity_view_display'); $displays = $storage->loadMultiple($load_ids); $displays_by_bundle = []; @@ -182,8 +182,8 @@ public function __construct(array $values, $entity_type) { public function postSave(EntityStorageInterface $storage, $update = TRUE) { // Reset the render cache for the target entity type. parent::postSave($storage, $update); - if (\Drupal::entityManager()->hasHandler($this->targetEntityType, 'view_builder')) { - \Drupal::entityManager()->getViewBuilder($this->targetEntityType)->resetCache(); + if (\Drupal::entityTypeManager()->hasHandler($this->targetEntityType, 'view_builder')) { + \Drupal::entityTypeManager()->getViewBuilder($this->targetEntityType)->resetCache(); } } diff --git a/core/lib/Drupal/Core/Entity/EntityDisplayBase.php b/core/lib/Drupal/Core/Entity/EntityDisplayBase.php index e696a982fe..4ab69cb98e 100644 --- a/core/lib/Drupal/Core/Entity/EntityDisplayBase.php +++ b/core/lib/Drupal/Core/Entity/EntityDisplayBase.php @@ -157,7 +157,7 @@ protected function init() { $default_region = $this->getDefaultRegion(); // Fill in defaults for extra fields. $context = $this->displayContext == 'view' ? 'display' : $this->displayContext; - $extra_fields = \Drupal::entityManager()->getExtraFields($this->targetEntityType, $this->bundle); + $extra_fields = \Drupal::service('entity_field.manager')->getExtraFields($this->targetEntityType, $this->bundle); $extra_fields = isset($extra_fields[$context]) ? $extra_fields[$context] : []; foreach ($extra_fields as $name => $definition) { if (!isset($this->content[$name]) && !isset($this->hidden[$name])) { @@ -424,7 +424,7 @@ protected function getFieldDefinition($field_name) { */ protected function getFieldDefinitions() { if (!isset($this->fieldDefinitions)) { - $definitions = \Drupal::entityManager()->getFieldDefinitions($this->targetEntityType, $this->bundle); + $definitions = \Drupal::service('entity_field.manager')->getFieldDefinitions($this->targetEntityType, $this->bundle); // For "official" view modes and form modes, ignore fields whose // definition states they should not be displayed. if ($this->mode !== static::CUSTOM_MODE) { diff --git a/core/lib/Drupal/Core/Entity/EntityDisplayModeBase.php b/core/lib/Drupal/Core/Entity/EntityDisplayModeBase.php index fe7f105e10..a611487fa1 100644 --- a/core/lib/Drupal/Core/Entity/EntityDisplayModeBase.php +++ b/core/lib/Drupal/Core/Entity/EntityDisplayModeBase.php @@ -86,7 +86,7 @@ public function setTargetType($target_entity_type) { */ public function calculateDependencies() { parent::calculateDependencies(); - $target_entity_type = \Drupal::entityManager()->getDefinition($this->targetEntityType); + $target_entity_type = \Drupal::entityTypeManager()->getDefinition($this->targetEntityType); $this->addDependency('module', $target_entity_type->getProvider()); return $this; } @@ -96,7 +96,7 @@ public function calculateDependencies() { */ public function preSave(EntityStorageInterface $storage) { parent::preSave($storage); - \Drupal::entityManager()->clearCachedFieldDefinitions(); + \Drupal::service('entity_field.manager')->clearCachedFieldDefinitions(); } /** @@ -104,7 +104,7 @@ public function preSave(EntityStorageInterface $storage) { */ public static function preDelete(EntityStorageInterface $storage, array $entities) { parent::preDelete($storage, $entities); - \Drupal::entityManager()->clearCachedFieldDefinitions(); + \Drupal::service('entity_field.manager')->clearCachedFieldDefinitions(); } /** diff --git a/core/lib/Drupal/Core/Entity/EntityStorageBase.php b/core/lib/Drupal/Core/Entity/EntityStorageBase.php index 2ceb19c2b1..1a27a7738a 100644 --- a/core/lib/Drupal/Core/Entity/EntityStorageBase.php +++ b/core/lib/Drupal/Core/Entity/EntityStorageBase.php @@ -22,7 +22,7 @@ abstract class EntityStorageBase extends EntityHandlerBase implements EntityStor * * The following code returns the same object: * @code - * \Drupal::entityManager()->getDefinition($this->entityTypeId) + * \Drupal::entityTypeManager()->getDefinition($this->entityTypeId) * @endcode * * @var \Drupal\Core\Entity\EntityTypeInterface diff --git a/core/lib/Drupal/Core/Entity/EntityType.php b/core/lib/Drupal/Core/Entity/EntityType.php index 71aea12b80..db0def37de 100644 --- a/core/lib/Drupal/Core/Entity/EntityType.php +++ b/core/lib/Drupal/Core/Entity/EntityType.php @@ -910,7 +910,7 @@ public function getBundleConfigDependency($bundle) { // If this entity type uses entities to manage its bundles then depend on // the bundle entity. if ($bundle_entity_type_id = $this->getBundleEntityType()) { - if (!$bundle_entity = \Drupal::entityManager()->getStorage($bundle_entity_type_id)->load($bundle)) { + if (!$bundle_entity = \Drupal::entityTypeManager()->getStorage($bundle_entity_type_id)->load($bundle)) { throw new \LogicException(sprintf('Missing bundle entity, entity type %s, entity id %s.', $bundle_entity_type_id, $bundle)); } $config_dependency = [ diff --git a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityChangedConstraintValidator.php b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityChangedConstraintValidator.php index 28d81ba6e4..5a7b4b90c6 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityChangedConstraintValidator.php +++ b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityChangedConstraintValidator.php @@ -17,7 +17,7 @@ public function validate($entity, Constraint $constraint) { if (isset($entity)) { /** @var \Drupal\Core\Entity\EntityInterface $entity */ if (!$entity->isNew()) { - $saved_entity = \Drupal::entityManager()->getStorage($entity->getEntityTypeId())->loadUnchanged($entity->id()); + $saved_entity = \Drupal::entityTypeManager()->getStorage($entity->getEntityTypeId())->loadUnchanged($entity->id()); // Ensure that all the entity translations are the same as or newer // than their current version in the storage in order to avoid // reverting other changes. In fact the entity object that is being diff --git a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/ReferenceAccessConstraintValidator.php b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/ReferenceAccessConstraintValidator.php index 7860c90d65..eec95bca50 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/ReferenceAccessConstraintValidator.php +++ b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/ReferenceAccessConstraintValidator.php @@ -29,7 +29,7 @@ public function validate($value, Constraint $constraint) { $entity = $value->getEntity(); $check_permission = TRUE; if (!$entity->isNew()) { - $existing_entity = \Drupal::entityManager()->getStorage($entity->getEntityTypeId())->loadUnchanged($entity->id()); + $existing_entity = \Drupal::entityTypeManager()->getStorage($entity->getEntityTypeId())->loadUnchanged($entity->id()); $referenced_entities = $existing_entity->{$value->getFieldDefinition()->getName()}->referencedEntities(); // Check permission if we are not already referencing the entity. foreach ($referenced_entities as $ref) { diff --git a/core/lib/Drupal/Core/Entity/TypedData/EntityDataDefinition.php b/core/lib/Drupal/Core/Entity/TypedData/EntityDataDefinition.php index 21c05d1e35..74463ee2c3 100644 --- a/core/lib/Drupal/Core/Entity/TypedData/EntityDataDefinition.php +++ b/core/lib/Drupal/Core/Entity/TypedData/EntityDataDefinition.php @@ -70,7 +70,7 @@ public function getPropertyDefinitions() { if (!isset($this->propertyDefinitions)) { if ($entity_type_id = $this->getEntityTypeId()) { // Return an empty array for entities that are not content entities. - $entity_type_class = \Drupal::entityManager()->getDefinition($entity_type_id)->getClass(); + $entity_type_class = \Drupal::entityTypeManager()->getDefinition($entity_type_id)->getClass(); if (!in_array('Drupal\Core\Entity\FieldableEntityInterface', class_implements($entity_type_class))) { $this->propertyDefinitions = []; } @@ -79,10 +79,10 @@ public function getPropertyDefinitions() { // See https://www.drupal.org/node/2169813. $bundles = $this->getBundles(); if (is_array($bundles) && count($bundles) == 1) { - $this->propertyDefinitions = \Drupal::entityManager()->getFieldDefinitions($entity_type_id, reset($bundles)); + $this->propertyDefinitions = \Drupal::service('entity_field.manager')->getFieldDefinitions($entity_type_id, reset($bundles)); } else { - $this->propertyDefinitions = \Drupal::entityManager()->getBaseFieldDefinitions($entity_type_id); + $this->propertyDefinitions = \Drupal::service('entity_field.manager')->getBaseFieldDefinitions($entity_type_id); } } } diff --git a/core/lib/Drupal/Core/Entity/entity.api.php b/core/lib/Drupal/Core/Entity/entity.api.php index 846c757128..74ddd1b4d7 100644 --- a/core/lib/Drupal/Core/Entity/entity.api.php +++ b/core/lib/Drupal/Core/Entity/entity.api.php @@ -580,7 +580,7 @@ * implementing \Drupal\Core\Entity\EntityViewBuilderInterface that you can * retrieve with: * @code - * $view_builder = \Drupal::entityManager()->getViewBuilder('your_entity_type'); + * $view_builder = \Drupal::entityTypeManager()->getViewBuilder('your_entity_type'); * // Or if you have a $container variable: * $view_builder = $container->get('entity.manager')->getViewBuilder('your_entity_type'); * @endcode @@ -1943,7 +1943,7 @@ function hook_entity_bundle_field_info_alter(&$fields, \Drupal\Core\Entity\Entit * @see \Drupal\Core\Entity\EntityManagerInterface::getFieldStorageDefinitions() */ function hook_entity_field_storage_info(\Drupal\Core\Entity\EntityTypeInterface $entity_type) { - if (\Drupal::entityManager()->getStorage($entity_type->id()) instanceof DynamicallyFieldableEntityStorageInterface) { + if (\Drupal::entityTypeManager()->getStorage($entity_type->id()) instanceof DynamicallyFieldableEntityStorageInterface) { // Query by filtering on the ID as this is more efficient than filtering // on the entity_type property directly. $ids = \Drupal::entityQuery('field_storage_config') diff --git a/core/lib/Drupal/Core/Extension/ModuleInstaller.php b/core/lib/Drupal/Core/Extension/ModuleInstaller.php index 86cc9bc44d..f059e3bc0d 100644 --- a/core/lib/Drupal/Core/Extension/ModuleInstaller.php +++ b/core/lib/Drupal/Core/Extension/ModuleInstaller.php @@ -232,9 +232,11 @@ public function install(array $module_list, $enable_dependencies = TRUE) { // handler can use this as an opportunity to create the necessary // database tables. // @todo Clean this up in https://www.drupal.org/node/2350111. - $entity_manager = \Drupal::entityManager(); + $entity_type_manager = \Drupal::entityTypeManager(); + /** @var \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager */ + $entity_field_manager = \Drupal::service('entity_field.manager'); $update_manager = \Drupal::entityDefinitionUpdateManager(); - foreach ($entity_manager->getDefinitions() as $entity_type) { + foreach ($entity_type_manager->getDefinitions() as $entity_type) { if ($entity_type->getProvider() == $module) { $update_manager->installEntityType($entity_type); } @@ -242,7 +244,7 @@ public function install(array $module_list, $enable_dependencies = TRUE) { // The module being installed may be adding new fields to existing // entity types. Field definitions for any entity type defined by // the module are handled in the if branch. - foreach ($entity_manager->getFieldStorageDefinitions($entity_type->id()) as $storage_definition) { + foreach ($entity_field_manager->getFieldStorageDefinitions($entity_type->id()) as $storage_definition) { if ($storage_definition->getProvider() == $module) { // If the module being installed is also defining a storage key // for the entity type, the entity schema may not exist yet. It @@ -390,9 +392,11 @@ public function uninstall(array $module_list, $uninstall_dependents = TRUE) { // Clean up all entity bundles (including fields) of every entity type // provided by the module that is being uninstalled. // @todo Clean this up in https://www.drupal.org/node/2350111. - $entity_manager = \Drupal::entityManager(); + $entity_type_manager = \Drupal::entityTypeManager(); + /** @var \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager */ + $entity_field_manager = \Drupal::service('entity_field.manager'); $entity_type_bundle_info = \Drupal::service('entity_type.bundle.info'); - foreach ($entity_manager->getDefinitions() as $entity_type_id => $entity_type) { + foreach ($entity_type_manager->getDefinitions() as $entity_type_id => $entity_type) { if ($entity_type->getProvider() == $module) { foreach (array_keys($entity_type_bundle_info->getBundleInfo($entity_type_id)) as $bundle) { \Drupal::service('entity_bundle.listener')->onBundleDelete($bundle, $entity_type_id); @@ -419,7 +423,7 @@ public function uninstall(array $module_list, $uninstall_dependents = TRUE) { // opportunity to drop the corresponding database tables. // @todo Clean this up in https://www.drupal.org/node/2350111. $update_manager = \Drupal::entityDefinitionUpdateManager(); - foreach ($entity_manager->getDefinitions() as $entity_type) { + foreach ($entity_type_manager->getDefinitions() as $entity_type) { if ($entity_type->getProvider() == $module) { $update_manager->uninstallEntityType($entity_type); } @@ -427,7 +431,7 @@ public function uninstall(array $module_list, $uninstall_dependents = TRUE) { // The module being uninstalled might have added new fields to // existing entity types. This will add them to the deleted fields // repository so their data will be purged on cron. - foreach ($entity_manager->getFieldStorageDefinitions($entity_type->id()) as $storage_definition) { + foreach ($entity_field_manager->getFieldStorageDefinitions($entity_type->id()) as $storage_definition) { if ($storage_definition->getProvider() == $module) { $update_manager->uninstallFieldStorageDefinition($storage_definition); } diff --git a/core/lib/Drupal/Core/Extension/module.api.php b/core/lib/Drupal/Core/Extension/module.api.php index e30230b407..52d7f684e9 100644 --- a/core/lib/Drupal/Core/Extension/module.api.php +++ b/core/lib/Drupal/Core/Extension/module.api.php @@ -729,7 +729,7 @@ function hook_post_update_NAME(&$sandbox) { $block_update_8001 = \Drupal::keyValue('update_backup')->get('block_update_8001', []); $block_ids = array_keys($block_update_8001); - $block_storage = \Drupal::entityManager()->getStorage('block'); + $block_storage = \Drupal::entityTypeManager()->getStorage('block'); $blocks = $block_storage->loadMultiple($block_ids); /** @var $blocks \Drupal\block\BlockInterface[] */ foreach ($blocks as $block) { diff --git a/core/lib/Drupal/Core/Field/Entity/BaseFieldOverride.php b/core/lib/Drupal/Core/Field/Entity/BaseFieldOverride.php index 4ad9fd529e..2a97e00a19 100644 --- a/core/lib/Drupal/Core/Field/Entity/BaseFieldOverride.php +++ b/core/lib/Drupal/Core/Field/Entity/BaseFieldOverride.php @@ -64,7 +64,7 @@ public static function createFromBaseFieldDefinition(BaseFieldDefinition $base_f $values = $base_field_definition->toArray(); $values['bundle'] = $bundle; $values['baseFieldDefinition'] = $base_field_definition; - return \Drupal::entityManager()->getStorage('base_field_override')->create($values); + return \Drupal::entityTypeManager()->getStorage('base_field_override')->create($values); } /** @@ -240,7 +240,7 @@ public static function postDelete(EntityStorageInterface $storage, array $field_ * provided field name, otherwise NULL. */ public static function loadByName($entity_type_id, $bundle, $field_name) { - return \Drupal::entityManager()->getStorage('base_field_override')->load($entity_type_id . '.' . $bundle . '.' . $field_name); + return \Drupal::entityTypeManager()->getStorage('base_field_override')->load($entity_type_id . '.' . $bundle . '.' . $field_name); } /** diff --git a/core/lib/Drupal/Core/Field/EntityReferenceFieldItemList.php b/core/lib/Drupal/Core/Field/EntityReferenceFieldItemList.php index 3fa199b727..07449e8e91 100644 --- a/core/lib/Drupal/Core/Field/EntityReferenceFieldItemList.php +++ b/core/lib/Drupal/Core/Field/EntityReferenceFieldItemList.php @@ -43,7 +43,7 @@ public function referencedEntities() { // Load and add the existing entities. if ($ids) { $target_type = $this->getFieldDefinition()->getSetting('target_type'); - $entities = \Drupal::entityManager()->getStorage($target_type)->loadMultiple($ids); + $entities = \Drupal::entityTypeManager()->getStorage($target_type)->loadMultiple($ids); foreach ($ids as $delta => $target_id) { if (isset($entities[$target_id])) { $target_entities[$delta] = $entities[$target_id]; @@ -75,7 +75,7 @@ public static function processDefaultValue($default_value, FieldableEntityInterf $entity_ids = \Drupal::entityQuery($target_type) ->condition('uuid', $uuids, 'IN') ->execute(); - $entities = \Drupal::entityManager() + $entities = \Drupal::entityTypeManager() ->getStorage($target_type) ->loadMultiple($entity_ids); @@ -117,7 +117,7 @@ public function defaultValuesFormSubmit(array $element, array &$form, FormStateI } $ids[] = $default_value[$delta]['target_id']; } - $entities = \Drupal::entityManager() + $entities = \Drupal::entityTypeManager() ->getStorage($this->getSetting('target_type')) ->loadMultiple($ids); diff --git a/core/lib/Drupal/Core/Field/FieldItemBase.php b/core/lib/Drupal/Core/Field/FieldItemBase.php index 5aa4ad11d3..a6e4092a85 100644 --- a/core/lib/Drupal/Core/Field/FieldItemBase.php +++ b/core/lib/Drupal/Core/Field/FieldItemBase.php @@ -184,7 +184,7 @@ public function __unset($name) { * {@inheritdoc} */ public function view($display_options = []) { - $view_builder = \Drupal::entityManager()->getViewBuilder($this->getEntity()->getEntityTypeId()); + $view_builder = \Drupal::entityTypeManager()->getViewBuilder($this->getEntity()->getEntityTypeId()); return $view_builder->viewFieldItem($this, $display_options); } diff --git a/core/lib/Drupal/Core/Field/FieldItemList.php b/core/lib/Drupal/Core/Field/FieldItemList.php index d3eb205a02..c7ca9bf556 100644 --- a/core/lib/Drupal/Core/Field/FieldItemList.php +++ b/core/lib/Drupal/Core/Field/FieldItemList.php @@ -150,7 +150,7 @@ public function __unset($property_name) { * {@inheritdoc} */ public function access($operation = 'view', AccountInterface $account = NULL, $return_as_object = FALSE) { - $access_control_handler = \Drupal::entityManager()->getAccessControlHandler($this->getEntity()->getEntityTypeId()); + $access_control_handler = \Drupal::entityTypeManager()->getAccessControlHandler($this->getEntity()->getEntityTypeId()); return $access_control_handler->fieldAccess($operation, $this->getFieldDefinition(), $account, $this, $return_as_object); } @@ -239,7 +239,7 @@ protected function delegateMethod($method) { * {@inheritdoc} */ public function view($display_options = []) { - $view_builder = \Drupal::entityManager()->getViewBuilder($this->getEntity()->getEntityTypeId()); + $view_builder = \Drupal::entityTypeManager()->getViewBuilder($this->getEntity()->getEntityTypeId()); return $view_builder->viewField($this, $display_options); } diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php index 9333d7e227..b04cf9d91d 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php @@ -213,7 +213,7 @@ public static function isApplicable(FieldDefinitionInterface $field_definition) // This formatter is only available for entity types that have a view // builder. $target_type = $field_definition->getFieldStorageDefinition()->getSetting('target_type'); - return \Drupal::entityManager()->getDefinition($target_type)->hasViewBuilderClass(); + return \Drupal::entityTypeManager()->getDefinition($target_type)->hasViewBuilderClass(); } } diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceFormatterBase.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceFormatterBase.php index d2a691f077..1db3f0ed9a 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceFormatterBase.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceFormatterBase.php @@ -136,7 +136,7 @@ public function prepareView(array $entities_items) { } if ($ids) { $target_type = $this->getFieldSetting('target_type'); - $target_entities = \Drupal::entityManager()->getStorage($target_type)->loadMultiple($ids); + $target_entities = \Drupal::entityTypeManager()->getStorage($target_type)->loadMultiple($ids); } // For each item, pre-populate the loaded entity in $item->entity, and set diff --git a/core/lib/Drupal/Core/Menu/menu.api.php b/core/lib/Drupal/Core/Menu/menu.api.php index 4951c232db..758013f494 100644 --- a/core/lib/Drupal/Core/Menu/menu.api.php +++ b/core/lib/Drupal/Core/Menu/menu.api.php @@ -400,7 +400,7 @@ function hook_contextual_links_alter(array &$links, $group, array $route_paramet if ($group == 'menu') { // Dynamically use the menu name for the title of the menu_edit contextual // link. - $menu = \Drupal::entityManager()->getStorage('menu')->load($route_parameters['menu']); + $menu = \Drupal::entityTypeManager()->getStorage('menu')->load($route_parameters['menu']); $links['menu_edit']['title'] = t('Edit menu: @label', ['@label' => $menu->label()]); } } diff --git a/core/lib/Drupal/Core/Session/AccountProxy.php b/core/lib/Drupal/Core/Session/AccountProxy.php index 147bb62a77..bc7f554c33 100644 --- a/core/lib/Drupal/Core/Session/AccountProxy.php +++ b/core/lib/Drupal/Core/Session/AccountProxy.php @@ -195,7 +195,7 @@ public function setInitialAccountId($account_id) { * An account or NULL if none is found. */ protected function loadUserEntity($account_id) { - return \Drupal::entityManager()->getStorage('user')->load($account_id); + return \Drupal::entityTypeManager()->getStorage('user')->load($account_id); } } diff --git a/core/lib/Drupal/Core/Session/UserSession.php b/core/lib/Drupal/Core/Session/UserSession.php index ec002beb73..ba3b929a4c 100644 --- a/core/lib/Drupal/Core/Session/UserSession.php +++ b/core/lib/Drupal/Core/Session/UserSession.php @@ -203,7 +203,7 @@ public function getLastAccessedTime() { * The role storage object. */ protected function getRoleStorage() { - return \Drupal::entityManager()->getStorage('user_role'); + return \Drupal::entityTypeManager()->getStorage('user_role'); } } diff --git a/core/modules/aggregator/aggregator.module b/core/modules/aggregator/aggregator.module index 86b067604b..d8e6678ce1 100644 --- a/core/modules/aggregator/aggregator.module +++ b/core/modules/aggregator/aggregator.module @@ -142,7 +142,7 @@ function aggregator_entity_extra_field_info() { function aggregator_cron() { $queue = \Drupal::queue('aggregator_feeds'); - $ids = \Drupal::entityManager()->getStorage('aggregator_feed')->getFeedIdsToRefresh(); + $ids = \Drupal::entityTypeManager()->getStorage('aggregator_feed')->getFeedIdsToRefresh(); foreach (Feed::loadMultiple($ids) as $feed) { if ($queue->createItem($feed)) { // Add timestamp to avoid queueing item more than once. diff --git a/core/modules/aggregator/src/Entity/Feed.php b/core/modules/aggregator/src/Entity/Feed.php index e653008458..4c3a5b856e 100644 --- a/core/modules/aggregator/src/Entity/Feed.php +++ b/core/modules/aggregator/src/Entity/Feed.php @@ -125,7 +125,7 @@ public static function postDelete(EntityStorageInterface $storage, array $entiti ->condition('settings.feed', array_keys($entities)) ->execute(); if ($ids) { - $block_storage = \Drupal::entityManager()->getStorage('block'); + $block_storage = \Drupal::entityTypeManager()->getStorage('block'); $block_storage->delete($block_storage->loadMultiple($ids)); } } diff --git a/core/modules/aggregator/tests/src/Functional/FeedProcessorPluginTest.php b/core/modules/aggregator/tests/src/Functional/FeedProcessorPluginTest.php index bdc63f56b0..a5e225d43c 100644 --- a/core/modules/aggregator/tests/src/Functional/FeedProcessorPluginTest.php +++ b/core/modules/aggregator/tests/src/Functional/FeedProcessorPluginTest.php @@ -57,7 +57,7 @@ public function testPostProcess() { $this->updateFeedItems($feed); $feed_id = $feed->id(); // Reset entity cache manually. - \Drupal::entityManager()->getStorage('aggregator_feed')->resetCache([$feed_id]); + \Drupal::entityTypeManager()->getStorage('aggregator_feed')->resetCache([$feed_id]); // Reload the feed to get new values. $feed = Feed::load($feed_id); // Make sure its refresh rate doubled. diff --git a/core/modules/block/block.post_update.php b/core/modules/block/block.post_update.php index 0d49ead480..e9e332ad08 100644 --- a/core/modules/block/block.post_update.php +++ b/core/modules/block/block.post_update.php @@ -30,7 +30,7 @@ function block_post_update_disable_blocks_with_missing_contexts() { $block_update_8001 = \Drupal::keyValue('update_backup')->get('block_update_8001', []); $block_ids = array_keys($block_update_8001); - $block_storage = \Drupal::entityManager()->getStorage('block'); + $block_storage = \Drupal::entityTypeManager()->getStorage('block'); $blocks = $block_storage->loadMultiple($block_ids); /** @var $blocks \Drupal\block\BlockInterface[] */ foreach ($blocks as $block) { diff --git a/core/modules/block_content/tests/src/Functional/BlockContentTranslationUITest.php b/core/modules/block_content/tests/src/Functional/BlockContentTranslationUITest.php index 9c2c1b44b7..c34e30f085 100644 --- a/core/modules/block_content/tests/src/Functional/BlockContentTranslationUITest.php +++ b/core/modules/block_content/tests/src/Functional/BlockContentTranslationUITest.php @@ -132,7 +132,7 @@ protected function doTestBasicTranslation() { // as in the original language. $default_langcode = $this->langcodes[0]; $values = $this->getNewEntityValues($default_langcode); - $storage = \Drupal::entityManager()->getStorage($this->entityTypeId); + $storage = \Drupal::entityTypeManager()->getStorage($this->entityTypeId); /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */ $entity = $storage->create(['type' => 'basic'] + $values); $entity->save(); diff --git a/core/modules/block_content/tests/src/Functional/BlockContentTypeTest.php b/core/modules/block_content/tests/src/Functional/BlockContentTypeTest.php index b707c83a92..2ce9c89377 100644 --- a/core/modules/block_content/tests/src/Functional/BlockContentTypeTest.php +++ b/core/modules/block_content/tests/src/Functional/BlockContentTypeTest.php @@ -67,7 +67,7 @@ public function testBlockContentTypeCreation() { $block_type = BlockContentType::load('foo'); $this->assertTrue($block_type, 'The new block type has been created.'); - $field_definitions = \Drupal::entityManager()->getFieldDefinitions('block_content', 'foo'); + $field_definitions = \Drupal::service('entity_field.manager')->getFieldDefinitions('block_content', 'foo'); $this->assertTrue(isset($field_definitions['body']), 'Body field created when using the UI to create block content types.'); // Check that the block type was created in site default language. @@ -76,11 +76,11 @@ public function testBlockContentTypeCreation() { // Create block types programmatically. $this->createBlockContentType('basic', TRUE); - $field_definitions = \Drupal::entityManager()->getFieldDefinitions('block_content', 'basic'); + $field_definitions = \Drupal::service('entity_field.manager')->getFieldDefinitions('block_content', 'basic'); $this->assertTrue(isset($field_definitions['body']), "Body field for 'basic' block type created when using the testing API to create block content types."); $this->createBlockContentType('other'); - $field_definitions = \Drupal::entityManager()->getFieldDefinitions('block_content', 'other'); + $field_definitions = \Drupal::service('entity_field.manager')->getFieldDefinitions('block_content', 'other'); $this->assertFalse(isset($field_definitions['body']), "Body field for 'other' block type not created when using the testing API to create block content types."); $block_type = BlockContentType::load('other'); @@ -102,7 +102,7 @@ public function testBlockContentTypeEditing() { // We need two block types to prevent /block/add redirecting. $this->createBlockContentType('other'); - $field_definitions = \Drupal::entityManager()->getFieldDefinitions('block_content', 'other'); + $field_definitions = \Drupal::service('entity_field.manager')->getFieldDefinitions('block_content', 'other'); $this->assertFalse(isset($field_definitions['body']), 'Body field was not created when using the API to create block content types.'); // Verify that title and body fields are displayed. @@ -124,7 +124,7 @@ public function testBlockContentTypeEditing() { 'admin/structure/block/block-content' => 'Custom block library', 'admin/structure/block/block-content/manage/basic' => 'Edit Bar', ]); - \Drupal::entityManager()->clearCachedFieldDefinitions(); + \Drupal::service('entity_field.manager')->clearCachedFieldDefinitions(); $this->drupalGet('block/add'); $this->assertRaw('Bar', 'New name was displayed.'); diff --git a/core/modules/block_content/tests/src/Functional/PageEditTest.php b/core/modules/block_content/tests/src/Functional/PageEditTest.php index f623cfa28a..e751c70b09 100644 --- a/core/modules/block_content/tests/src/Functional/PageEditTest.php +++ b/core/modules/block_content/tests/src/Functional/PageEditTest.php @@ -57,7 +57,7 @@ public function testPageEdit() { $this->drupalPostForm(NULL, $edit, t('Save')); // Ensure that the block revision has been created. - \Drupal::entityManager()->getStorage('block_content')->resetCache([$block->id()]); + \Drupal::entityTypeManager()->getStorage('block_content')->resetCache([$block->id()]); $revised_block = BlockContent::load($block->id()); $this->assertNotIdentical($block->getRevisionId(), $revised_block->getRevisionId(), 'A new revision has been created.'); diff --git a/core/modules/book/book.module b/core/modules/book/book.module index b5d5515969..3d9f2f257e 100644 --- a/core/modules/book/book.module +++ b/core/modules/book/book.module @@ -96,7 +96,7 @@ function book_node_links_alter(array &$links, NodeInterface $node, array &$conte if (isset($node->book['depth'])) { if ($context['view_mode'] == 'full' && node_is_page($node)) { $child_type = \Drupal::config('book.settings')->get('child_type'); - $access_control_handler = \Drupal::entityManager()->getAccessControlHandler('node'); + $access_control_handler = \Drupal::entityTypeManager()->getAccessControlHandler('node'); if (($account->hasPermission('add content to books') || $account->hasPermission('administer book outlines')) && $access_control_handler->createAccess($child_type) && $node->isPublished() && $node->book['depth'] < BookManager::BOOK_MAX_DEPTH) { $book_links['book_add_child'] = [ 'title' => t('Add child page'), diff --git a/core/modules/book/tests/src/Functional/BookBreadcrumbTest.php b/core/modules/book/tests/src/Functional/BookBreadcrumbTest.php index a863ff1529..5271c8e7b8 100644 --- a/core/modules/book/tests/src/Functional/BookBreadcrumbTest.php +++ b/core/modules/book/tests/src/Functional/BookBreadcrumbTest.php @@ -118,7 +118,7 @@ protected function createBookNode($book_nid, $parent = NULL) { $edit['book[pid]'] = $parent; $this->drupalPostForm(NULL, $edit, t('Save')); // Make sure the parent was flagged as having children. - $parent_node = \Drupal::entityManager()->getStorage('node')->loadUnchanged($parent); + $parent_node = \Drupal::entityTypeManager()->getStorage('node')->loadUnchanged($parent); $this->assertFalse(empty($parent_node->book['has_children']), 'Parent node is marked as having children'); } else { diff --git a/core/modules/book/tests/src/Functional/BookTest.php b/core/modules/book/tests/src/Functional/BookTest.php index 39c856c7e2..56aed15cd0 100644 --- a/core/modules/book/tests/src/Functional/BookTest.php +++ b/core/modules/book/tests/src/Functional/BookTest.php @@ -403,7 +403,7 @@ public function testBookOutline() { $edit = []; $edit['book[bid]'] = '1'; $this->drupalPostForm('node/' . $empty_book->id() . '/outline', $edit, t('Add to book outline')); - $node = \Drupal::entityManager()->getStorage('node')->load($empty_book->id()); + $node = \Drupal::entityTypeManager()->getStorage('node')->load($empty_book->id()); // Test the book array. $this->assertEqual($node->book['nid'], $empty_book->id()); $this->assertEqual($node->book['bid'], $empty_book->id()); @@ -426,7 +426,7 @@ public function testBookOutline() { $edit = []; $edit['book[bid]'] = $node->id(); $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save')); - $node = \Drupal::entityManager()->getStorage('node')->load($node->id()); + $node = \Drupal::entityTypeManager()->getStorage('node')->load($node->id()); // Test the book array. $this->assertEqual($node->book['nid'], $node->id()); @@ -517,7 +517,7 @@ public function testHookNodeLoadAccess() { $this->drupalLogin($this->bookAuthor); $this->book = $this->createBookNode('new'); // Reset any internal static caching. - $node_storage = \Drupal::entityManager()->getStorage('node'); + $node_storage = \Drupal::entityTypeManager()->getStorage('node'); $node_storage->resetCache(); // Log in as user without access to the book node, so no 'node test view' diff --git a/core/modules/book/tests/src/Functional/BookTestTrait.php b/core/modules/book/tests/src/Functional/BookTestTrait.php index 221ed1fcf5..85d80e44e1 100644 --- a/core/modules/book/tests/src/Functional/BookTestTrait.php +++ b/core/modules/book/tests/src/Functional/BookTestTrait.php @@ -197,7 +197,7 @@ public function createBookNode($book_nid, $parent = NULL, $edit = []) { $edit['book[pid]'] = $parent; $this->drupalPostForm(NULL, $edit, t('Save')); // Make sure the parent was flagged as having children. - $parent_node = \Drupal::entityManager()->getStorage('node')->loadUnchanged($parent); + $parent_node = \Drupal::entityTypeManager()->getStorage('node')->loadUnchanged($parent); $this->assertFalse(empty($parent_node->book['has_children']), 'Parent node is marked as having children'); } else { diff --git a/core/modules/book/tests/src/Functional/Views/BookRelationshipTest.php b/core/modules/book/tests/src/Functional/Views/BookRelationshipTest.php index 9ee79c78dc..30b8a8445a 100644 --- a/core/modules/book/tests/src/Functional/Views/BookRelationshipTest.php +++ b/core/modules/book/tests/src/Functional/Views/BookRelationshipTest.php @@ -121,7 +121,7 @@ protected function createBookNode($book_nid, $parent = NULL) { $edit['book[pid]'] = $parent; $this->drupalPostForm(NULL, $edit, t('Save')); // Make sure the parent was flagged as having children. - $parent_node = \Drupal::entityManager()->getStorage('node')->loadUnchanged($parent); + $parent_node = \Drupal::entityTypeManager()->getStorage('node')->loadUnchanged($parent); $this->assertFalse(empty($parent_node->book['has_children']), 'Parent node is marked as having children'); } else { diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 8a63a7eae3..1cfcfca3ac 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -177,7 +177,7 @@ function comment_field_config_update(FieldConfigInterface $field) { if ($field->getType() == 'comment') { // Comment field settings also affects the rendering of *comment* entities, // not only the *commented* entities. - \Drupal::entityManager()->getViewBuilder('comment')->resetCache(); + \Drupal::entityTypeManager()->getViewBuilder('comment')->resetCache(); } } @@ -272,7 +272,7 @@ function comment_node_view_alter(array &$build, EntityInterface $node, EntityVie * An array as expected by \Drupal\Core\Render\RendererInterface::render(). * * @deprecated in Drupal 8.x and will be removed before Drupal 9.0. - * Use \Drupal::entityManager()->getViewBuilder('comment')->view(). + * Use \Drupal::entityTypeManager()->getViewBuilder('comment')->view(). */ function comment_view(CommentInterface $comment, $view_mode = 'full', $langcode = NULL) { return entity_view($comment, $view_mode, $langcode); @@ -296,7 +296,7 @@ function comment_view(CommentInterface $comment, $view_mode = 'full', $langcode * \Drupal\Core\Render\RendererInterface::render(). * * @deprecated in Drupal 8.x and will be removed before Drupal 9.0. - * Use \Drupal::entityManager()->getViewBuilder('comment')->viewMultiple(). + * Use \Drupal::entityTypeManager()->getViewBuilder('comment')->viewMultiple(). * * @see \Drupal\Core\Render\RendererInterface::render() */ @@ -346,7 +346,7 @@ function comment_form_field_ui_display_overview_form_alter(&$form, FormStateInte */ function comment_entity_storage_load($entities, $entity_type) { // Comments can only be attached to content entities, so skip others. - if (!\Drupal::entityManager()->getDefinition($entity_type)->entityClassImplements(FieldableEntityInterface::class)) { + if (!\Drupal::entityTypeManager()->getDefinition($entity_type)->entityClassImplements(FieldableEntityInterface::class)) { return; } if (!\Drupal::service('comment.manager')->getFields($entity_type)) { @@ -413,12 +413,12 @@ function comment_entity_predelete(EntityInterface $entity) { * FALSE otherwise. */ function _comment_entity_uses_integer_id($entity_type_id) { - $entity_type = \Drupal::entityManager()->getDefinition($entity_type_id); + $entity_type = \Drupal::entityTypeManager()->getDefinition($entity_type_id); $entity_type_id_key = $entity_type->getKey('id'); if ($entity_type_id_key === FALSE) { return FALSE; } - $field_definitions = \Drupal::entityManager()->getBaseFieldDefinitions($entity_type->id()); + $field_definitions = \Drupal::service('entity_field.manager')->getBaseFieldDefinitions($entity_type->id()); $entity_type_id_definition = $field_definitions[$entity_type_id_key]; return $entity_type_id_definition->getType() === 'integer'; } @@ -440,7 +440,7 @@ function comment_node_update_index(EntityInterface $node) { // edit could change the security situation so it is not safe to index the // comments. $index_comments = TRUE; - $roles = \Drupal::entityManager()->getStorage('user_role')->loadMultiple(); + $roles = \Drupal::entityTypeManager()->getStorage('user_role')->loadMultiple(); $authenticated_can_access = $roles[RoleInterface::AUTHENTICATED_ID]->hasPermission('access comments'); foreach ($roles as $rid => $role) { if ($role->hasPermission('search content') && !$role->hasPermission('access comments')) { @@ -464,10 +464,10 @@ function comment_node_update_index(EntityInterface $node) { $mode = $field_definition->getSetting('default_mode'); $comments_per_page = $field_definition->getSetting('per_page'); if ($node->get($field_name)->status) { - $comments = \Drupal::entityManager()->getStorage('comment') + $comments = \Drupal::entityTypeManager()->getStorage('comment') ->loadThread($node, $field_name, $mode, $comments_per_page); if ($comments) { - $build[] = \Drupal::entityManager()->getViewBuilder('comment')->viewMultiple($comments); + $build[] = \Drupal::entityTypeManager()->getViewBuilder('comment')->viewMultiple($comments); } } } diff --git a/core/modules/comment/comment.views.inc b/core/modules/comment/comment.views.inc index 11abede944..e5df31a1a0 100644 --- a/core/modules/comment/comment.views.inc +++ b/core/modules/comment/comment.views.inc @@ -23,7 +23,7 @@ function comment_views_data_alter(&$data) { ]; // Provide a integration for each entity type except comment. - foreach (\Drupal::entityManager()->getDefinitions() as $entity_type_id => $entity_type) { + foreach (\Drupal::entityTypeManager()->getDefinitions() as $entity_type_id => $entity_type) { if ($entity_type_id == 'comment' || !$entity_type->entityClassImplements(ContentEntityInterface::class) || !$entity_type->getBaseTable()) { continue; } diff --git a/core/modules/comment/src/CommentViewsData.php b/core/modules/comment/src/CommentViewsData.php index 7fb74217c4..956a33544b 100644 --- a/core/modules/comment/src/CommentViewsData.php +++ b/core/modules/comment/src/CommentViewsData.php @@ -193,7 +193,7 @@ public function getViewsData() { unset($data['comment_field_data']['thread']['filter']); unset($data['comment_field_data']['thread']['argument']); - $entities_types = \Drupal::entityManager()->getDefinitions(); + $entities_types = \Drupal::entityTypeManager()->getDefinitions(); // Provide a relationship for each entity type except comment. foreach ($entities_types as $type => $entity_type) { diff --git a/core/modules/comment/src/Plugin/views/field/NodeNewComments.php b/core/modules/comment/src/Plugin/views/field/NodeNewComments.php index a1efc1da10..b1a3de16f4 100644 --- a/core/modules/comment/src/Plugin/views/field/NodeNewComments.php +++ b/core/modules/comment/src/Plugin/views/field/NodeNewComments.php @@ -4,6 +4,8 @@ use Drupal\Core\Database\Connection; use Drupal\comment\CommentInterface; +use Drupal\Core\Entity\EntityFieldManagerInterface; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\node\Entity\Node; use Drupal\views\Plugin\views\field\NumericField; @@ -35,6 +37,20 @@ public function usesGroupBy() { */ protected $database; + /** + * The entity type manager. + * + * @var \Drupal\Core\Entity\EntityTypeManagerInterface + */ + protected $entityTypeManager; + + /** + * The entity field manager. + * + * @var \Drupal\Core\Entity\EntityFieldManagerInterface + */ + protected $entityFieldManager; + /** * Constructs a \Drupal\comment\Plugin\views\field\NodeNewComments object. * @@ -46,18 +62,38 @@ public function usesGroupBy() { * The plugin implementation definition. * @param \Drupal\Core\Database\Connection $database * Database Service Object. + * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager + * The entity type manager service. + * @param \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager + * The entity field manager service. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, Connection $database) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, Connection $database, EntityTypeManagerInterface $entity_type_manager = NULL, EntityFieldManagerInterface $entity_field_manager = NULL) { parent::__construct($configuration, $plugin_id, $plugin_definition); - $this->database = $database; + if (!$entity_type_manager) { + @trigger_error("Not passing the entity type manager to the NodeNewComments constructor is deprecated in drupal:8.8.0 and will be required in drupal 9.0.0. @see https://www.drupal.org/node/3047897"); + $entity_type_manager = \Drupal::entityTypeManager(); + } + if (!$entity_field_manager) { + @trigger_error("Not passing the entity type manager to the NodeNewComments constructor is deprecated in drupal:8.8.0 and will be required in drupal 9.0.0. @see https://www.drupal.org/node/3047897"); + $entity_field_manager = \Drupal::service('entity_field.manager'); + } + $this->entityTypeManager = $entity_type_manager; + $this->entityFieldManager = $entity_field_manager; } /** * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { - return new static($configuration, $plugin_id, $plugin_definition, $container->get('database')); + return new static( + $configuration, + $plugin_id, + $plugin_definition, + $container->get('database'), + $container->get('entity_type.manager'), + $container->get('entity_field.manager') + ); } /** @@ -166,8 +202,7 @@ protected function renderLink($data, ResultRow $values) { // reference, we arbitrarily use the first such field name we find. // @todo Provide a means for selecting the comment field. // https://www.drupal.org/node/2594201 - $entity_manager = \Drupal::entityManager(); - $field_map = $entity_manager->getFieldMapByFieldType('comment'); + $field_map = $this->entityFieldManager->getFieldMapByFieldType('comment'); $comment_field_name = 'comment'; foreach ($field_map['node'] as $field_name => $field_data) { foreach ($field_data['bundles'] as $bundle_name) { @@ -177,7 +212,7 @@ protected function renderLink($data, ResultRow $values) { } } } - $page_number = $entity_manager->getStorage('comment') + $page_number = $this->entityTypeManager->getStorage('comment') ->getNewCommentPageNumber($this->getValue($values, 'comment_count'), $this->getValue($values), $node, $comment_field_name); $this->options['alter']['make_link'] = TRUE; $this->options['alter']['url'] = $node->toUrl(); diff --git a/core/modules/comment/src/Tests/CommentTestBase.php b/core/modules/comment/src/Tests/CommentTestBase.php index 22a842e2f7..dcd22105c0 100644 --- a/core/modules/comment/src/Tests/CommentTestBase.php +++ b/core/modules/comment/src/Tests/CommentTestBase.php @@ -176,7 +176,7 @@ public function postComment($entity, $comment, $subject = '', $contact = NULL, $ } if (isset($match[1])) { - \Drupal::entityManager()->getStorage('comment')->resetCache([$match[1]]); + \Drupal::entityTypeManager()->getStorage('comment')->resetCache([$match[1]]); return Comment::load($match[1]); } } diff --git a/core/modules/comment/src/Tests/CommentTestTrait.php b/core/modules/comment/src/Tests/CommentTestTrait.php index 0c0d65de16..8c277fb1f1 100644 --- a/core/modules/comment/src/Tests/CommentTestTrait.php +++ b/core/modules/comment/src/Tests/CommentTestTrait.php @@ -34,10 +34,11 @@ trait CommentTestTrait { * Defaults to 'full'. */ public function addDefaultCommentField($entity_type, $bundle, $field_name = 'comment', $default_value = CommentItemInterface::OPEN, $comment_type_id = 'comment', $comment_view_mode = 'full') { - $entity_manager = \Drupal::entityManager(); + $entity_type_manager = \Drupal::entityTypeManager(); + $entity_field_manager = \Drupal::service('entity_field.manager'); $entity_display_repository = \Drupal::service('entity_display.repository'); // Create the comment type if needed. - $comment_type_storage = $entity_manager->getStorage('comment_type'); + $comment_type_storage = $entity_type_manager->getStorage('comment_type'); if ($comment_type = $comment_type_storage->load($comment_type_id)) { if ($comment_type->getTargetEntityTypeId() !== $entity_type) { throw new \InvalidArgumentException("The given comment type id $comment_type_id can only be used with the $entity_type entity type"); @@ -56,8 +57,8 @@ public function addDefaultCommentField($entity_type, $bundle, $field_name = 'com // Add a comment field to the host entity type. Create the field storage if // needed. - if (!array_key_exists($field_name, $entity_manager->getFieldStorageDefinitions($entity_type))) { - $entity_manager->getStorage('field_storage_config')->create([ + if (!array_key_exists($field_name, $entity_field_manager->getFieldStorageDefinitions($entity_type))) { + $entity_type_manager->getStorage('field_storage_config')->create([ 'entity_type' => $entity_type, 'field_name' => $field_name, 'type' => 'comment', @@ -68,8 +69,8 @@ public function addDefaultCommentField($entity_type, $bundle, $field_name = 'com ])->save(); } // Create the field if needed, and configure its form and view displays. - if (!array_key_exists($field_name, $entity_manager->getFieldDefinitions($entity_type, $bundle))) { - $entity_manager->getStorage('field_config')->create([ + if (!array_key_exists($field_name, $entity_field_manager->getFieldDefinitions($entity_type, $bundle))) { + $entity_type_manager->getStorage('field_config')->create([ 'label' => 'Comments', 'description' => '', 'field_name' => $field_name, diff --git a/core/modules/comment/tests/src/Functional/CommentPagerTest.php b/core/modules/comment/tests/src/Functional/CommentPagerTest.php index b0532ce395..93b7ea81a7 100644 --- a/core/modules/comment/tests/src/Functional/CommentPagerTest.php +++ b/core/modules/comment/tests/src/Functional/CommentPagerTest.php @@ -283,7 +283,7 @@ public function testCommentNewPageIndicator() { $node = Node::load($node->id()); foreach ($expected_pages as $new_replies => $expected_page) { - $returned_page = \Drupal::entityManager()->getStorage('comment') + $returned_page = \Drupal::entityTypeManager()->getStorage('comment') ->getNewCommentPageNumber($node->get('comment')->comment_count, $new_replies, $node, 'comment'); $this->assertIdentical($expected_page, $returned_page, format_string('Flat mode, @new replies: expected page @expected, returned page @returned.', ['@new' => $new_replies, '@expected' => $expected_page, '@returned' => $returned_page])); } @@ -305,10 +305,10 @@ public function testCommentNewPageIndicator() { 6 => 0, ]; - \Drupal::entityManager()->getStorage('node')->resetCache([$node->id()]); + \Drupal::entityTypeManager()->getStorage('node')->resetCache([$node->id()]); $node = Node::load($node->id()); foreach ($expected_pages as $new_replies => $expected_page) { - $returned_page = \Drupal::entityManager()->getStorage('comment') + $returned_page = \Drupal::entityTypeManager()->getStorage('comment') ->getNewCommentPageNumber($node->get('comment')->comment_count, $new_replies, $node, 'comment'); $this->assertEqual($expected_page, $returned_page, format_string('Threaded mode, @new replies: expected page @expected, returned page @returned.', ['@new' => $new_replies, '@expected' => $expected_page, '@returned' => $returned_page])); } diff --git a/core/modules/comment/tests/src/Functional/CommentPreviewTest.php b/core/modules/comment/tests/src/Functional/CommentPreviewTest.php index cee08ae39c..c64eeaa6db 100644 --- a/core/modules/comment/tests/src/Functional/CommentPreviewTest.php +++ b/core/modules/comment/tests/src/Functional/CommentPreviewTest.php @@ -185,7 +185,7 @@ public function testCommentEditPreviewSave() { $this->drupalPostForm('comment/' . $comment->id() . '/edit', $displayed, t('Save')); // Check that the saved comment is still correct. - $comment_storage = \Drupal::entityManager()->getStorage('comment'); + $comment_storage = \Drupal::entityTypeManager()->getStorage('comment'); $comment_storage->resetCache([$comment->id()]); /** @var \Drupal\comment\CommentInterface $comment_loaded */ $comment_loaded = Comment::load($comment->id()); diff --git a/core/modules/comment/tests/src/Functional/CommentTestBase.php b/core/modules/comment/tests/src/Functional/CommentTestBase.php index 09d3b8e340..ceb83654df 100644 --- a/core/modules/comment/tests/src/Functional/CommentTestBase.php +++ b/core/modules/comment/tests/src/Functional/CommentTestBase.php @@ -170,7 +170,7 @@ public function postComment($entity, $comment, $subject = '', $contact = NULL, $ } if (isset($match[1])) { - \Drupal::entityManager()->getStorage('comment')->resetCache([$match[1]]); + \Drupal::entityTypeManager()->getStorage('comment')->resetCache([$match[1]]); return Comment::load($match[1]); } } diff --git a/core/modules/comment/tests/src/Functional/CommentTranslationUITest.php b/core/modules/comment/tests/src/Functional/CommentTranslationUITest.php index 68a60a4790..2d7787e744 100644 --- a/core/modules/comment/tests/src/Functional/CommentTranslationUITest.php +++ b/core/modules/comment/tests/src/Functional/CommentTranslationUITest.php @@ -125,8 +125,8 @@ protected function getNewEntityValues($langcode) { * {@inheritdoc} */ protected function doTestPublishedStatus() { - $entity_manager = \Drupal::entityManager(); - $storage = $entity_manager->getStorage($this->entityTypeId); + $entity_type_manager = \Drupal::entityTypeManager(); + $storage = $entity_type_manager->getStorage($this->entityTypeId); $storage->resetCache(); $entity = $storage->load($this->entityId); diff --git a/core/modules/comment/tests/src/Functional/CommentTypeTest.php b/core/modules/comment/tests/src/Functional/CommentTypeTest.php index 291f9dc3e1..e771949e78 100644 --- a/core/modules/comment/tests/src/Functional/CommentTypeTest.php +++ b/core/modules/comment/tests/src/Functional/CommentTypeTest.php @@ -83,7 +83,7 @@ public function testCommentTypeCreation() { // Save the form and ensure the entity-type value is preserved even though // the field isn't present. $this->drupalPostForm(NULL, [], t('Save')); - \Drupal::entityManager()->getStorage('comment_type')->resetCache(['foo']); + \Drupal::entityTypeManager()->getStorage('comment_type')->resetCache(['foo']); $comment_type = CommentType::load('foo'); $this->assertEqual($comment_type->getTargetEntityTypeId(), 'node'); } diff --git a/core/modules/comment/tests/src/Kernel/CommentDefaultFormatterCacheTagsTest.php b/core/modules/comment/tests/src/Kernel/CommentDefaultFormatterCacheTagsTest.php index bdea71df15..e681a4d9ad 100644 --- a/core/modules/comment/tests/src/Kernel/CommentDefaultFormatterCacheTagsTest.php +++ b/core/modules/comment/tests/src/Kernel/CommentDefaultFormatterCacheTagsTest.php @@ -74,7 +74,7 @@ public function testCacheTags() { $commented_entity->save(); // Verify cache tags on the rendered entity before it has comments. - $build = \Drupal::entityManager() + $build = \Drupal::entityTypeManager() ->getViewBuilder('entity_test') ->view($commented_entity); $renderer->renderRoot($build); @@ -117,7 +117,7 @@ public function testCacheTags() { $commented_entity = $storage->load($commented_entity->id()); // Verify cache tags on the rendered entity when it has comments. - $build = \Drupal::entityManager() + $build = \Drupal::entityTypeManager() ->getViewBuilder('entity_test') ->view($commented_entity); $renderer->renderRoot($build); @@ -142,7 +142,7 @@ public function testCacheTags() { // builder elements bubble up outside of the entity and we can check that // it got the correct cache max age. $build = ['#type' => 'container']; - $build['entity'] = \Drupal::entityManager() + $build['entity'] = \Drupal::entityTypeManager() ->getViewBuilder('entity_test') ->view($commented_entity); $renderer->renderRoot($build); diff --git a/core/modules/comment/tests/src/Kernel/CommentValidationTest.php b/core/modules/comment/tests/src/Kernel/CommentValidationTest.php index 4c2481c984..77a7dd8fee 100644 --- a/core/modules/comment/tests/src/Kernel/CommentValidationTest.php +++ b/core/modules/comment/tests/src/Kernel/CommentValidationTest.php @@ -138,7 +138,7 @@ public function testValidation() { $field->setSetting('anonymous', CommentInterface::ANONYMOUS_MUST_CONTACT); $field->save(); // Reset the node entity. - \Drupal::entityManager()->getStorage('node')->resetCache([$node->id()]); + \Drupal::entityTypeManager()->getStorage('node')->resetCache([$node->id()]); $node = Node::load($node->id()); // Create a new comment with the new field. $comment = $this->entityManager->getStorage('comment')->create([ diff --git a/core/modules/comment/tests/src/Kernel/Migrate/MigrateCommentStubTest.php b/core/modules/comment/tests/src/Kernel/Migrate/MigrateCommentStubTest.php index 3b0674222c..fdb415e46e 100644 --- a/core/modules/comment/tests/src/Kernel/Migrate/MigrateCommentStubTest.php +++ b/core/modules/comment/tests/src/Kernel/Migrate/MigrateCommentStubTest.php @@ -31,7 +31,7 @@ protected function setUp() { $this->installSchema('system', ['sequences']); // Make sure uid 0 is created (default uid for comments is 0). - $storage = \Drupal::entityManager()->getStorage('user'); + $storage = \Drupal::entityTypeManager()->getStorage('user'); // Insert a row for the anonymous user. $storage ->create([ diff --git a/core/modules/comment/tests/src/Kernel/Views/CommentUserNameTest.php b/core/modules/comment/tests/src/Kernel/Views/CommentUserNameTest.php index 30a8a64ffa..1a8db39d4b 100644 --- a/core/modules/comment/tests/src/Kernel/Views/CommentUserNameTest.php +++ b/core/modules/comment/tests/src/Kernel/Views/CommentUserNameTest.php @@ -42,7 +42,7 @@ protected function setUp($import_test_views = TRUE) { $this->installConfig(['user']); // Create an anonymous user. - $storage = \Drupal::entityManager()->getStorage('user'); + $storage = \Drupal::entityTypeManager()->getStorage('user'); // Insert a row for the anonymous user. $storage ->create([ diff --git a/core/modules/config/tests/src/Functional/ConfigEntityListMultilingualTest.php b/core/modules/config/tests/src/Functional/ConfigEntityListMultilingualTest.php index 7c5fa1fac1..cf9ff99f22 100644 --- a/core/modules/config/tests/src/Functional/ConfigEntityListMultilingualTest.php +++ b/core/modules/config/tests/src/Functional/ConfigEntityListMultilingualTest.php @@ -25,7 +25,7 @@ class ConfigEntityListMultilingualTest extends BrowserTestBase { protected function setUp() { parent::setUp(); // Delete the override config_test entity. It is not required by this test. - \Drupal::entityManager()->getStorage('config_test')->load('override')->delete(); + \Drupal::entityTypeManager()->getStorage('config_test')->load('override')->delete(); ConfigurableLanguage::createFromLangcode('hu')->save(); $this->drupalPlaceBlock('local_actions_block'); diff --git a/core/modules/config/tests/src/Functional/ConfigEntityListTest.php b/core/modules/config/tests/src/Functional/ConfigEntityListTest.php index b92629d197..10dffd9869 100644 --- a/core/modules/config/tests/src/Functional/ConfigEntityListTest.php +++ b/core/modules/config/tests/src/Functional/ConfigEntityListTest.php @@ -30,7 +30,7 @@ protected function setUp() { parent::setUp(); // Delete the override config_test entity since it is not required by this // test. - \Drupal::entityManager()->getStorage('config_test')->load('override')->delete(); + \Drupal::entityTypeManager()->getStorage('config_test')->load('override')->delete(); $this->drupalPlaceBlock('local_actions_block'); } @@ -38,7 +38,7 @@ protected function setUp() { * Tests entity list builder methods. */ public function testList() { - $controller = \Drupal::entityManager()->getListBuilder('config_test'); + $controller = \Drupal::service('entity_field.manager')->getListBuilder('config_test'); // Test getStorage() method. $this->assertTrue($controller->getStorage() instanceof EntityStorageInterface, 'EntityStorage instance in storage.'); @@ -252,7 +252,7 @@ public function testListUI() { public function testPager() { $this->drupalLogin($this->drupalCreateUser(['administer site configuration'])); - $storage = \Drupal::entityManager()->getListBuilder('config_test')->getStorage(); + $storage = \Drupal::service('entity_field.manager')->getListBuilder('config_test')->getStorage(); // Create 51 test entities. for ($i = 1; $i < 52; $i++) { diff --git a/core/modules/config/tests/src/Functional/ConfigInstallProfileOverrideTest.php b/core/modules/config/tests/src/Functional/ConfigInstallProfileOverrideTest.php index 8615da5865..167d2a7e26 100644 --- a/core/modules/config/tests/src/Functional/ConfigInstallProfileOverrideTest.php +++ b/core/modules/config/tests/src/Functional/ConfigInstallProfileOverrideTest.php @@ -94,7 +94,7 @@ public function testInstallProfileConfigOverwrite() { // configuration in a modules config/install directory. $this->container->get('module_installer')->install(['config_test']); $this->rebuildContainer(); - $config_test_storage = \Drupal::entityManager()->getStorage('config_test'); + $config_test_storage = \Drupal::entityTypeManager()->getStorage('config_test'); $this->assertEqual($config_test_storage->load('dotted.default')->label(), 'Default install profile override', 'The config_test entity is overridden by the profile optional configuration.'); // Test that override of optional configuration does work. $this->assertEqual($config_test_storage->load('override')->label(), 'Override', 'The optional config_test entity is overridden by the profile optional configuration.'); @@ -115,7 +115,7 @@ public function testInstallProfileConfigOverwrite() { // that deleted profile configuration is not re-created. $this->container->get('module_installer')->install(['config_other_module_config_test']); $this->rebuildContainer(); - $config_test_storage = \Drupal::entityManager()->getStorage('config_test'); + $config_test_storage = \Drupal::entityTypeManager()->getStorage('config_test'); $this->assertNull($config_test_storage->load('completely_new')); } diff --git a/core/modules/config/tests/src/Functional/ConfigSingleImportExportTest.php b/core/modules/config/tests/src/Functional/ConfigSingleImportExportTest.php index 69a7ed74ea..65e76e0583 100644 --- a/core/modules/config/tests/src/Functional/ConfigSingleImportExportTest.php +++ b/core/modules/config/tests/src/Functional/ConfigSingleImportExportTest.php @@ -36,7 +36,7 @@ protected function setUp() { * Tests importing a single configuration file. */ public function testImport() { - $storage = \Drupal::entityManager()->getStorage('config_test'); + $storage = \Drupal::entityTypeManager()->getStorage('config_test'); $uuid = \Drupal::service('uuid'); $this->drupalLogin($this->drupalCreateUser(['import configuration'])); @@ -254,7 +254,7 @@ public function testExport() { $this->drupalGet('admin/config/development/configuration/single/export/date_format/fallback'); $this->assertFieldByXPath('//select[@name="config_name"]//option[@selected="selected"]', t('Fallback date format (fallback)'), 'The fallback date format config entity is selected when specified in the URL.'); - $fallback_date = \Drupal::entityManager()->getStorage('date_format')->load('fallback'); + $fallback_date = \Drupal::entityTypeManager()->getStorage('date_format')->load('fallback'); $yaml_text = $this->xpath('//textarea[@name="export"]')[0]->getValue(); $this->assertEqual(Yaml::decode($yaml_text), $fallback_date->toArray(), 'The fallback date format config entity export code is displayed.'); } diff --git a/core/modules/config_translation/config_translation.api.php b/core/modules/config_translation/config_translation.api.php index f97e25997a..8e337309c0 100644 --- a/core/modules/config_translation/config_translation.api.php +++ b/core/modules/config_translation/config_translation.api.php @@ -32,14 +32,14 @@ * @see \Drupal\config_translation\Routing\RouteSubscriber::routes() */ function hook_config_translation_info(&$info) { - $entity_manager = \Drupal::entityManager(); + $entity_type_manager = \Drupal::entityTypeManager(); $route_provider = \Drupal::service('router.route_provider'); // If field UI is not enabled, the base routes of the type // "entity.field_config.{$entity_type}_field_edit_form" are not defined. if (\Drupal::moduleHandler()->moduleExists('field_ui')) { // Add fields entity mappers to all fieldable entity types defined. - foreach ($entity_manager->getDefinitions() as $entity_type_id => $entity_type) { + foreach ($entity_type_manager->getDefinitions() as $entity_type_id => $entity_type) { $base_route = NULL; try { $base_route = $route_provider->getRouteByName('entity.field_config.' . $entity_type_id . '_field_edit_form'); diff --git a/core/modules/config_translation/config_translation.module b/core/modules/config_translation/config_translation.module index e6750ed4df..0f394dec96 100644 --- a/core/modules/config_translation/config_translation.module +++ b/core/modules/config_translation/config_translation.module @@ -101,13 +101,13 @@ function config_translation_entity_type_alter(array &$entity_types) { * Implements hook_config_translation_info(). */ function config_translation_config_translation_info(&$info) { - $entity_manager = \Drupal::entityManager(); + $entity_type_manager = \Drupal::entityTypeManager(); // If field UI is not enabled, the base routes of the type // "entity.field_config.{$entity_type}_field_edit_form" are not defined. if (\Drupal::moduleHandler()->moduleExists('field_ui')) { // Add fields entity mappers to all fieldable entity types defined. - foreach ($entity_manager->getDefinitions() as $entity_type_id => $entity_type) { + foreach ($entity_type_manager->getDefinitions() as $entity_type_id => $entity_type) { // Make sure entity type has field UI enabled and has a base route. if ($entity_type->get('field_ui_base_route')) { $info[$entity_type_id . '_fields'] = [ @@ -122,7 +122,7 @@ function config_translation_config_translation_info(&$info) { } // Discover configuration entities automatically. - foreach ($entity_manager->getDefinitions() as $entity_type_id => $entity_type) { + foreach ($entity_type_manager->getDefinitions() as $entity_type_id => $entity_type) { // Determine base path for entities automatically if provided via the // configuration entity. if ( diff --git a/core/modules/config_translation/tests/src/Functional/ConfigTranslationOverviewTest.php b/core/modules/config_translation/tests/src/Functional/ConfigTranslationOverviewTest.php index 9ccbb135d2..e4aae1a6bc 100644 --- a/core/modules/config_translation/tests/src/Functional/ConfigTranslationOverviewTest.php +++ b/core/modules/config_translation/tests/src/Functional/ConfigTranslationOverviewTest.php @@ -107,7 +107,7 @@ public function testMapperListPage() { $this->assertIdentical('Translate', $dropbutton->getText()); } - $entity_type = \Drupal::entityManager()->getDefinition($test_entity->getEntityTypeId()); + $entity_type = \Drupal::entityTypeManager()->getDefinition($test_entity->getEntityTypeId()); $this->drupalGet($base_url . '/translate'); $title = $test_entity->label() . ' ' . $entity_type->getLowercaseLabel(); diff --git a/core/modules/contact/tests/src/Kernel/MessageEntityTest.php b/core/modules/contact/tests/src/Kernel/MessageEntityTest.php index e7343b9166..f3025e7b1c 100644 --- a/core/modules/contact/tests/src/Kernel/MessageEntityTest.php +++ b/core/modules/contact/tests/src/Kernel/MessageEntityTest.php @@ -62,8 +62,8 @@ public function testMessageMethods() { $access_user = $this->createUser(['uid' => 3], ['access site-wide contact form']); $admin = $this->createUser(['uid' => 4], ['administer contact forms']); - $this->assertFalse(\Drupal::entityManager()->getAccessControlHandler('contact_message')->createAccess(NULL, $no_access_user)); - $this->assertTrue(\Drupal::entityManager()->getAccessControlHandler('contact_message')->createAccess(NULL, $access_user)); + $this->assertFalse(\Drupal::entityTypeManager()->getAccessControlHandler('contact_message')->createAccess(NULL, $no_access_user)); + $this->assertTrue(\Drupal::entityTypeManager()->getAccessControlHandler('contact_message')->createAccess(NULL, $access_user)); $this->assertTrue($message->access('edit', $admin)); $this->assertFalse($message->access('edit', $access_user)); } diff --git a/core/modules/content_translation/content_translation.admin.inc b/core/modules/content_translation/content_translation.admin.inc index 2fd1e27e7c..8a745d0561 100644 --- a/core/modules/content_translation/content_translation.admin.inc +++ b/core/modules/content_translation/content_translation.admin.inc @@ -95,11 +95,13 @@ function _content_translation_form_language_content_settings_form_alter(array &$ $form['#attached']['library'][] = 'content_translation/drupal.content_translation.admin'; - $entity_manager = Drupal::entityManager(); + $entity_type_manager = \Drupal::entityTypeManager(); + /** @var \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager */ + $entity_field_manager = \Drupal::service('entity_field.manager'); $bundle_info_service = \Drupal::service('entity_type.bundle.info'); foreach ($form['#labels'] as $entity_type_id => $label) { - $entity_type = $entity_manager->getDefinition($entity_type_id); - $storage_definitions = $entity_type instanceof ContentEntityTypeInterface ? $entity_manager->getFieldStorageDefinitions($entity_type_id) : []; + $entity_type = $entity_type_manager->getDefinition($entity_type_id); + $storage_definitions = $entity_type instanceof ContentEntityTypeInterface ? $entity_field_manager->getFieldStorageDefinitions($entity_type_id) : []; $entity_type_translatable = $content_translation_manager->isSupported($entity_type_id); foreach ($bundle_info_service->getBundleInfo($entity_type_id) as $bundle => $bundle_info) { @@ -133,7 +135,7 @@ function _content_translation_form_language_content_settings_form_alter(array &$ ]; } - $fields = $entity_manager->getFieldDefinitions($entity_type_id, $bundle); + $fields = $entity_field_manager->getFieldDefinitions($entity_type_id, $bundle); if ($fields) { foreach ($fields as $field_name => $definition) { if ($definition->isComputed() || (!empty($storage_definitions[$field_name]) && _content_translation_is_field_translatability_configurable($entity_type, $storage_definitions[$field_name]))) { @@ -351,7 +353,7 @@ function content_translation_form_language_content_settings_submit(array $form, // all of its fields will be not translatable. foreach ($settings as $entity_type_id => &$entity_settings) { foreach ($entity_settings as $bundle => &$bundle_settings) { - $fields = \Drupal::entityManager()->getFieldDefinitions($entity_type_id, $bundle); + $fields = \Drupal::service('entity_field.manager')->getFieldDefinitions($entity_type_id, $bundle); if (!empty($bundle_settings['translatable'])) { $bundle_settings['translatable'] = $bundle_settings['translatable'] && $entity_types[$entity_type_id]; } diff --git a/core/modules/content_translation/content_translation.module b/core/modules/content_translation/content_translation.module index 50d7b846d8..91ead7e50a 100644 --- a/core/modules/content_translation/content_translation.module +++ b/core/modules/content_translation/content_translation.module @@ -333,7 +333,7 @@ function content_translation_entity_operation(EntityInterface $entity) { function content_translation_views_data_alter(array &$data) { // Add the content translation entity link definition to Views data for entity // types having translation enabled. - $entity_types = \Drupal::entityManager()->getDefinitions(); + $entity_types = \Drupal::entityTypeManager()->getDefinitions(); /** @var \Drupal\content_translation\ContentTranslationManagerInterface $manager */ $manager = \Drupal::service('content_translation.manager'); foreach ($entity_types as $entity_type_id => $entity_type) { @@ -392,7 +392,7 @@ function content_translation_form_alter(array &$form, FormStateInterface $form_s // be the 'add' or 'edit' form. It also tries a 'default' form in case neither // of the aforementioned forms are defined. if ($entity instanceof ContentEntityInterface && $entity->isTranslatable() && count($entity->getTranslationLanguages()) > 1 && in_array($op, ['edit', 'add', 'default'], TRUE)) { - $controller = \Drupal::entityManager()->getHandler($entity->getEntityTypeId(), 'translation'); + $controller = \Drupal::entityTypeManager()->getHandler($entity->getEntityTypeId(), 'translation'); $controller->entityFormAlter($form, $form_state, $entity); // @todo Move the following lines to the code generating the property form @@ -453,7 +453,7 @@ function content_translation_language_fallback_candidates_entity_view_alter(&$ca function content_translation_entity_extra_field_info() { $extra = []; $bundle_info_service = \Drupal::service('entity_type.bundle.info'); - foreach (\Drupal::entityManager()->getDefinitions() as $entity_type => $info) { + foreach (\Drupal::entityTypeManager()->getDefinitions() as $entity_type => $info) { foreach ($bundle_info_service->getBundleInfo($entity_type) as $bundle => $bundle_info) { if (\Drupal::service('content_translation.manager')->isEnabled($entity_type, $bundle)) { $extra[$entity_type][$bundle]['form']['translation'] = [ diff --git a/core/modules/content_translation/src/Tests/ContentTranslationTestBase.php b/core/modules/content_translation/src/Tests/ContentTranslationTestBase.php index e831649c33..8b8dc5ca4b 100644 --- a/core/modules/content_translation/src/Tests/ContentTranslationTestBase.php +++ b/core/modules/content_translation/src/Tests/ContentTranslationTestBase.php @@ -127,7 +127,7 @@ protected function getTranslatorPermissions() { * Returns the translate permissions for the current entity and bundle. */ protected function getTranslatePermission() { - $entity_type = \Drupal::entityManager()->getDefinition($this->entityTypeId); + $entity_type = \Drupal::entityTypeManager()->getDefinition($this->entityTypeId); if ($permission_granularity = $entity_type->getPermissionGranularity()) { return $permission_granularity == 'bundle' ? "translate {$this->bundle} {$this->entityTypeId}" : "translate {$this->entityTypeId}"; } @@ -175,7 +175,7 @@ protected function enableTranslation() { // picked up. \Drupal::service('content_translation.manager')->setEnabled($this->entityTypeId, $this->bundle, TRUE); - \Drupal::entityManager()->clearCachedDefinitions(); + \Drupal::entityTypeManager()->clearCachedDefinitions(); \Drupal::service('router.builder')->rebuild(); } @@ -223,7 +223,7 @@ protected function setupTestFields() { protected function createEntity($values, $langcode, $bundle_name = NULL) { $entity_values = $values; $entity_values['langcode'] = $langcode; - $entity_type = \Drupal::entityManager()->getDefinition($this->entityTypeId); + $entity_type = \Drupal::entityTypeManager()->getDefinition($this->entityTypeId); if ($bundle_key = $entity_type->getKey('bundle')) { $entity_values[$bundle_key] = $bundle_name ?: $this->bundle; } diff --git a/core/modules/content_translation/tests/src/Functional/ContentTranslationMetadataFieldsTest.php b/core/modules/content_translation/tests/src/Functional/ContentTranslationMetadataFieldsTest.php index bbad25ca9c..2624e20893 100644 --- a/core/modules/content_translation/tests/src/Functional/ContentTranslationMetadataFieldsTest.php +++ b/core/modules/content_translation/tests/src/Functional/ContentTranslationMetadataFieldsTest.php @@ -42,8 +42,11 @@ class ContentTranslationMetadataFieldsTest extends ContentTranslationTestBase { */ public function testSkipUntranslatable() { $this->drupalLogin($this->translator); - $entity_manager = \Drupal::entityManager(); - $fields = $entity_manager->getFieldDefinitions($this->entityTypeId, $this->bundle); + $entity_type_manager = \Drupal::entityTypeManager(); + /** @var \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager */ + $entity_field_manager = \Drupal::service('entity_field.manager'); + + $fields = $entity_field_manager->getFieldDefinitions($this->entityTypeId, $this->bundle); // Turn off translatability for the metadata fields on the current bundle. $metadata_fields = ['created', 'changed', 'uid', 'status']; @@ -57,7 +60,7 @@ public function testSkipUntranslatable() { // Create a new test entity with original values in the default language. $default_langcode = $this->langcodes[0]; $entity_id = $this->createEntity(['title' => $this->randomString()], $default_langcode); - $storage = $entity_manager->getStorage($this->entityTypeId); + $storage = $entity_type_manager->getStorage($this->entityTypeId); $storage->resetCache(); $entity = $storage->load($entity_id); @@ -99,8 +102,10 @@ public function testSkipUntranslatable() { */ public function testSetTranslatable() { $this->drupalLogin($this->translator); - $entity_manager = \Drupal::entityManager(); - $fields = $entity_manager->getFieldDefinitions($this->entityTypeId, $this->bundle); + $entity_type_manager = \Drupal::entityTypeManager(); + /** @var \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager */ + $entity_field_manager = \Drupal::service('entity_field.manager'); + $fields = $entity_field_manager->getFieldDefinitions($this->entityTypeId, $this->bundle); // Turn off translatability for the metadata fields on the current bundle. $metadata_fields = ['created', 'changed', 'uid', 'status']; @@ -114,7 +119,7 @@ public function testSetTranslatable() { // Create a new test entity with original values in the default language. $default_langcode = $this->langcodes[0]; $entity_id = $this->createEntity(['title' => $this->randomString(), 'status' => FALSE], $default_langcode); - $storage = $entity_manager->getStorage($this->entityTypeId); + $storage = $entity_type_manager->getStorage($this->entityTypeId); $storage->resetCache(); $entity = $storage->load($entity_id); diff --git a/core/modules/content_translation/tests/src/Functional/ContentTranslationOperationsTest.php b/core/modules/content_translation/tests/src/Functional/ContentTranslationOperationsTest.php index fc0f788a6a..8486ac529f 100644 --- a/core/modules/content_translation/tests/src/Functional/ContentTranslationOperationsTest.php +++ b/core/modules/content_translation/tests/src/Functional/ContentTranslationOperationsTest.php @@ -126,7 +126,7 @@ public function testOperationTranslateLink() { * @see content_translation_translate_access() */ public function testContentTranslationOverviewAccess() { - $access_control_handler = \Drupal::entityManager()->getAccessControlHandler('node'); + $access_control_handler = \Drupal::entityTypeManager()->getAccessControlHandler('node'); $user = $this->createUser(['create content translations', 'access content']); $this->drupalLogin($user); diff --git a/core/modules/content_translation/tests/src/Functional/ContentTranslationSettingsTest.php b/core/modules/content_translation/tests/src/Functional/ContentTranslationSettingsTest.php index 1469b31242..13a7f2d486 100644 --- a/core/modules/content_translation/tests/src/Functional/ContentTranslationSettingsTest.php +++ b/core/modules/content_translation/tests/src/Functional/ContentTranslationSettingsTest.php @@ -163,7 +163,7 @@ public function testSettingsUI() { $edit = ['settings[node][article][fields][body]' => $translatable]; $this->assertSettings('node', 'article', TRUE, $edit); $field = FieldConfig::loadByName('node', 'article', 'body'); - $definitions = \Drupal::entityManager()->getFieldDefinitions('node', 'article'); + $definitions = \Drupal::service('entity_field.manager')->getFieldDefinitions('node', 'article'); $this->assertEqual($definitions['body']->isTranslatable(), $translatable, 'Field translatability correctly switched.'); $this->assertEqual($field->isTranslatable(), $definitions['body']->isTranslatable(), 'Configurable field translatability correctly switched.'); @@ -171,9 +171,9 @@ public function testSettingsUI() { $translatable = !$translatable; $edit = ['translatable' => $translatable]; $this->drupalPostForm('admin/structure/types/manage/article/fields/node.article.body', $edit, t('Save settings')); - \Drupal::entityManager()->clearCachedFieldDefinitions(); + \Drupal::service('entity_field.manager')->clearCachedFieldDefinitions(); $field = FieldConfig::loadByName('node', 'article', 'body'); - $definitions = \Drupal::entityManager()->getFieldDefinitions('node', 'article'); + $definitions = \Drupal::service('entity_field.manager')->getFieldDefinitions('node', 'article'); $this->assertEqual($definitions['body']->isTranslatable(), $translatable, 'Field translatability correctly switched.'); $this->assertEqual($field->isTranslatable(), $definitions['body']->isTranslatable(), 'Configurable field translatability correctly switched.'); } diff --git a/core/modules/content_translation/tests/src/Functional/ContentTranslationTestBase.php b/core/modules/content_translation/tests/src/Functional/ContentTranslationTestBase.php index de6cef999c..7008112264 100644 --- a/core/modules/content_translation/tests/src/Functional/ContentTranslationTestBase.php +++ b/core/modules/content_translation/tests/src/Functional/ContentTranslationTestBase.php @@ -121,7 +121,7 @@ protected function getTranslatorPermissions() { * Returns the translate permissions for the current entity and bundle. */ protected function getTranslatePermission() { - $entity_type = \Drupal::entityManager()->getDefinition($this->entityTypeId); + $entity_type = \Drupal::entityTypeManager()->getDefinition($this->entityTypeId); if ($permission_granularity = $entity_type->getPermissionGranularity()) { return $permission_granularity == 'bundle' ? "translate {$this->bundle} {$this->entityTypeId}" : "translate {$this->entityTypeId}"; } @@ -216,7 +216,7 @@ protected function setupTestFields() { protected function createEntity($values, $langcode, $bundle_name = NULL) { $entity_values = $values; $entity_values['langcode'] = $langcode; - $entity_type = \Drupal::entityManager()->getDefinition($this->entityTypeId); + $entity_type = \Drupal::entityTypeManager()->getDefinition($this->entityTypeId); if ($bundle_key = $entity_type->getKey('bundle')) { $entity_values[$bundle_key] = $bundle_name ?: $this->bundle; } diff --git a/core/modules/datetime/tests/src/Functional/DateTimeFieldTest.php b/core/modules/datetime/tests/src/Functional/DateTimeFieldTest.php index 792e75bef0..67eeec3955 100644 --- a/core/modules/datetime/tests/src/Functional/DateTimeFieldTest.php +++ b/core/modules/datetime/tests/src/Functional/DateTimeFieldTest.php @@ -391,7 +391,7 @@ public function testDatelistWidget() { ], ]) ->save(); - \Drupal::entityManager()->clearCachedFieldDefinitions(); + \Drupal::service('entity_field.manager')->clearCachedFieldDefinitions(); // Display creation form. $this->drupalGet('entity_test/add'); @@ -427,7 +427,7 @@ public function testDatelistWidget() { ], ]) ->save(); - \Drupal::entityManager()->clearCachedFieldDefinitions(); + \Drupal::service('entity_field.manager')->clearCachedFieldDefinitions(); // Go to the form display page to assert that increment option does appear on Date Time $fieldEditUrl = 'entity_test/structure/entity_test/form-display'; @@ -493,7 +493,7 @@ public function testDatelistWidget() { ], ]) ->save(); - \Drupal::entityManager()->clearCachedFieldDefinitions(); + \Drupal::service('entity_field.manager')->clearCachedFieldDefinitions(); // Display creation form. $this->drupalGet('entity_test/add'); @@ -533,7 +533,7 @@ public function testDatelistWidget() { ], ]) ->save(); - \Drupal::entityManager()->clearCachedFieldDefinitions(); + \Drupal::service('entity_field.manager')->clearCachedFieldDefinitions(); // Test the widget for validation notifications. foreach ($this->datelistDataProvider($field_label) as $data) { @@ -691,7 +691,7 @@ public function testDefaultValue() { ], 'Default value has been stored successfully'); // Clear field cache in order to avoid stale cache values. - \Drupal::entityManager()->clearCachedFieldDefinitions(); + \Drupal::service('entity_field.manager')->clearCachedFieldDefinitions(); // Create a new node to check that datetime field default value is today. $new_node = Node::create(['type' => 'date_content']); @@ -729,7 +729,7 @@ public function testDefaultValue() { ], 'Default value has been stored successfully'); // Clear field cache in order to avoid stale cache values. - \Drupal::entityManager()->clearCachedFieldDefinitions(); + \Drupal::service('entity_field.manager')->clearCachedFieldDefinitions(); // Create a new node to check that datetime field default value is +90 // days. @@ -755,7 +755,7 @@ public function testDefaultValue() { $this->assertTrue(empty($config_entity['default_value']), 'Empty default value has been stored successfully'); // Clear field cache in order to avoid stale cache values. - \Drupal::entityManager()->clearCachedFieldDefinitions(); + \Drupal::service('entity_field.manager')->clearCachedFieldDefinitions(); // Create a new node to check that datetime field default value is not // set. diff --git a/core/modules/editor/editor.module b/core/modules/editor/editor.module index aa8d988f58..7eb910ce5e 100644 --- a/core/modules/editor/editor.module +++ b/core/modules/editor/editor.module @@ -622,7 +622,7 @@ function editor_filter_format_presave(FilterFormatInterface $format) { } /** @var \Drupal\filter\FilterFormatInterface $original */ - $original = \Drupal::entityManager() + $original = \Drupal::entityTypeManager() ->getStorage('filter_format') ->loadUnchanged($format->getOriginalId()); diff --git a/core/modules/editor/src/Entity/Editor.php b/core/modules/editor/src/Entity/Editor.php index 07c9d24aa8..5d60313a42 100644 --- a/core/modules/editor/src/Entity/Editor.php +++ b/core/modules/editor/src/Entity/Editor.php @@ -127,7 +127,7 @@ public function hasAssociatedFilterFormat() { */ public function getFilterFormat() { if (!$this->filterFormat) { - $this->filterFormat = \Drupal::entityManager()->getStorage('filter_format')->load($this->format); + $this->filterFormat = \Drupal::entityTypeManager()->getStorage('filter_format')->load($this->format); } return $this->filterFormat; } diff --git a/core/modules/editor/tests/src/Kernel/EditorImageDialogTest.php b/core/modules/editor/tests/src/Kernel/EditorImageDialogTest.php index 6500d1adef..0d0ecaaa60 100644 --- a/core/modules/editor/tests/src/Kernel/EditorImageDialogTest.php +++ b/core/modules/editor/tests/src/Kernel/EditorImageDialogTest.php @@ -108,7 +108,7 @@ public function testEditorImageDialog() { ->addBuildInfo('args', [$this->editor]); $form_builder = $this->container->get('form_builder'); - $form_object = new EditorImageDialog(\Drupal::entityManager()->getStorage('file')); + $form_object = new EditorImageDialog(\Drupal::entityTypeManager()->getStorage('file')); $form_id = $form_builder->getFormId($form_object, $form_state); $form = $form_builder->retrieveForm($form_id, $form_state); $form_builder->prepareForm($form_id, $form, $form_state); diff --git a/core/modules/field/field.module b/core/modules/field/field.module index 4d4d4822fa..27173af080 100644 --- a/core/modules/field/field.module +++ b/core/modules/field/field.module @@ -171,7 +171,7 @@ function field_cron() { * Implements hook_entity_field_storage_info(). */ function field_entity_field_storage_info(EntityTypeInterface $entity_type) { - if (\Drupal::entityManager()->getStorage($entity_type->id()) instanceof DynamicallyFieldableEntityStorageInterface) { + if (\Drupal::entityTypeManager()->getStorage($entity_type->id()) instanceof DynamicallyFieldableEntityStorageInterface) { // Query by filtering on the ID as this is more efficient than filtering // on the entity_type property directly. $ids = \Drupal::entityQuery('field_storage_config') @@ -192,7 +192,7 @@ function field_entity_field_storage_info(EntityTypeInterface $entity_type) { * Implements hook_entity_bundle_field_info(). */ function field_entity_bundle_field_info(EntityTypeInterface $entity_type, $bundle, array $base_field_definitions) { - if (\Drupal::entityManager()->getStorage($entity_type->id()) instanceof DynamicallyFieldableEntityStorageInterface) { + if (\Drupal::entityTypeManager()->getStorage($entity_type->id()) instanceof DynamicallyFieldableEntityStorageInterface) { // Query by filtering on the ID as this is more efficient than filtering // on the entity_type property directly. $ids = \Drupal::entityQuery('field_config') @@ -213,7 +213,7 @@ function field_entity_bundle_field_info(EntityTypeInterface $entity_type, $bundl * Implements hook_entity_bundle_delete(). */ function field_entity_bundle_delete($entity_type_id, $bundle) { - $storage = \Drupal::entityManager()->getStorage('field_config'); + $storage = \Drupal::entityTypeManager()->getStorage('field_config'); // Get the fields on the bundle. $fields = $storage->loadByProperties(['entity_type' => $entity_type_id, 'bundle' => $bundle]); // This deletes the data for the field as well as the field themselves. This @@ -232,7 +232,7 @@ function field_entity_bundle_delete($entity_type_id, $bundle) { // config entity type so they are not part of the config dependencies. // Gather a list of all entity reference fields. - $map = \Drupal::entityManager()->getFieldMapByFieldType('entity_reference'); + $map = \Drupal::service('entity_field.manager')->getFieldMapByFieldType('entity_reference'); $ids = []; foreach ($map as $type => $info) { foreach ($info as $name => $data) { @@ -271,7 +271,7 @@ function field_entity_bundle_delete($entity_type_id, $bundle) { */ function _field_create_entity_from_ids($ids) { $id_properties = []; - $entity_type = \Drupal::entityManager()->getDefinition($ids->entity_type); + $entity_type = \Drupal::entityTypeManager()->getDefinition($ids->entity_type); if ($id_key = $entity_type->getKey('id')) { $id_properties[$id_key] = $ids->entity_id; } diff --git a/core/modules/field/field.purge.inc b/core/modules/field/field.purge.inc index a2b2b92975..11b2ac11a6 100644 --- a/core/modules/field/field.purge.inc +++ b/core/modules/field/field.purge.inc @@ -77,7 +77,7 @@ function field_purge_batch($batch_size, $field_storage_unique_id = NULL) { $fields = $deleted_fields_repository->getFieldDefinitions($field_storage_unique_id); - $info = \Drupal::entityManager()->getDefinitions(); + $info = \Drupal::entityTypeManager()->getDefinitions(); foreach ($fields as $field) { $entity_type = $field->getTargetEntityTypeId(); @@ -89,7 +89,7 @@ function field_purge_batch($batch_size, $field_storage_unique_id = NULL) { continue; } - $count_purged = \Drupal::entityManager()->getStorage($entity_type)->purgeFieldData($field, $batch_size); + $count_purged = \Drupal::entityTypeManager()->getStorage($entity_type)->purgeFieldData($field, $batch_size); if ($count_purged < $batch_size || $count_purged == 0) { // No field data remains for the field, so we can remove it. field_purge_field($field); @@ -163,7 +163,7 @@ function field_purge_field_storage(FieldStorageDefinitionInterface $field_storag $deleted_fields_repository->removeFieldStorageDefinition($field_storage); // Notify the storage layer. - \Drupal::entityManager()->getStorage($field_storage->getTargetEntityTypeId())->finalizePurge($field_storage); + \Drupal::entityTypeManager()->getStorage($field_storage->getTargetEntityTypeId())->finalizePurge($field_storage); // Invoke external hooks after the cache is cleared for API consistency. \Drupal::moduleHandler()->invokeAll('field_purge_field_storage', [$field_storage]); diff --git a/core/modules/field/src/ConfigImporterFieldPurger.php b/core/modules/field/src/ConfigImporterFieldPurger.php index c38fc4b136..22bf7c2058 100644 --- a/core/modules/field/src/ConfigImporterFieldPurger.php +++ b/core/modules/field/src/ConfigImporterFieldPurger.php @@ -71,7 +71,7 @@ protected static function initializeSandbox(array &$context, ConfigImporter $con $context['sandbox']['field']['steps_to_delete'] = 0; $fields = static::getFieldStoragesToPurge($context['sandbox']['field']['extensions'], $config_importer->getUnprocessedConfiguration('delete')); foreach ($fields as $field) { - $row_count = \Drupal::entityManager()->getStorage($field->getTargetEntityTypeId()) + $row_count = \Drupal::entityTypeManager()->getStorage($field->getTargetEntityTypeId()) ->countFieldData($field); if ($row_count > 0) { // The number of steps to delete each field is determined by the @@ -117,7 +117,7 @@ public static function getFieldStoragesToPurge(array $extensions, array $deletes // where the module that provides the field type is also being uninstalled. $field_storage_ids = []; foreach ($deletes as $config_name) { - $field_storage_config_prefix = \Drupal::entityManager()->getDefinition('field_storage_config')->getConfigPrefix(); + $field_storage_config_prefix = \Drupal::entityTypeManager()->getDefinition('field_storage_config')->getConfigPrefix(); if (strpos($config_name, $field_storage_config_prefix . '.') === 0) { $field_storage_ids[] = ConfigEntityStorage::getIDFromConfigName($config_name, $field_storage_config_prefix); } diff --git a/core/modules/field/src/Entity/FieldConfig.php b/core/modules/field/src/Entity/FieldConfig.php index 8218db1ed3..380c4b37f9 100644 --- a/core/modules/field/src/Entity/FieldConfig.php +++ b/core/modules/field/src/Entity/FieldConfig.php @@ -149,7 +149,6 @@ public function postCreate(EntityStorageInterface $storage) { * In case of failures at the configuration storage level. */ public function preSave(EntityStorageInterface $storage) { - $entity_manager = \Drupal::entityManager(); $field_type_manager = \Drupal::service('plugin.manager.field.field_type'); $storage_definition = $this->getFieldStorageDefinition(); @@ -250,7 +249,7 @@ public static function postDelete(EntityStorageInterface $storage, array $fields } } if ($storages_to_delete) { - \Drupal::entityManager()->getStorage('field_storage_config')->delete($storages_to_delete); + \Drupal::entityTypeManager()->getStorage('field_storage_config')->delete($storages_to_delete); } } @@ -276,7 +275,7 @@ protected function linkTemplates() { */ protected function urlRouteParameters($rel) { $parameters = parent::urlRouteParameters($rel); - $entity_type = \Drupal::entityManager()->getDefinition($this->entity_type); + $entity_type = \Drupal::entityTypeManager()->getDefinition($this->entity_type); $bundle_parameter_key = $entity_type->getBundleEntityType() ?: 'bundle'; $parameters[$bundle_parameter_key] = $this->bundle; return $parameters; @@ -374,7 +373,7 @@ public function getUniqueIdentifier() { * name, otherwise NULL. */ public static function loadByName($entity_type_id, $bundle, $field_name) { - return \Drupal::entityManager()->getStorage('field_config')->load($entity_type_id . '.' . $bundle . '.' . $field_name); + return \Drupal::entityTypeManager()->getStorage('field_config')->load($entity_type_id . '.' . $bundle . '.' . $field_name); } } diff --git a/core/modules/field/src/Entity/FieldStorageConfig.php b/core/modules/field/src/Entity/FieldStorageConfig.php index 4387c6ce1f..65f7c7356e 100644 --- a/core/modules/field/src/Entity/FieldStorageConfig.php +++ b/core/modules/field/src/Entity/FieldStorageConfig.php @@ -310,7 +310,7 @@ public function preSave(EntityStorageInterface $storage) { * If the field definition is invalid. */ protected function preSaveNew(EntityStorageInterface $storage) { - $entity_manager = \Drupal::entityManager(); + $entity_field_manager = \Drupal::service('entity_field.manager'); $field_type_manager = \Drupal::service('plugin.manager.field.field_type'); // Assign the ID. @@ -324,7 +324,7 @@ protected function preSaveNew(EntityStorageInterface $storage) { } // Disallow reserved field names. - $disallowed_field_names = array_keys($entity_manager->getBaseFieldDefinitions($this->getTargetEntityTypeId())); + $disallowed_field_names = array_keys($entity_field_manager->getBaseFieldDefinitions($this->getTargetEntityTypeId())); if (in_array($this->getName(), $disallowed_field_names)) { throw new FieldException("Attempt to create field storage {$this->getName()} which is reserved by entity type {$this->getTargetEntityTypeId()}."); } @@ -353,7 +353,7 @@ public function calculateDependencies() { $this->addDependencies($definition['class']::calculateStorageDependencies($this)); // Ensure the field is dependent on the provider of the entity type. - $entity_type = \Drupal::entityManager()->getDefinition($this->entity_type); + $entity_type = \Drupal::entityTypeManager()->getDefinition($this->entity_type); $this->addDependency('module', $entity_type->getProvider()); return $this; } @@ -391,10 +391,10 @@ protected function preSaveUpdated(EntityStorageInterface $storage) { public function postSave(EntityStorageInterface $storage, $update = TRUE) { if ($update) { // Invalidate the render cache for all affected entities. - $entity_manager = \Drupal::entityManager(); + $entity_type_manager = \Drupal::entityTypeManager(); $entity_type = $this->getTargetEntityTypeId(); - if ($entity_manager->hasHandler($entity_type, 'view_builder')) { - $entity_manager->getViewBuilder($entity_type)->resetCache(); + if ($entity_type_manager->hasHandler($entity_type, 'view_builder')) { + $entity_type_manager->getViewBuilder($entity_type)->resetCache(); } } } @@ -496,7 +496,7 @@ public function getColumns() { */ public function getBundles() { if (!$this->isDeleted()) { - $map = \Drupal::entityManager()->getFieldMap(); + $map = \Drupal::service('entity_field.manager')->getFieldMap(); if (isset($map[$this->getTargetEntityTypeId()][$this->getName()]['bundles'])) { return $map[$this->getTargetEntityTypeId()][$this->getName()]['bundles']; } @@ -709,7 +709,7 @@ public function isQueryable() { * TRUE if the field has data for any entity; FALSE otherwise. */ public function hasData() { - return \Drupal::entityManager()->getStorage($this->entity_type)->countFieldData($this, TRUE); + return \Drupal::entityTypeManager()->getStorage($this->entity_type)->countFieldData($this, TRUE); } /** @@ -808,7 +808,7 @@ protected function getFieldItemClass() { * otherwise NULL. */ public static function loadByName($entity_type_id, $field_name) { - return \Drupal::entityManager()->getStorage('field_storage_config')->load($entity_type_id . '.' . $field_name); + return \Drupal::entityTypeManager()->getStorage('field_storage_config')->load($entity_type_id . '.' . $field_name); } /** diff --git a/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceFieldDefaultValueTest.php b/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceFieldDefaultValueTest.php index f5d37c2d31..89d30eb27c 100644 --- a/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceFieldDefaultValueTest.php +++ b/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceFieldDefaultValueTest.php @@ -90,7 +90,7 @@ public function testEntityReferenceDefaultValue() { $this->assertEqual([$referenced_node->getConfigDependencyName()], $config_entity['dependencies']['content']); // Clear field definitions cache in order to avoid stale cache values. - \Drupal::entityManager()->clearCachedFieldDefinitions(); + \Drupal::service('entity_field.manager')->clearCachedFieldDefinitions(); // Create a new node to check that UUID has been converted to numeric ID. $new_node = Node::create(['type' => 'reference_content']); diff --git a/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceIntegrationTest.php b/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceIntegrationTest.php index 15326b9952..268ede3255 100644 --- a/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceIntegrationTest.php +++ b/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceIntegrationTest.php @@ -154,7 +154,7 @@ public function testSupportedEntityTypesAndWidgets() { // default value deleted. $referenced_entities[0]->delete(); // Reload the field since deleting the default value can change the field. - \Drupal::entityManager()->getStorage($field->getEntityTypeId())->resetCache([$field->id()]); + \Drupal::entityTypeManager()->getStorage($field->getEntityTypeId())->resetCache([$field->id()]); $field = FieldConfig::loadByName($this->entityType, $this->bundle, $this->fieldName); $this->assertConfigEntityImport($field); diff --git a/core/modules/field/tests/src/FunctionalJavascript/EntityReference/EntityReferenceAdminTest.php b/core/modules/field/tests/src/FunctionalJavascript/EntityReference/EntityReferenceAdminTest.php index 89a8ce1e45..ac9dc34bae 100644 --- a/core/modules/field/tests/src/FunctionalJavascript/EntityReference/EntityReferenceAdminTest.php +++ b/core/modules/field/tests/src/FunctionalJavascript/EntityReference/EntityReferenceAdminTest.php @@ -83,7 +83,7 @@ public function testFieldAdminHandler() { $this->assertFieldByName('settings[target_type]', 'node'); // Check that all entity types can be referenced. - $this->assertFieldSelectOptions('settings[target_type]', array_keys(\Drupal::entityManager()->getDefinitions())); + $this->assertFieldSelectOptions('settings[target_type]', array_keys(\Drupal::entityTypeManager()->getDefinitions())); // Second step: 'Field settings' form. $this->drupalPostForm(NULL, [], t('Save field settings')); diff --git a/core/modules/field/tests/src/Kernel/BulkDeleteTest.php b/core/modules/field/tests/src/Kernel/BulkDeleteTest.php index 2abb61e8e5..b8560ccd0e 100644 --- a/core/modules/field/tests/src/Kernel/BulkDeleteTest.php +++ b/core/modules/field/tests/src/Kernel/BulkDeleteTest.php @@ -278,7 +278,7 @@ public function testPurgeWithDeletedAndActiveField() { } // Check that the two field storages have different tables. - $storage = \Drupal::entityManager()->getStorage($this->entityTypeId); + $storage = \Drupal::entityTypeManager()->getStorage($this->entityTypeId); /** @var \Drupal\Core\Entity\Sql\DefaultTableMapping $table_mapping */ $table_mapping = $storage->getTableMapping(); $deleted_table_name = $table_mapping->getDedicatedDataTableName($deleted_field_storage, TRUE); diff --git a/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceFormatterTest.php b/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceFormatterTest.php index e7558803ed..0db7ff3860 100644 --- a/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceFormatterTest.php +++ b/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceFormatterTest.php @@ -209,7 +209,7 @@ public function testEntityFormatter() { '; $renderer->renderRoot($build[0]); $this->assertEqual($build[0]['#markup'], 'default | ' . $this->referencedEntity->label() . $expected_rendered_name_field_1 . $expected_rendered_body_field_1, sprintf('The markup returned by the %s formatter is correct for an item with a saved entity.', $formatter)); - $expected_cache_tags = Cache::mergeTags(\Drupal::entityManager()->getViewBuilder($this->entityType)->getCacheTags(), $this->referencedEntity->getCacheTags()); + $expected_cache_tags = Cache::mergeTags(\Drupal::entityTypeManager()->getViewBuilder($this->entityType)->getCacheTags(), $this->referencedEntity->getCacheTags()); $expected_cache_tags = Cache::mergeTags($expected_cache_tags, FilterFormat::load('full_html')->getCacheTags()); $this->assertEqual($build[0]['#cache']['tags'], $expected_cache_tags, format_string('The @formatter formatter has the expected cache tags.', ['@formatter' => $formatter])); diff --git a/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceItemTest.php b/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceItemTest.php index 5c8c667f5e..f8f57dfe8b 100644 --- a/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceItemTest.php +++ b/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceItemTest.php @@ -242,7 +242,7 @@ public function testContentEntityReferenceItemWithStringId() { $entity = EntityTest::create(); $entity->field_test_entity_test_string_id->target_id = $this->entityStringId->id(); $entity->save(); - $storage = \Drupal::entityManager()->getStorage('entity_test'); + $storage = \Drupal::entityTypeManager()->getStorage('entity_test'); $storage->resetCache(); $this->assertEqual($this->entityStringId->id(), $storage->load($entity->id())->field_test_entity_test_string_id->target_id); // Verify that the label for the target ID property definition is correct. diff --git a/core/modules/field/tests/src/Kernel/FieldAttachOtherTest.php b/core/modules/field/tests/src/Kernel/FieldAttachOtherTest.php index 05fdfae386..b45741bc56 100644 --- a/core/modules/field/tests/src/Kernel/FieldAttachOtherTest.php +++ b/core/modules/field/tests/src/Kernel/FieldAttachOtherTest.php @@ -333,7 +333,7 @@ public function testEntityFormDisplayExtractFormValues() { $values_2[1]['value'] = 0; // Pretend the form has been built. - $form_state->setFormObject(\Drupal::entityManager()->getFormObject($entity_type, 'default')); + $form_state->setFormObject(\Drupal::entityTypeManager()->getFormObject($entity_type, 'default')); \Drupal::formBuilder()->prepareForm('field_test_entity_form', $form, $form_state); \Drupal::formBuilder()->processForm('field_test_entity_form', $form, $form_state); $form_state->setValue($this->fieldTestData->field_name, $values); diff --git a/core/modules/field/tests/src/Kernel/FieldAttachStorageTest.php b/core/modules/field/tests/src/Kernel/FieldAttachStorageTest.php index 04d997d77d..7aa6359c7f 100644 --- a/core/modules/field/tests/src/Kernel/FieldAttachStorageTest.php +++ b/core/modules/field/tests/src/Kernel/FieldAttachStorageTest.php @@ -127,7 +127,7 @@ public function testFieldAttachLoadMultiple() { } // Check that a single load correctly loads field values for both entities. - $controller = \Drupal::entityManager()->getStorage($entity->getEntityTypeId()); + $controller = \Drupal::entityTypeManager()->getStorage($entity->getEntityTypeId()); $controller->resetCache(); $entities = $controller->loadMultiple(); foreach ($entities as $index => $entity) { diff --git a/core/modules/field/tests/src/Kernel/FieldCrudTest.php b/core/modules/field/tests/src/Kernel/FieldCrudTest.php index 6068d316fb..73f2d109d7 100644 --- a/core/modules/field/tests/src/Kernel/FieldCrudTest.php +++ b/core/modules/field/tests/src/Kernel/FieldCrudTest.php @@ -216,7 +216,7 @@ public function testCreateFieldCustomStorage() { ]); $field->save(); - \Drupal::entityManager()->clearCachedFieldDefinitions(); + \Drupal::service('entity_field.manager')->clearCachedFieldDefinitions(); // Check that no table has been created for the field. $this->assertFalse(\Drupal::database()->schema()->tableExists('entity_test__' . $field_storage->getName())); diff --git a/core/modules/field/tests/src/Kernel/FieldDataCountTest.php b/core/modules/field/tests/src/Kernel/FieldDataCountTest.php index 82ef6d09f0..3224763293 100644 --- a/core/modules/field/tests/src/Kernel/FieldDataCountTest.php +++ b/core/modules/field/tests/src/Kernel/FieldDataCountTest.php @@ -39,9 +39,9 @@ class FieldDataCountTest extends FieldKernelTestBase { protected function setUp() { parent::setUp(); $this->installEntitySchema('entity_test_rev'); - $this->storage = \Drupal::entityManager()->getStorage('entity_test'); - $this->storageRev = \Drupal::entityManager()->getStorage('entity_test_rev'); - $this->storageUser = \Drupal::entityManager()->getStorage('user'); + $this->storage = \Drupal::entityTypeManager()->getStorage('entity_test'); + $this->storageRev = \Drupal::entityTypeManager()->getStorage('entity_test_rev'); + $this->storageUser = \Drupal::entityTypeManager()->getStorage('user'); } /** @@ -83,7 +83,7 @@ public function testEntityCountAndHasData() { $entity->save(); } - $storage = \Drupal::entityManager()->getStorage('entity_test'); + $storage = \Drupal::entityTypeManager()->getStorage('entity_test'); if ($storage instanceof SqlContentEntityStorage) { // Count the actual number of rows in the field table. $table_mapping = $storage->getTableMapping(); diff --git a/core/modules/field/tests/src/Kernel/FieldImportDeleteTest.php b/core/modules/field/tests/src/Kernel/FieldImportDeleteTest.php index b4180a0170..cfede1e386 100644 --- a/core/modules/field/tests/src/Kernel/FieldImportDeleteTest.php +++ b/core/modules/field/tests/src/Kernel/FieldImportDeleteTest.php @@ -82,19 +82,19 @@ public function testImportDelete() { $this->configImporter()->import(); // Check that the field storages and fields are gone. - \Drupal::entityManager()->getStorage('field_storage_config')->resetCache([$field_storage_id]); + \Drupal::entityTypeManager()->getStorage('field_storage_config')->resetCache([$field_storage_id]); $field_storage = FieldStorageConfig::load($field_storage_id); $this->assertFalse($field_storage, 'The field storage was deleted.'); - \Drupal::entityManager()->getStorage('field_storage_config')->resetCache([$field_storage_id_2]); + \Drupal::entityTypeManager()->getStorage('field_storage_config')->resetCache([$field_storage_id_2]); $field_storage_2 = FieldStorageConfig::load($field_storage_id_2); $this->assertFalse($field_storage_2, 'The second field storage was deleted.'); - \Drupal::entityManager()->getStorage('field_config')->resetCache([$field_id]); + \Drupal::entityTypeManager()->getStorage('field_config')->resetCache([$field_id]); $field = FieldConfig::load($field_id); $this->assertFalse($field, 'The field was deleted.'); - \Drupal::entityManager()->getStorage('field_config')->resetCache([$field_id_2a]); + \Drupal::entityTypeManager()->getStorage('field_config')->resetCache([$field_id_2a]); $field_2a = FieldConfig::load($field_id_2a); $this->assertFalse($field_2a, 'The second field on test bundle was deleted.'); - \Drupal::entityManager()->getStorage('field_config')->resetCache([$field_id_2b]); + \Drupal::entityTypeManager()->getStorage('field_config')->resetCache([$field_id_2b]); $field_2b = FieldConfig::load($field_id_2b); $this->assertFalse($field_2b, 'The second field on test bundle 2 was deleted.'); diff --git a/core/modules/field/tests/src/Kernel/FieldKernelTestBase.php b/core/modules/field/tests/src/Kernel/FieldKernelTestBase.php index 98d7419f5f..cf7c7e44df 100644 --- a/core/modules/field/tests/src/Kernel/FieldKernelTestBase.php +++ b/core/modules/field/tests/src/Kernel/FieldKernelTestBase.php @@ -52,7 +52,7 @@ protected function setUp() { $this->installConfig(['field', 'system']); // Create user 1. - $storage = \Drupal::entityManager()->getStorage('user'); + $storage = \Drupal::entityTypeManager()->getStorage('user'); $storage ->create([ 'uid' => 1, diff --git a/core/modules/field/tests/src/Kernel/Timestamp/TimestampFormatterTest.php b/core/modules/field/tests/src/Kernel/Timestamp/TimestampFormatterTest.php index 9bb1f73acc..a90e77b21d 100644 --- a/core/modules/field/tests/src/Kernel/Timestamp/TimestampFormatterTest.php +++ b/core/modules/field/tests/src/Kernel/Timestamp/TimestampFormatterTest.php @@ -102,7 +102,7 @@ public function testTimestampFormatter() { $data = []; // Test standard formats. - $date_formats = array_keys(\Drupal::entityManager()->getStorage('date_format')->loadMultiple()); + $date_formats = array_keys(\Drupal::entityTypeManager()->getStorage('date_format')->loadMultiple()); foreach ($date_formats as $date_format) { $data[] = ['date_format' => $date_format, 'custom_date_format' => '', 'timezone' => '']; diff --git a/core/modules/field/tests/src/Kernel/TranslationTest.php b/core/modules/field/tests/src/Kernel/TranslationTest.php index 1a101b79ee..f427ee2d98 100644 --- a/core/modules/field/tests/src/Kernel/TranslationTest.php +++ b/core/modules/field/tests/src/Kernel/TranslationTest.php @@ -109,7 +109,7 @@ protected function setUp() { public function testTranslatableFieldSaveLoad() { // Enable field translations for nodes. field_test_entity_info_translatable('node', TRUE); - $entity_type = \Drupal::entityManager()->getDefinition('node'); + $entity_type = \Drupal::entityTypeManager()->getDefinition('node'); $this->assertTrue($entity_type->isTranslatable(), 'Nodes are translatable.'); // Prepare the field translations. @@ -202,7 +202,7 @@ public function testTranslatableFieldSaveLoad() { * @see https://www.drupal.org/node/2404739 */ public function testFieldAccess() { - $access_control_handler = \Drupal::entityManager()->getAccessControlHandler($this->entityType); + $access_control_handler = \Drupal::entityTypeManager()->getAccessControlHandler($this->entityType); $this->assertTrue($access_control_handler->fieldAccess('view', $this->field)); } diff --git a/core/modules/field_ui/field_ui.module b/core/modules/field_ui/field_ui.module index 79b3f151a5..647211dc63 100644 --- a/core/modules/field_ui/field_ui.module +++ b/core/modules/field_ui/field_ui.module @@ -142,7 +142,7 @@ function field_ui_entity_operation(EntityInterface $entity) { $info = $entity->getEntityType(); // Add manage fields and display links if this entity type is the bundle // of another and that type has field UI enabled. - if (($bundle_of = $info->getBundleOf()) && \Drupal::entityManager()->getDefinition($bundle_of)->get('field_ui_base_route')) { + if (($bundle_of = $info->getBundleOf()) && \Drupal::entityTypeManager()->getDefinition($bundle_of)->get('field_ui_base_route')) { $account = \Drupal::currentUser(); if ($account->hasPermission('administer ' . $bundle_of . ' fields')) { $operations['manage-fields'] = [ diff --git a/core/modules/field_ui/src/FieldUI.php b/core/modules/field_ui/src/FieldUI.php index b9351a4b77..0d5d7771dc 100644 --- a/core/modules/field_ui/src/FieldUI.php +++ b/core/modules/field_ui/src/FieldUI.php @@ -23,7 +23,7 @@ class FieldUI { * A URL object. */ public static function getOverviewRouteInfo($entity_type_id, $bundle) { - $entity_type = \Drupal::entityManager()->getDefinition($entity_type_id); + $entity_type = \Drupal::entityTypeManager()->getDefinition($entity_type_id); if ($entity_type->get('field_ui_base_route')) { return new Url("entity.{$entity_type_id}.field_ui_fields", static::getRouteBundleParameter($entity_type, $bundle)); } diff --git a/core/modules/field_ui/src/Form/EntityDisplayModeFormBase.php b/core/modules/field_ui/src/Form/EntityDisplayModeFormBase.php index 2a5ed16868..461a74d8ed 100644 --- a/core/modules/field_ui/src/Form/EntityDisplayModeFormBase.php +++ b/core/modules/field_ui/src/Form/EntityDisplayModeFormBase.php @@ -80,7 +80,7 @@ public function exists($entity_id, array $element) { public function save(array $form, FormStateInterface $form_state) { $this->messenger()->addStatus($this->t('Saved the %label @entity-type.', ['%label' => $this->entity->label(), '@entity-type' => $this->entityType->getLowercaseLabel()])); $this->entity->save(); - \Drupal::entityManager()->clearCachedFieldDefinitions(); + \Drupal::service('entity_field.manager')->clearCachedFieldDefinitions(); $form_state->setRedirectUrl($this->entity->toUrl('collection')); } diff --git a/core/modules/field_ui/tests/src/Functional/ManageDisplayTest.php b/core/modules/field_ui/tests/src/Functional/ManageDisplayTest.php index 2cdcf14841..66aedf51ea 100644 --- a/core/modules/field_ui/tests/src/Functional/ManageDisplayTest.php +++ b/core/modules/field_ui/tests/src/Functional/ManageDisplayTest.php @@ -63,7 +63,7 @@ protected function setUp() { public function testViewModeCustom() { // Create a field, and a node with some data for the field. $this->fieldUIAddNewField('admin/structure/types/manage/' . $this->type, 'test', 'Test field'); - \Drupal::entityManager()->clearCachedFieldDefinitions(); + \Drupal::service('entity_field.manager')->clearCachedFieldDefinitions(); // For this test, use a formatter setting value that is an integer unlikely // to appear in a rendered node other than as part of the field being tested // (for example, unlikely to be part of the "Submitted by ... on ..." line). @@ -238,7 +238,7 @@ public function assertNodeViewNoText(EntityInterface $node, $view_mode, $text, $ public function assertNodeViewTextHelper(EntityInterface $node, $view_mode, $text, $message, $not_exists) { // Make sure caches on the tester side are refreshed after changes // submitted on the tested side. - \Drupal::entityManager()->clearCachedFieldDefinitions(); + \Drupal::service('entity_field.manager')->clearCachedFieldDefinitions(); // Render a cloned node, so that we do not alter the original. $clone = clone $node; diff --git a/core/modules/file/file.module b/core/modules/file/file.module index 809cc3b129..a18edcd847 100644 --- a/core/modules/file/file.module +++ b/core/modules/file/file.module @@ -87,7 +87,7 @@ function file_field_widget_info_alter(array &$info) { function file_load_multiple(array $fids = NULL, $reset = FALSE) { @trigger_error('file_load_multiple() is deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal\file\Entity\File::loadMultiple(). See https://www.drupal.org/node/2266845', E_USER_DEPRECATED); if ($reset) { - \Drupal::entityManager()->getStorage('file')->resetCache($fids); + \Drupal::entityTypeManager()->getStorage('file')->resetCache($fids); } return File::loadMultiple($fids); } @@ -112,7 +112,7 @@ function file_load_multiple(array $fids = NULL, $reset = FALSE) { function file_load($fid, $reset = FALSE) { @trigger_error('file_load() is deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal\file\Entity\File::load(). See https://www.drupal.org/node/2266845', E_USER_DEPRECATED); if ($reset) { - \Drupal::entityManager()->getStorage('file')->resetCache([$fid]); + \Drupal::entityTypeManager()->getStorage('file')->resetCache([$fid]); } return File::load($fid); } @@ -396,7 +396,7 @@ function file_validate_size(FileInterface $file, $file_limit = 0, $user_limit = } // Save a query by only calling spaceUsed() when a limit is provided. - if ($user_limit && (\Drupal::entityManager()->getStorage('file')->spaceUsed($user->id()) + $file->getSize()) > $user_limit) { + if ($user_limit && (\Drupal::entityTypeManager()->getStorage('file')->spaceUsed($user->id()) + $file->getSize()) > $user_limit) { $errors[] = t('The file is %filesize which would exceed your disk quota of %quota.', ['%filesize' => format_size($file->getSize()), '%quota' => format_size($user_limit)]); } @@ -714,7 +714,7 @@ function file_file_download($uri) { */ function file_cron() { $age = \Drupal::config('system.file')->get('temporary_maximum_age'); - $file_storage = \Drupal::entityManager()->getStorage('file'); + $file_storage = \Drupal::entityTypeManager()->getStorage('file'); // Only delete temporary files if older than $age. Note that automatic cleanup // is disabled if $age set to 0. @@ -1732,7 +1732,7 @@ function file_get_file_references(FileInterface $file, FieldDefinitionInterface if ($field || $field_type) { foreach ($return as $field_name => $data) { foreach (array_keys($data) as $entity_type_id) { - $field_storage_definitions = \Drupal::entityManager()->getFieldStorageDefinitions($entity_type_id); + $field_storage_definitions = \Drupal::service('entity_field.manager')->getFieldStorageDefinitions($entity_type_id); $current_field = $field_storage_definitions[$field_name]; if (($field_type && $current_field->getType() != $field_type) || ($field && $field->uuid() != $current_field->uuid())) { unset($return[$field_name][$entity_type_id]); diff --git a/core/modules/file/file.views.inc b/core/modules/file/file.views.inc index 8e45101bd8..f2c2482f56 100644 --- a/core/modules/file/file.views.inc +++ b/core/modules/file/file.views.inc @@ -38,7 +38,7 @@ function file_field_views_data(FieldStorageConfigInterface $field_storage) { */ function file_field_views_data_views_data_alter(array &$data, FieldStorageConfigInterface $field_storage) { $entity_type_id = $field_storage->getTargetEntityTypeId(); - $entity_manager = \Drupal::entityManager(); + $entity_manager = \Drupal::entityTypeManager(); $entity_type = $entity_manager->getDefinition($entity_type_id); $field_name = $field_storage->getName(); $pseudo_field_name = 'reverse_' . $field_name . '_' . $entity_type_id; diff --git a/core/modules/file/src/Plugin/Field/FieldType/FileFieldItemList.php b/core/modules/file/src/Plugin/Field/FieldType/FileFieldItemList.php index c7cf0f04e4..ab936177bb 100644 --- a/core/modules/file/src/Plugin/Field/FieldType/FileFieldItemList.php +++ b/core/modules/file/src/Plugin/Field/FieldType/FileFieldItemList.php @@ -60,7 +60,7 @@ public function postSave($update) { // Decrement file usage by 1 for files that were removed from the field. $removed_ids = array_filter(array_diff($original_ids, $ids)); - $removed_files = \Drupal::entityManager()->getStorage('file')->loadMultiple($removed_ids); + $removed_files = \Drupal::entityTypeManager()->getStorage('file')->loadMultiple($removed_ids); foreach ($removed_files as $file) { \Drupal::service('file.usage')->delete($file, 'file', $entity->getEntityTypeId(), $entity->id()); } diff --git a/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php b/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php index f1da5a4b5f..b06dcae40b 100644 --- a/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php +++ b/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php @@ -346,7 +346,7 @@ public static function validateMultipleCount($element, FormStateInterface $form_ array_pop($array_parents); $previously_uploaded_count = count(Element::children(NestedArray::getValue($form, $array_parents))) - 1; - $field_storage_definitions = \Drupal::entityManager()->getFieldStorageDefinitions($element['#entity_type']); + $field_storage_definitions = \Drupal::service('entity_field.manager')->getFieldStorageDefinitions($element['#entity_type']); $field_storage = $field_storage_definitions[$element['#field_name']]; $newly_uploaded_count = count($values['fids']); $total_uploaded_count = $newly_uploaded_count + $previously_uploaded_count; diff --git a/core/modules/file/tests/src/Functional/FileFieldWidgetTest.php b/core/modules/file/tests/src/Functional/FileFieldWidgetTest.php index 4aaf196e6a..9d20859c0b 100644 --- a/core/modules/file/tests/src/Functional/FileFieldWidgetTest.php +++ b/core/modules/file/tests/src/Functional/FileFieldWidgetTest.php @@ -298,7 +298,7 @@ public function testPrivateFileComment() { $this->fieldUIAddNewField('admin/structure/comment/manage/comment', $name, $label, 'file', $storage_edit); // Manually clear cache on the tester side. - \Drupal::entityManager()->clearCachedFieldDefinitions(); + \Drupal::service('entity_field.manager')->clearCachedFieldDefinitions(); // Create node. $edit = [ diff --git a/core/modules/file/tests/src/Functional/FileManagedFileElementTest.php b/core/modules/file/tests/src/Functional/FileManagedFileElementTest.php index 7feaa507da..2b448ba7db 100644 --- a/core/modules/file/tests/src/Functional/FileManagedFileElementTest.php +++ b/core/modules/file/tests/src/Functional/FileManagedFileElementTest.php @@ -142,7 +142,7 @@ public function testManagedFileRemoved() { $this->drupalPostForm(NULL, $edit, t('Upload')); $fid = $this->getLastFileId(); - $file = \Drupal::entityManager()->getStorage('file')->load($fid); + $file = \Drupal::entityTypeManager()->getStorage('file')->load($fid); $file->delete(); $this->drupalPostForm(NULL, $edit, t('Upload')); diff --git a/core/modules/file/tests/src/Functional/FileOnTranslatedEntityTest.php b/core/modules/file/tests/src/Functional/FileOnTranslatedEntityTest.php index c6ff2c7612..65aa802b92 100644 --- a/core/modules/file/tests/src/Functional/FileOnTranslatedEntityTest.php +++ b/core/modules/file/tests/src/Functional/FileOnTranslatedEntityTest.php @@ -81,7 +81,7 @@ protected function setUp() { */ public function testSyncedFiles() { // Verify that the file field on the "Basic page" node type is translatable. - $definitions = \Drupal::entityManager()->getFieldDefinitions('node', 'page'); + $definitions = \Drupal::service('entity_field.manager')->getFieldDefinitions('node', 'page'); $this->assertTrue($definitions[$this->fieldName]->isTranslatable(), 'Node file field is translatable.'); // Create a default language node. diff --git a/core/modules/file/tests/src/Functional/FilePrivateTest.php b/core/modules/file/tests/src/Functional/FilePrivateTest.php index 2e5b0a1dac..7a6824b132 100644 --- a/core/modules/file/tests/src/Functional/FilePrivateTest.php +++ b/core/modules/file/tests/src/Functional/FilePrivateTest.php @@ -46,7 +46,7 @@ public function testPrivateFile() { $test_file = $this->getTestFile('text'); $nid = $this->uploadNodeFile($test_file, $field_name, $type_name, TRUE, ['private' => TRUE]); - \Drupal::entityManager()->getStorage('node')->resetCache([$nid]); + \Drupal::entityTypeManager()->getStorage('node')->resetCache([$nid]); /* @var \Drupal\node\NodeInterface $node */ $node = $node_storage->load($nid); $node_file = File::load($node->{$field_name}->target_id); @@ -67,7 +67,7 @@ public function testPrivateFile() { // Test with the field that should deny access through field access. $this->drupalLogin($this->adminUser); $nid = $this->uploadNodeFile($test_file, $no_access_field_name, $type_name, TRUE, ['private' => TRUE]); - \Drupal::entityManager()->getStorage('node')->resetCache([$nid]); + \Drupal::entityTypeManager()->getStorage('node')->resetCache([$nid]); $node = $node_storage->load($nid); $node_file = File::load($node->{$no_access_field_name}->target_id); diff --git a/core/modules/file/tests/src/Functional/PrivateFileOnTranslatedEntityTest.php b/core/modules/file/tests/src/Functional/PrivateFileOnTranslatedEntityTest.php index 51051a09d7..44b2ee10c9 100644 --- a/core/modules/file/tests/src/Functional/PrivateFileOnTranslatedEntityTest.php +++ b/core/modules/file/tests/src/Functional/PrivateFileOnTranslatedEntityTest.php @@ -70,7 +70,7 @@ protected function setUp() { */ public function testPrivateLanguageFile() { // Verify that the file field on the "Basic page" node type is translatable. - $definitions = \Drupal::entityManager()->getFieldDefinitions('node', 'page'); + $definitions = \Drupal::service('entity_field.manager')->getFieldDefinitions('node', 'page'); $this->assertTrue($definitions[$this->fieldName]->isTranslatable(), 'Node file field is translatable.'); // Create a default language node. @@ -87,7 +87,7 @@ public function testPrivateLanguageFile() { $this->rebuildContainer(); // Ensure the file can be downloaded. - \Drupal::entityManager()->getStorage('node')->resetCache([$default_language_node->id()]); + \Drupal::entityTypeManager()->getStorage('node')->resetCache([$default_language_node->id()]); $node = Node::load($default_language_node->id()); $node_file = File::load($node->{$this->fieldName}->target_id); $this->drupalGet(file_create_url($node_file->getFileUri())); @@ -109,7 +109,7 @@ public function testPrivateLanguageFile() { $last_fid = $this->getLastFileId(); // Verify the translation was created. - \Drupal::entityManager()->getStorage('node')->resetCache([$default_language_node->id()]); + \Drupal::entityTypeManager()->getStorage('node')->resetCache([$default_language_node->id()]); $default_language_node = Node::load($default_language_node->id()); $this->assertTrue($default_language_node->hasTranslation('fr'), 'Node found in database.'); $this->assertTrue($last_fid > $last_fid_prior, 'New file got saved.'); diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module index e1d3657574..422feac65d 100644 --- a/core/modules/filter/filter.module +++ b/core/modules/filter/filter.module @@ -102,9 +102,9 @@ function filter_formats(AccountInterface $account = NULL) { $formats['all'] = $cache->data; } else { - $formats['all'] = \Drupal::entityManager()->getStorage('filter_format')->loadByProperties(['status' => TRUE]); + $formats['all'] = \Drupal::entityTypeManager()->getStorage('filter_format')->loadByProperties(['status' => TRUE]); uasort($formats['all'], 'Drupal\Core\Config\Entity\ConfigEntityBase::sort'); - \Drupal::cache()->set("filter_formats:{$language_interface->getId()}", $formats['all'], Cache::PERMANENT, \Drupal::entityManager()->getDefinition('filter_format')->getListCacheTags()); + \Drupal::cache()->set("filter_formats:{$language_interface->getId()}", $formats['all'], Cache::PERMANENT, \Drupal::entityTypeManager()->getDefinition('filter_format')->getListCacheTags()); } } diff --git a/core/modules/filter/tests/src/Kernel/FilterAPITest.php b/core/modules/filter/tests/src/Kernel/FilterAPITest.php index 8ce4fa9108..ed6bff8668 100644 --- a/core/modules/filter/tests/src/Kernel/FilterAPITest.php +++ b/core/modules/filter/tests/src/Kernel/FilterAPITest.php @@ -487,7 +487,7 @@ public function testDependencyRemoval() { $this->assertTrue(isset($filters['filter_test_restrict_tags_and_attributes']), 'The filter plugin filter_test_restrict_tags_and_attributes is configured by the filtered_html filter format.'); drupal_static_reset('filter_formats'); - \Drupal::entityManager()->getStorage('filter_format')->resetCache(); + \Drupal::entityTypeManager()->getStorage('filter_format')->resetCache(); $module_data = \Drupal::service('extension.list.module')->reset()->getList(); $this->assertFalse(isset($module_data['filter_test']->info['required']), 'The filter_test module is required.'); @@ -500,7 +500,7 @@ public function testDependencyRemoval() { // Verify the filter format still exists but the dependency and filter is // gone. - \Drupal::entityManager()->getStorage('filter_format')->resetCache(); + \Drupal::entityTypeManager()->getStorage('filter_format')->resetCache(); $filter_format = FilterFormat::load('filtered_html'); $this->assertEqual([], $filter_format->getDependencies()); // Use the get method since the FilterFormat::filters() method only returns diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module index 4af6116cfc..dcaf1002ca 100644 --- a/core/modules/forum/forum.module +++ b/core/modules/forum/forum.module @@ -474,7 +474,7 @@ function template_preprocess_forums(&$variables) { $variables['topics'][$id]->new_url = ''; if ($topic->new_replies) { - $page_number = \Drupal::entityManager()->getStorage('comment') + $page_number = \Drupal::entityTypeManager()->getStorage('comment') ->getNewCommentPageNumber($topic->comment_count, $topic->new_replies, $topic, 'comment_forum'); $query = $page_number ? ['page' => $page_number] : NULL; $variables['topics'][$id]->new_text = \Drupal::translation()->formatPlural($topic->new_replies, '1 new post in topic %title', '@count new posts in topic %title', ['%title' => $variables['topics'][$id]->label()]); diff --git a/core/modules/image/image.views.inc b/core/modules/image/image.views.inc index cca0e3d904..483f989faf 100644 --- a/core/modules/image/image.views.inc +++ b/core/modules/image/image.views.inc @@ -39,11 +39,11 @@ function image_field_views_data(FieldStorageConfigInterface $field_storage) { function image_field_views_data_views_data_alter(array &$data, FieldStorageConfigInterface $field_storage) { $entity_type_id = $field_storage->getTargetEntityTypeId(); $field_name = $field_storage->getName(); - $entity_manager = \Drupal::entityManager(); - $entity_type = $entity_manager->getDefinition($entity_type_id); + $entity_type_manager = \Drupal::entityTypeManager(); + $entity_type = $entity_type_manager->getDefinition($entity_type_id); $pseudo_field_name = 'reverse_' . $field_name . '_' . $entity_type_id; /** @var \Drupal\Core\Entity\Sql\DefaultTableMapping $table_mapping */ - $table_mapping = $entity_manager->getStorage($entity_type_id)->getTableMapping(); + $table_mapping = $entity_type_manager->getStorage($entity_type_id)->getTableMapping(); list($label) = views_entity_field_label($entity_type_id, $field_name); diff --git a/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php b/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php index ba4677d7ea..3880a68961 100644 --- a/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php +++ b/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php @@ -481,7 +481,7 @@ public static function validateDefaultImageForm(array &$element, FormStateInterf if (isset($element['fids']['#value'][0])) { $value = $element['fids']['#value'][0]; // Convert the file ID to a uuid. - if ($file = \Drupal::entityManager()->getStorage('file')->load($value)) { + if ($file = \Drupal::entityTypeManager()->getStorage('file')->load($value)) { $value = $file->uuid(); } } diff --git a/core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php b/core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php index 2dde552788..47aa51fa15 100644 --- a/core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php +++ b/core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php @@ -326,7 +326,7 @@ public function onDependencyRemoval(array $dependencies) { if ($style_id && $style = ImageStyle::load($style_id)) { if (!empty($dependencies[$style->getConfigDependencyKey()][$style->getConfigDependencyName()])) { /** @var \Drupal\image\ImageStyleStorageInterface $storage */ - $storage = \Drupal::entityManager()->getStorage($style->getEntityTypeId()); + $storage = \Drupal::entityTypeManager()->getStorage($style->getEntityTypeId()); $replacement_id = $storage->getReplacementId($style_id); // If a valid replacement has been provided in the storage, replace the // preview image style with the replacement. diff --git a/core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php b/core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php index a69eeaae80..410d7bf032 100644 --- a/core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php +++ b/core/modules/image/tests/src/Functional/ImageFieldDisplayTest.php @@ -374,7 +374,7 @@ public function testImageFieldDefaultImage() { ]; $this->drupalPostForm("admin/structure/types/manage/article/fields/node.article.$field_name/storage", $edit, t('Save field settings')); // Clear field definition cache so the new default image is detected. - \Drupal::entityManager()->clearCachedFieldDefinitions(); + \Drupal::service('entity_field.manager')->clearCachedFieldDefinitions(); $field_storage = FieldStorageConfig::loadByName('node', $field_name); $default_image = $field_storage->getSetting('default_image'); $file = \Drupal::service('entity.repository')->loadEntityByUuid('file', $default_image['uuid']); @@ -427,7 +427,7 @@ public function testImageFieldDefaultImage() { $this->getSession()->getPage()->pressButton(t('Save field settings')); // Clear field definition cache so the new default image is detected. - \Drupal::entityManager()->clearCachedFieldDefinitions(); + \Drupal::service('entity_field.manager')->clearCachedFieldDefinitions(); $field_storage = FieldStorageConfig::loadByName('node', $field_name); $default_image = $field_storage->getSetting('default_image'); $this->assertFalse($default_image['uuid'], 'Default image removed from field.'); @@ -444,7 +444,7 @@ public function testImageFieldDefaultImage() { ]; $this->drupalPostForm('admin/structure/types/manage/article/fields/node.article.' . $private_field_name . '/storage', $edit, t('Save field settings')); // Clear field definition cache so the new default image is detected. - \Drupal::entityManager()->clearCachedFieldDefinitions(); + \Drupal::service('entity_field.manager')->clearCachedFieldDefinitions(); $private_field_storage = FieldStorageConfig::loadByName('node', $private_field_name); $default_image = $private_field_storage->getSetting('default_image'); diff --git a/core/modules/image/tests/src/Functional/ImageOnTranslatedEntityTest.php b/core/modules/image/tests/src/Functional/ImageOnTranslatedEntityTest.php index 15ca758288..e4bde9261c 100644 --- a/core/modules/image/tests/src/Functional/ImageOnTranslatedEntityTest.php +++ b/core/modules/image/tests/src/Functional/ImageOnTranslatedEntityTest.php @@ -92,7 +92,7 @@ public function testSyncedImages() { // Verify that the image field on the "Basic basic" node type is // translatable. - $definitions = \Drupal::entityManager()->getFieldDefinitions('node', 'basicpage'); + $definitions = \Drupal::service('entity_field.manager')->getFieldDefinitions('node', 'basicpage'); $this->assertTrue($definitions[$this->fieldName]->isTranslatable(), 'Node image field is translatable.'); // Create a default language node. diff --git a/core/modules/jsonapi/tests/src/Functional/JsonApiFunctionalTest.php b/core/modules/jsonapi/tests/src/Functional/JsonApiFunctionalTest.php index b2d6f1033f..bea8773efb 100644 --- a/core/modules/jsonapi/tests/src/Functional/JsonApiFunctionalTest.php +++ b/core/modules/jsonapi/tests/src/Functional/JsonApiFunctionalTest.php @@ -748,7 +748,7 @@ public function testWrite() { $this->assertEquals("The current user is not allowed to PATCH the selected field (status). The 'administer nodes' permission is required.", $updated_response['errors'][0]['detail']); - $node = \Drupal::entityManager()->loadEntityByUuid('node', $uuid); + $node = \Drupal::service('entity.repository')->loadEntityByUuid('node', $uuid); $this->assertEquals(1, $node->get('status')->value, 'Node status was not changed.'); // 9. Successful POST to related endpoint. $body = [ diff --git a/core/modules/language/language.module b/core/modules/language/language.module index 2b178e1c96..d313746ed7 100644 --- a/core/modules/language/language.module +++ b/core/modules/language/language.module @@ -329,7 +329,7 @@ function language_modules_installed($modules) { // this is not a hard dependency, and thus is not detected by the config // system, we have to clean up the related values manually. foreach (['entity_view_display', 'entity_form_display'] as $key) { - $displays = \Drupal::entityManager()->getStorage($key)->loadMultiple(); + $displays = \Drupal::entityTypeManager()->getStorage($key)->loadMultiple(); /** @var \Drupal\Core\Entity\Display\EntityDisplayInterface $display */ foreach ($displays as $display) { $display->save(); diff --git a/core/modules/language/src/Entity/ContentLanguageSettings.php b/core/modules/language/src/Entity/ContentLanguageSettings.php index d89b1508f9..4f1bf44db6 100644 --- a/core/modules/language/src/Entity/ContentLanguageSettings.php +++ b/core/modules/language/src/Entity/ContentLanguageSettings.php @@ -192,7 +192,7 @@ public static function loadByEntityTypeBundle($entity_type_id, $bundle) { if ($entity_type_id == NULL || $bundle == NULL) { return NULL; } - $config = \Drupal::entityManager()->getStorage('language_content_settings')->load($entity_type_id . '.' . $bundle); + $config = \Drupal::entityTypeManager()->getStorage('language_content_settings')->load($entity_type_id . '.' . $bundle); if ($config == NULL) { $config = ContentLanguageSettings::create(['target_entity_type_id' => $entity_type_id, 'target_bundle' => $bundle]); } @@ -206,7 +206,7 @@ public function calculateDependencies() { parent::calculateDependencies(); // Create dependency on the bundle. - $entity_type = \Drupal::entityManager()->getDefinition($this->target_entity_type_id); + $entity_type = \Drupal::entityTypeManager()->getDefinition($this->target_entity_type_id); $bundle_config_dependency = $entity_type->getBundleConfigDependency($this->target_bundle); $this->addDependency($bundle_config_dependency['type'], $bundle_config_dependency['name']); diff --git a/core/modules/language/tests/src/Functional/LanguageConfigurationElementTest.php b/core/modules/language/tests/src/Functional/LanguageConfigurationElementTest.php index 0f3dd1f0ba..a562f24970 100644 --- a/core/modules/language/tests/src/Functional/LanguageConfigurationElementTest.php +++ b/core/modules/language/tests/src/Functional/LanguageConfigurationElementTest.php @@ -203,15 +203,15 @@ public function testNodeTypeDelete() { $this->drupalPostForm('admin/structure/types/manage/article', $edit, t('Save content type')); // Check the language default configuration for articles is present. - $configuration = \Drupal::entityManager()->getStorage('language_content_settings')->load('node.article'); + $configuration = \Drupal::entityTypeManager()->getStorage('language_content_settings')->load('node.article'); $this->assertTrue($configuration, 'The language configuration is present.'); // Delete 'article' bundle. $this->drupalPostForm('admin/structure/types/manage/article/delete', [], t('Delete')); // Check that the language configuration has been deleted. - \Drupal::entityManager()->getStorage('language_content_settings')->resetCache(); - $configuration = \Drupal::entityManager()->getStorage('language_content_settings')->load('node.article'); + \Drupal::entityTypeManager()->getStorage('language_content_settings')->resetCache(); + $configuration = \Drupal::entityTypeManager()->getStorage('language_content_settings')->load('node.article'); $this->assertFalse($configuration, 'The language configuration was deleted after bundle was deleted.'); } diff --git a/core/modules/locale/tests/src/Functional/LocaleTranslatedSchemaDefinitionTest.php b/core/modules/locale/tests/src/Functional/LocaleTranslatedSchemaDefinitionTest.php index ba5afb933e..6f292693f8 100644 --- a/core/modules/locale/tests/src/Functional/LocaleTranslatedSchemaDefinitionTest.php +++ b/core/modules/locale/tests/src/Functional/LocaleTranslatedSchemaDefinitionTest.php @@ -53,7 +53,7 @@ public function testTranslatedSchemaDefinition() { ])->save(); // Ensure that the field is translated when access through the API. - $this->assertEqual('Translated Revision ID', \Drupal::entityManager()->getBaseFieldDefinitions('node')['vid']->getLabel()); + $this->assertEqual('Translated Revision ID', \Drupal::service('entity_field.manager')->getBaseFieldDefinitions('node')['vid']->getLabel()); // Assert there are no updates. $this->assertFalse(\Drupal::service('entity.definition_update_manager')->needsUpdates()); diff --git a/core/modules/menu_link_content/menu_link_content.module b/core/modules/menu_link_content/menu_link_content.module index 2960834a5c..3f9ca515f9 100644 --- a/core/modules/menu_link_content/menu_link_content.module +++ b/core/modules/menu_link_content/menu_link_content.module @@ -43,7 +43,7 @@ function menu_link_content_entity_type_alter(array &$entity_types) { * Implements hook_menu_delete(). */ function menu_link_content_menu_delete(MenuInterface $menu) { - $storage = \Drupal::entityManager()->getStorage('menu_link_content'); + $storage = \Drupal::entityTypeManager()->getStorage('menu_link_content'); $menu_links = $storage->loadByProperties(['menu_name' => $menu->id()]); $storage->delete($menu_links); } @@ -65,7 +65,7 @@ function _menu_link_content_update_path_alias($path) { /** @var \Drupal\Core\Menu\MenuLinkManagerInterface $menu_link_manager */ $menu_link_manager = \Drupal::service('plugin.manager.menu.link'); /** @var \Drupal\menu_link_content\MenuLinkContentInterface[] $entities */ - $entities = \Drupal::entityManager() + $entities = \Drupal::entityTypeManager() ->getStorage('menu_link_content') ->loadByProperties(['link.uri' => 'internal:' . $path]); foreach ($entities as $menu_link) { diff --git a/core/modules/menu_ui/menu_ui.module b/core/modules/menu_ui/menu_ui.module index fb6b852ed3..c6093ac10f 100644 --- a/core/modules/menu_ui/menu_ui.module +++ b/core/modules/menu_ui/menu_ui.module @@ -188,7 +188,7 @@ function menu_ui_get_menu_link_defaults(NodeInterface $node) { if (!$defaults) { // Get the default max_length of a menu link title from the base field // definition. - $field_definitions = \Drupal::entityManager()->getBaseFieldDefinitions('menu_link_content'); + $field_definitions = \Drupal::service('entity_field.manager')->getBaseFieldDefinitions('menu_link_content'); $max_length = $field_definitions['title']->getSetting('max_length'); $description_max_length = $field_definitions['description']->getSetting('max_length'); $defaults = [ diff --git a/core/modules/menu_ui/src/Tests/MenuWebTestBase.php b/core/modules/menu_ui/src/Tests/MenuWebTestBase.php index a8b9862223..136b246b1c 100644 --- a/core/modules/menu_ui/src/Tests/MenuWebTestBase.php +++ b/core/modules/menu_ui/src/Tests/MenuWebTestBase.php @@ -37,7 +37,7 @@ public function assertMenuLink($menu_plugin_id, array $expected_item) { $menu_link_manager = \Drupal::service('plugin.manager.menu.link'); $menu_link_manager->resetDefinitions(); // Reset the static load cache. - \Drupal::entityManager()->getStorage('menu_link_content')->resetCache(); + \Drupal::entityTypeManager()->getStorage('menu_link_content')->resetCache(); $definition = $menu_link_manager->getDefinition($menu_plugin_id); $entity = NULL; @@ -46,7 +46,7 @@ public function assertMenuLink($menu_plugin_id, array $expected_item) { if (strpos($menu_plugin_id, 'menu_link_content') === 0) { list(, $uuid) = explode(':', $menu_plugin_id, 2); /** @var \Drupal\menu_link_content\Entity\MenuLinkContent $entity */ - $entity = \Drupal::entityManager()->loadEntityByUuid('menu_link_content', $uuid); + $entity = \Drupal::service('entity.repository')->loadEntityByUuid('menu_link_content', $uuid); } if (isset($expected_item['children'])) { diff --git a/core/modules/menu_ui/tests/src/Functional/MenuUiNodeTest.php b/core/modules/menu_ui/tests/src/Functional/MenuUiNodeTest.php index 24a81d9809..57a100a5e1 100644 --- a/core/modules/menu_ui/tests/src/Functional/MenuUiNodeTest.php +++ b/core/modules/menu_ui/tests/src/Functional/MenuUiNodeTest.php @@ -63,12 +63,12 @@ public function testMenuNodeFormWidget() { $this->assertSession()->responseHeaderContains('X-Drupal-Cache-Contexts', 'user.roles:authenticated'); // Verify that the menu link title has the correct maxlength. - $title_max_length = \Drupal::entityManager()->getBaseFieldDefinitions('menu_link_content')['title']->getSetting('max_length'); + $title_max_length = \Drupal::service('entity_field.manager')->getBaseFieldDefinitions('menu_link_content')['title']->getSetting('max_length'); $this->drupalGet('node/add/page'); $this->assertPattern('//', 'Menu link title field has correct maxlength in node add form.'); // Verify that the menu link description has the correct maxlength. - $description_max_length = \Drupal::entityManager()->getBaseFieldDefinitions('menu_link_content')['description']->getSetting('max_length'); + $description_max_length = \Drupal::service('entity_field.manager')->getBaseFieldDefinitions('menu_link_content')['description']->getSetting('max_length'); $this->drupalGet('node/add/page'); $this->assertPattern('//', 'Menu link description field has correct maxlength in node add form.'); diff --git a/core/modules/menu_ui/tests/src/Functional/MenuUninstallTest.php b/core/modules/menu_ui/tests/src/Functional/MenuUninstallTest.php index a0320f44b0..b2d64cece5 100644 --- a/core/modules/menu_ui/tests/src/Functional/MenuUninstallTest.php +++ b/core/modules/menu_ui/tests/src/Functional/MenuUninstallTest.php @@ -25,7 +25,7 @@ class MenuUninstallTest extends BrowserTestBase { public function testMenuUninstall() { \Drupal::service('module_installer')->uninstall(['menu_ui']); - \Drupal::entityManager()->getStorage('menu')->resetCache(['admin']); + \Drupal::entityTypeManager()->getStorage('menu')->resetCache(['admin']); $this->assertTrue(Menu::load('admin'), 'The \'admin\' menu still exists after uninstalling Menu UI module.'); } diff --git a/core/modules/migrate/src/MigrateExecutable.php b/core/modules/migrate/src/MigrateExecutable.php index b0f2fa8a1a..c3a0506419 100644 --- a/core/modules/migrate/src/MigrateExecutable.php +++ b/core/modules/migrate/src/MigrateExecutable.php @@ -546,9 +546,9 @@ protected function attemptMemoryReclaim() { drupal_static_reset(); // Entity storage can blow up with caches so clear them out. - $manager = \Drupal::entityManager(); - foreach ($manager->getDefinitions() as $id => $definition) { - $manager->getStorage($id)->resetCache(); + $entity_type_manager = \Drupal::entityTypeManager(); + foreach ($entity_type_manager->getDefinitions() as $id => $definition) { + $entity_type_manager->getStorage($id)->resetCache(); } // @TODO: explore resetting the container. diff --git a/core/modules/migrate_drupal/src/Tests/StubTestTrait.php b/core/modules/migrate_drupal/src/Tests/StubTestTrait.php index 3bf00281a0..5a5fa04332 100644 --- a/core/modules/migrate_drupal/src/Tests/StubTestTrait.php +++ b/core/modules/migrate_drupal/src/Tests/StubTestTrait.php @@ -65,7 +65,7 @@ protected function createStub($entity_type_id) { * List of constraint violations identified. */ protected function validateStub($entity_type_id, $entity_id) { - $controller = \Drupal::entityManager()->getStorage($entity_type_id); + $controller = \Drupal::entityTypeManager()->getStorage($entity_type_id); /** @var \Drupal\Core\Entity\ContentEntityInterface $stub_entity */ $stub_entity = $controller->load($entity_id); return $stub_entity->validate(); diff --git a/core/modules/node/node.install b/core/modules/node/node.install index 557153eb59..ba1d946535 100644 --- a/core/modules/node/node.install +++ b/core/modules/node/node.install @@ -18,7 +18,7 @@ function node_requirements($phase) { // Only show rebuild button if there are either 0, or 2 or more, rows // in the {node_access} table, or if there are modules that // implement hook_node_grants(). - $grant_count = \Drupal::entityManager()->getAccessControlHandler('node')->countGrants(); + $grant_count = \Drupal::entityTypeManager()->getAccessControlHandler('node')->countGrants(); if ($grant_count != 1 || count(\Drupal::moduleHandler()->getImplementations('node_grants')) > 0) { $value = \Drupal::translation()->formatPlural($grant_count, 'One permission in use', '@count permissions in use', ['@count' => $grant_count]); } diff --git a/core/modules/node/node.module b/core/modules/node/node.module index af0c16606f..5d2cb372f4 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -428,7 +428,7 @@ function node_entity_extra_field_info() { * The number of nodes whose node type field was modified. */ function node_type_update_nodes($old_id, $new_id) { - return \Drupal::entityManager()->getStorage('node')->updateType($old_id, $new_id); + return \Drupal::entityTypeManager()->getStorage('node')->updateType($old_id, $new_id); } /** @@ -455,7 +455,7 @@ function node_type_update_nodes($old_id, $new_id) { function node_load_multiple(array $nids = NULL, $reset = FALSE) { @trigger_error('node_load_multiple() is deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal\node\Entity\Node::loadMultiple(). See https://www.drupal.org/node/2266845', E_USER_DEPRECATED); if ($reset) { - \Drupal::entityManager()->getStorage('node')->resetCache($nids); + \Drupal::entityTypeManager()->getStorage('node')->resetCache($nids); } return Node::loadMultiple($nids); } @@ -480,7 +480,7 @@ function node_load_multiple(array $nids = NULL, $reset = FALSE) { function node_load($nid = NULL, $reset = FALSE) { @trigger_error('node_load() is deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal\node\Entity\Node::load(). See https://www.drupal.org/node/2266845', E_USER_DEPRECATED); if ($reset) { - \Drupal::entityManager()->getStorage('node')->resetCache([$nid]); + \Drupal::entityTypeManager()->getStorage('node')->resetCache([$nid]); } return Node::load($nid); } @@ -767,7 +767,7 @@ function node_user_cancel($edit, UserInterface $account, $method) { case 'user_cancel_reassign': // Anonymize all of the nodes for this old account. module_load_include('inc', 'node', 'node.admin'); - $vids = \Drupal::entityManager()->getStorage('node')->userRevisionIds($account); + $vids = \Drupal::entityTypeManager()->getStorage('node')->userRevisionIds($account); node_mass_update($vids, [ 'uid' => 0, 'revision_uid' => 0, @@ -788,7 +788,7 @@ function node_user_predelete($account) { ->execute(); entity_delete_multiple('node', $nids); // Delete old revisions. - $storage_controller = \Drupal::entityManager()->getStorage('node'); + $storage_controller = \Drupal::entityTypeManager()->getStorage('node'); $revisions = $storage_controller->userRevisionIds($account); foreach ($revisions as $revision) { node_revision_delete($revision); @@ -1068,7 +1068,7 @@ function node_access_view_all_nodes($account = NULL) { $access[$account->id()] = TRUE; } else { - $access[$account->id()] = \Drupal::entityManager()->getAccessControlHandler('node')->checkAllGrants($account); + $access[$account->id()] = \Drupal::entityTypeManager()->getAccessControlHandler('node')->checkAllGrants($account); } return $access[$account->id()]; @@ -1212,9 +1212,9 @@ function node_access_needs_rebuild($rebuild = NULL) { * @see node_access_needs_rebuild() */ function node_access_rebuild($batch_mode = FALSE) { - $node_storage = \Drupal::entityManager()->getStorage('node'); + $node_storage = \Drupal::entityTypeManager()->getStorage('node'); /** @var \Drupal\node\NodeAccessControlHandlerInterface $access_control_handler */ - $access_control_handler = \Drupal::entityManager()->getAccessControlHandler('node'); + $access_control_handler = \Drupal::entityTypeManager()->getAccessControlHandler('node'); $access_control_handler->deleteGrants(); // Only recalculate if the site is using a node_access module. if (count(\Drupal::moduleHandler()->getImplementations('node_grants'))) { @@ -1278,7 +1278,7 @@ function node_access_rebuild($batch_mode = FALSE) { * An array of contextual key/value information for rebuild batch process. */ function _node_access_rebuild_batch_operation(&$context) { - $node_storage = \Drupal::entityManager()->getStorage('node'); + $node_storage = \Drupal::entityTypeManager()->getStorage('node'); if (empty($context['sandbox'])) { // Initiate multistep processing. $context['sandbox']['progress'] = 0; @@ -1305,7 +1305,7 @@ function _node_access_rebuild_batch_operation(&$context) { // loads successfully. if (!empty($node)) { /** @var \Drupal\node\NodeAccessControlHandlerInterface $access_control_handler */ - $access_control_handler = \Drupal::entityManager()->getAccessControlHandler('node'); + $access_control_handler = \Drupal::entityTypeManager()->getAccessControlHandler('node'); $grants = $access_control_handler->acquireGrants($node); \Drupal::service('node.grant_storage')->write($node, $grants); } @@ -1385,7 +1385,7 @@ function node_modules_uninstalled($modules) { */ function node_configurable_language_delete(ConfigurableLanguageInterface $language) { // On nodes with this language, unset the language. - \Drupal::entityManager()->getStorage('node')->clearRevisionsLanguage($language); + \Drupal::entityTypeManager()->getStorage('node')->clearRevisionsLanguage($language); } /** diff --git a/core/modules/node/src/Entity/Node.php b/core/modules/node/src/Entity/Node.php index b3d19d4e89..88bac5aadd 100644 --- a/core/modules/node/src/Entity/Node.php +++ b/core/modules/node/src/Entity/Node.php @@ -144,7 +144,7 @@ public function postSave(EntityStorageInterface $storage, $update = TRUE) { // is new. if ($this->isDefaultRevision()) { /** @var \Drupal\node\NodeAccessControlHandlerInterface $access_control_handler */ - $access_control_handler = \Drupal::entityManager()->getAccessControlHandler('node'); + $access_control_handler = \Drupal::entityTypeManager()->getAccessControlHandler('node'); $grants = $access_control_handler->acquireGrants($this); \Drupal::service('node.grant_storage')->write($this, $grants, NULL, $update); } diff --git a/core/modules/node/src/Plugin/views/wizard/Node.php b/core/modules/node/src/Plugin/views/wizard/Node.php index 0fd93675a8..640d8a8cc0 100644 --- a/core/modules/node/src/Plugin/views/wizard/Node.php +++ b/core/modules/node/src/Plugin/views/wizard/Node.php @@ -214,7 +214,7 @@ protected function buildFilters(&$form, FormStateInterface $form_state) { $tag_fields = []; foreach ($bundles as $bundle) { $display = entity_get_form_display($this->entityTypeId, $bundle, 'default'); - $taxonomy_fields = array_filter(\Drupal::entityManager()->getFieldDefinitions($this->entityTypeId, $bundle), function ($field_definition) { + $taxonomy_fields = array_filter(\Drupal::service('entity_field.manager')->getFieldDefinitions($this->entityTypeId, $bundle), function ($field_definition) { return $field_definition->getType() == 'entity_reference' && $field_definition->getSetting('target_type') == 'taxonomy_term'; }); foreach ($taxonomy_fields as $field_name => $field) { diff --git a/core/modules/node/src/Tests/NodeTestBase.php b/core/modules/node/src/Tests/NodeTestBase.php index e520b3283e..08e33e6f22 100644 --- a/core/modules/node/src/Tests/NodeTestBase.php +++ b/core/modules/node/src/Tests/NodeTestBase.php @@ -47,7 +47,7 @@ protected function setUp() { ]); $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']); } - $this->accessHandler = \Drupal::entityManager()->getAccessControlHandler('node'); + $this->accessHandler = \Drupal::entityTypeManager()->getAccessControlHandler('node'); } /** diff --git a/core/modules/node/tests/src/Functional/Migrate/d6/MigrateNodeRevisionTest.php b/core/modules/node/tests/src/Functional/Migrate/d6/MigrateNodeRevisionTest.php index 4065278bcf..0a7ed87b81 100644 --- a/core/modules/node/tests/src/Functional/Migrate/d6/MigrateNodeRevisionTest.php +++ b/core/modules/node/tests/src/Functional/Migrate/d6/MigrateNodeRevisionTest.php @@ -28,7 +28,7 @@ protected function setUp() { * Test node revisions migration from Drupal 6 to 8. */ public function testNodeRevision() { - $node = \Drupal::entityManager()->getStorage('node')->loadRevision(2001); + $node = \Drupal::entityTypeManager()->getStorage('node')->loadRevision(2001); /** @var \Drupal\node\NodeInterface $node */ $this->assertIdentical('1', $node->id()); $this->assertIdentical('2001', $node->getRevisionId()); @@ -40,7 +40,7 @@ public function testNodeRevision() { $this->assertIdentical('modified rev 2', $node->revision_log->value); $this->assertIdentical('1390095702', $node->getRevisionCreationTime()); - $node = \Drupal::entityManager()->getStorage('node')->loadRevision(5); + $node = \Drupal::entityTypeManager()->getStorage('node')->loadRevision(5); $this->assertIdentical('1', $node->id()); $this->assertIdentical('body test rev 3', $node->body->value); $this->assertIdentical('1', $node->getRevisionUser()->id()); diff --git a/core/modules/node/tests/src/Functional/NodeAccessLanguageTest.php b/core/modules/node/tests/src/Functional/NodeAccessLanguageTest.php index a3d9c4d942..505e3176a5 100644 --- a/core/modules/node/tests/src/Functional/NodeAccessLanguageTest.php +++ b/core/modules/node/tests/src/Functional/NodeAccessLanguageTest.php @@ -72,7 +72,7 @@ public function testNodeAccess() { $this->assertNodeAccess($expected_node_access, $node_public_no_language, $web_user); // Reset the node access cache and turn on our test node access code. - \Drupal::entityManager()->getAccessControlHandler('node')->resetCache(); + \Drupal::entityTypeManager()->getAccessControlHandler('node')->resetCache(); \Drupal::state()->set('node_access_test_secret_catalan', 1); $node_public_ca = $this->drupalCreateNode(['body' => [[]], 'langcode' => 'ca', 'private' => FALSE]); $this->assertTrue($node_public_ca->language()->getId() == 'ca', 'Node created as Catalan.'); @@ -96,7 +96,7 @@ public function testNodeAccess() { $this->assertNodeAccess($expected_node_access_no_access, $node_public_ca, $web_user); $this->assertNodeAccess($expected_node_access_no_access, $node_public_ca->getTranslation('ca'), $web_user); - \Drupal::entityManager()->getAccessControlHandler('node')->resetCache(); + \Drupal::entityTypeManager()->getAccessControlHandler('node')->resetCache(); // Tests that access is granted if requested with no language. $this->assertNodeAccess($expected_node_access, $node_public_no_language, $web_user); @@ -141,7 +141,7 @@ public function testNodeAccessPrivate() { $this->assertNodeAccess($expected_node_access_no_access, $node_private_no_language, $web_user); // Reset the node access cache and turn on our test node access code. - \Drupal::entityManager()->getAccessControlHandler('node')->resetCache(); + \Drupal::entityTypeManager()->getAccessControlHandler('node')->resetCache(); \Drupal::state()->set('node_access_test_secret_catalan', 1); // Tests that access is not granted if requested with no language. @@ -159,7 +159,7 @@ public function testNodeAccessPrivate() { $this->assertNodeAccess($expected_node_access_no_access, $node_private_ca, $private_ca_user); $this->assertNodeAccess($expected_node_access_no_access, $node_private_ca->getTranslation('ca'), $private_ca_user); - \Drupal::entityManager()->getAccessControlHandler('node')->resetCache(); + \Drupal::entityTypeManager()->getAccessControlHandler('node')->resetCache(); \Drupal::state()->set('node_access_test_secret_catalan', 0); // Tests that Catalan is still not accessible for a user with no access to diff --git a/core/modules/node/tests/src/Functional/NodeAccessPagerTest.php b/core/modules/node/tests/src/Functional/NodeAccessPagerTest.php index ad6cc54944..6e7e0f216a 100644 --- a/core/modules/node/tests/src/Functional/NodeAccessPagerTest.php +++ b/core/modules/node/tests/src/Functional/NodeAccessPagerTest.php @@ -74,7 +74,7 @@ public function testForumPager() { $this->assertTrue($vid, 'Forum navigation vocabulary ID is set.'); // Look up the general discussion term. - $tree = \Drupal::entityManager()->getStorage('taxonomy_term')->loadTree($vid, 0, 1); + $tree = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadTree($vid, 0, 1); $tid = reset($tree)->tid; $this->assertTrue($tid, 'General discussion term is found in the forum vocabulary.'); diff --git a/core/modules/node/tests/src/Functional/NodeCreationTest.php b/core/modules/node/tests/src/Functional/NodeCreationTest.php index 1bee2b6e79..1ac6965fca 100644 --- a/core/modules/node/tests/src/Functional/NodeCreationTest.php +++ b/core/modules/node/tests/src/Functional/NodeCreationTest.php @@ -34,7 +34,7 @@ protected function setUp() { * Creates a "Basic page" node and verifies its consistency in the database. */ public function testNodeCreation() { - $node_type_storage = \Drupal::entityManager()->getStorage('node_type'); + $node_type_storage = \Drupal::entityTypeManager()->getStorage('node_type'); // Test /node/add page with only one content type. $node_type_storage->load('article')->delete(); @@ -131,7 +131,7 @@ public function testUnpublishedNodeCreation() { $this->config('system.site')->set('page.front', '/test-page')->save(); // Set "Basic page" content type to be unpublished by default. - $fields = \Drupal::entityManager()->getFieldDefinitions('node', 'page'); + $fields = \Drupal::service('entity_field.manager')->getFieldDefinitions('node', 'page'); $fields['status']->getConfig('page') ->setDefaultValue(FALSE) ->save(); @@ -248,7 +248,7 @@ public function testNodeAddWithoutContentTypes() { $this->assertNoLinkByHref('/admin/structure/types/add'); // Test /node/add page without content types. - foreach (\Drupal::entityManager()->getStorage('node_type')->loadMultiple() as $entity) { + foreach (\Drupal::entityTypeManager()->getStorage('node_type')->loadMultiple() as $entity) { $entity->delete(); } diff --git a/core/modules/node/tests/src/Functional/NodeEditFormTest.php b/core/modules/node/tests/src/Functional/NodeEditFormTest.php index 89f891a643..642fba31b8 100644 --- a/core/modules/node/tests/src/Functional/NodeEditFormTest.php +++ b/core/modules/node/tests/src/Functional/NodeEditFormTest.php @@ -167,7 +167,7 @@ public function testNodeEditAuthoredBy() { // Now test with the Autocomplete (Tags) field widget. /** @var \Drupal\Core\Entity\Display\EntityFormDisplayInterface $form_display */ - $form_display = \Drupal::entityManager()->getStorage('entity_form_display')->load('node.page.default'); + $form_display = \Drupal::entityTypeManager()->getStorage('entity_form_display')->load('node.page.default'); $widget = $form_display->getComponent('uid'); $widget['type'] = 'entity_reference_autocomplete_tags'; $widget['settings'] = [ diff --git a/core/modules/node/tests/src/Functional/NodeSaveTest.php b/core/modules/node/tests/src/Functional/NodeSaveTest.php index 6c508aee68..64b38610d6 100644 --- a/core/modules/node/tests/src/Functional/NodeSaveTest.php +++ b/core/modules/node/tests/src/Functional/NodeSaveTest.php @@ -44,7 +44,7 @@ protected function setUp() { */ public function testImport() { // Node ID must be a number that is not in the database. - $nids = \Drupal::entityManager()->getStorage('node')->getQuery() + $nids = \Drupal::entityTypeManager()->getStorage('node')->getQuery() ->sort('nid', 'DESC') ->range(0, 1) ->execute(); diff --git a/core/modules/node/tests/src/Functional/NodeTemplateSuggestionsTest.php b/core/modules/node/tests/src/Functional/NodeTemplateSuggestionsTest.php index dcadf934de..371cf1c32d 100644 --- a/core/modules/node/tests/src/Functional/NodeTemplateSuggestionsTest.php +++ b/core/modules/node/tests/src/Functional/NodeTemplateSuggestionsTest.php @@ -18,7 +18,7 @@ public function testNodeThemeHookSuggestions() { $view_mode = 'full'; // Simulate theming of the node. - $build = \Drupal::entityManager()->getViewBuilder('node')->view($node, $view_mode); + $build = \Drupal::entityTypeManager()->getViewBuilder('node')->view($node, $view_mode); $variables['elements'] = $build; $suggestions = \Drupal::moduleHandler()->invokeAll('theme_suggestions_node', [$variables]); @@ -27,7 +27,7 @@ public function testNodeThemeHookSuggestions() { // Change the view mode. $view_mode = 'node.my_custom_view_mode'; - $build = \Drupal::entityManager()->getViewBuilder('node')->view($node, $view_mode); + $build = \Drupal::entityTypeManager()->getViewBuilder('node')->view($node, $view_mode); $variables['elements'] = $build; $suggestions = \Drupal::moduleHandler()->invokeAll('theme_suggestions_node', [$variables]); diff --git a/core/modules/node/tests/src/Functional/NodeTestBase.php b/core/modules/node/tests/src/Functional/NodeTestBase.php index e52708632b..264ac31535 100644 --- a/core/modules/node/tests/src/Functional/NodeTestBase.php +++ b/core/modules/node/tests/src/Functional/NodeTestBase.php @@ -40,7 +40,7 @@ protected function setUp() { ]); $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']); } - $this->accessHandler = \Drupal::entityManager()->getAccessControlHandler('node'); + $this->accessHandler = \Drupal::entityTypeManager()->getAccessControlHandler('node'); } /** diff --git a/core/modules/node/tests/src/Functional/NodeTranslationUITest.php b/core/modules/node/tests/src/Functional/NodeTranslationUITest.php index 3348ad9d90..00722fdfff 100644 --- a/core/modules/node/tests/src/Functional/NodeTranslationUITest.php +++ b/core/modules/node/tests/src/Functional/NodeTranslationUITest.php @@ -279,7 +279,7 @@ public function testTranslationRendering() { $default_langcode = $this->langcodes[0]; $values[$default_langcode] = $this->getNewEntityValues($default_langcode); $this->entityId = $this->createEntity($values[$default_langcode], $default_langcode); - $node = \Drupal::entityManager()->getStorage($this->entityTypeId)->load($this->entityId); + $node = \Drupal::entityTypeManager()->getStorage($this->entityTypeId)->load($this->entityId); $node->setPromoted(TRUE); // Create translations. @@ -298,7 +298,7 @@ public function testTranslationRendering() { $this->doTestTranslations('node', $values); // Enable the translation language renderer. - $view = \Drupal::entityManager()->getStorage('view')->load('frontpage'); + $view = \Drupal::entityTypeManager()->getStorage('view')->load('frontpage'); $display = &$view->getDisplay('default'); $display['display_options']['rendering_language'] = '***LANGUAGE_entity_translation***'; $view->save(); diff --git a/core/modules/node/tests/src/Functional/Views/BulkFormAccessTest.php b/core/modules/node/tests/src/Functional/Views/BulkFormAccessTest.php index 19c409719d..a51fe21b74 100644 --- a/core/modules/node/tests/src/Functional/Views/BulkFormAccessTest.php +++ b/core/modules/node/tests/src/Functional/Views/BulkFormAccessTest.php @@ -47,7 +47,7 @@ protected function setUp($import_test_views = TRUE) { // Create Article node type. $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']); - $this->accessHandler = \Drupal::entityManager()->getAccessControlHandler('node'); + $this->accessHandler = \Drupal::entityTypeManager()->getAccessControlHandler('node'); node_access_test_add_field(NodeType::load('article')); diff --git a/core/modules/node/tests/src/Functional/Views/NodeRevisionWizardTest.php b/core/modules/node/tests/src/Functional/Views/NodeRevisionWizardTest.php index 3a3c5723a6..2dc97b00c3 100644 --- a/core/modules/node/tests/src/Functional/Views/NodeRevisionWizardTest.php +++ b/core/modules/node/tests/src/Functional/Views/NodeRevisionWizardTest.php @@ -19,7 +19,7 @@ class NodeRevisionWizardTest extends WizardTestBase { public function testViewAdd() { $this->drupalCreateContentType(['type' => 'article']); // Create two nodes with two revision. - $node_storage = \Drupal::entityManager()->getStorage('node'); + $node_storage = \Drupal::entityTypeManager()->getStorage('node'); /** @var \Drupal\node\NodeInterface $node */ $node = $node_storage->create(['title' => $this->randomString(), 'type' => 'article', 'changed' => REQUEST_TIME + 40]); $node->save(); diff --git a/core/modules/node/tests/src/Kernel/Migrate/d6/MigrateNodeTest.php b/core/modules/node/tests/src/Kernel/Migrate/d6/MigrateNodeTest.php index 997df83b52..c390af2db4 100644 --- a/core/modules/node/tests/src/Kernel/Migrate/d6/MigrateNodeTest.php +++ b/core/modules/node/tests/src/Kernel/Migrate/d6/MigrateNodeTest.php @@ -60,7 +60,7 @@ public function testNode() { $this->assertIdentical('1420861423', $node->getRevisionCreationTime()); /** @var \Drupal\node\NodeInterface $node_revision */ - $node_revision = \Drupal::entityManager()->getStorage('node')->loadRevision(1); + $node_revision = \Drupal::entityTypeManager()->getStorage('node')->loadRevision(1); $this->assertIdentical('Test title', $node_revision->getTitle()); $this->assertIdentical('1', $node_revision->getRevisionUser()->id(), 'Node revision has the correct user'); $this->assertSame('1', $node_revision->id(), 'Node 1 loaded.'); diff --git a/core/modules/node/tests/src/Kernel/Migrate/d7/MigrateNodeTest.php b/core/modules/node/tests/src/Kernel/Migrate/d7/MigrateNodeTest.php index 0e66006032..7caeb72427 100644 --- a/core/modules/node/tests/src/Kernel/Migrate/d7/MigrateNodeTest.php +++ b/core/modules/node/tests/src/Kernel/Migrate/d7/MigrateNodeTest.php @@ -131,7 +131,7 @@ protected function assertEntity($id, $type, $langcode, $title, $uid, $status, $c * The revision's time stamp. */ protected function assertRevision($id, $title, $uid, $log, $timestamp) { - $revision = \Drupal::entityManager()->getStorage('node')->loadRevision($id); + $revision = \Drupal::entityTypeManager()->getStorage('node')->loadRevision($id); $this->assertInstanceOf(NodeInterface::class, $revision); $this->assertEquals($title, $revision->getTitle()); $this->assertEquals($uid, $revision->getRevisionUser()->id()); diff --git a/core/modules/node/tests/src/Kernel/NodeFieldOverridesTest.php b/core/modules/node/tests/src/Kernel/NodeFieldOverridesTest.php index 1d781c6f56..1fdfea7202 100644 --- a/core/modules/node/tests/src/Kernel/NodeFieldOverridesTest.php +++ b/core/modules/node/tests/src/Kernel/NodeFieldOverridesTest.php @@ -50,7 +50,7 @@ public function testFieldOverrides() { if ($override) { $override->delete(); } - $uid_field = \Drupal::entityManager()->getBaseFieldDefinitions('node')['uid']; + $uid_field = \Drupal::service('entity_field.manager')->getBaseFieldDefinitions('node')['uid']; $config = $uid_field->getConfig('ponies'); $config->save(); $this->assertEquals($config->get('default_value_callback'), 'Drupal\node\Entity\Node::getDefaultEntityOwner'); diff --git a/core/modules/path/tests/src/Functional/PathLanguageTest.php b/core/modules/path/tests/src/Functional/PathLanguageTest.php index eae2661248..e943c91e57 100644 --- a/core/modules/path/tests/src/Functional/PathLanguageTest.php +++ b/core/modules/path/tests/src/Functional/PathLanguageTest.php @@ -62,7 +62,7 @@ protected function setUp() { ]; $this->drupalPostForm('admin/config/regional/content-language', $edit, t('Save configuration')); - $definitions = \Drupal::entityManager()->getFieldDefinitions('node', 'page'); + $definitions = \Drupal::service('entity_field.manager')->getFieldDefinitions('node', 'page'); $this->assertTrue($definitions['path']->isTranslatable(), 'Node path is translatable.'); $this->assertTrue($definitions['body']->isTranslatable(), 'Node body is translatable.'); } diff --git a/core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditLoadingTest.php b/core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditLoadingTest.php index 0ecd655a93..2e79ac61af 100644 --- a/core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditLoadingTest.php +++ b/core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditLoadingTest.php @@ -138,7 +138,7 @@ public function testUserPermissions() { $nid = $this->testNode->id(); // There should be only one revision so far. $node = Node::load($nid); - $vids = \Drupal::entityManager()->getStorage('node')->revisionIds($node); + $vids = \Drupal::entityTypeManager()->getStorage('node')->revisionIds($node); $this->assertCount(1, $vids, 'The node has only one revision.'); $original_log = $node->revision_log->value; @@ -164,7 +164,7 @@ public function testUserPermissions() { $assert->assertWaitOnAjaxRequest(); $node = Node::load($nid); - $vids = \Drupal::entityManager()->getStorage('node')->revisionIds($node); + $vids = \Drupal::entityTypeManager()->getStorage('node')->revisionIds($node); $this->assertCount(1, $vids, 'The node has only one revision.'); $this->assertSame($original_log, $node->revision_log->value, 'The revision log message is unchanged.'); diff --git a/core/modules/rdf/src/Entity/RdfMapping.php b/core/modules/rdf/src/Entity/RdfMapping.php index a4f268f812..e33f24a59a 100644 --- a/core/modules/rdf/src/Entity/RdfMapping.php +++ b/core/modules/rdf/src/Entity/RdfMapping.php @@ -145,7 +145,7 @@ public function calculateDependencies() { parent::calculateDependencies(); // Create dependency on the bundle. - $entity_type = \Drupal::entityManager()->getDefinition($this->targetEntityType); + $entity_type = \Drupal::entityTypeManager()->getDefinition($this->targetEntityType); $this->addDependency('module', $entity_type->getProvider()); $bundle_config_dependency = $entity_type->getBundleConfigDependency($this->bundle); $this->addDependency($bundle_config_dependency['type'], $bundle_config_dependency['name']); @@ -159,8 +159,8 @@ public function calculateDependencies() { public function postSave(EntityStorageInterface $storage, $update = TRUE) { parent::postSave($storage, $update); - if (\Drupal::entityManager()->hasHandler($this->targetEntityType, 'view_builder')) { - \Drupal::entityManager()->getViewBuilder($this->targetEntityType)->resetCache(); + if (\Drupal::entityTypeManager()->hasHandler($this->targetEntityType, 'view_builder')) { + \Drupal::entityTypeManager()->getViewBuilder($this->targetEntityType)->resetCache(); } } diff --git a/core/modules/responsive_image/src/FunctionalJavascript/ResponsiveImageFieldUiTest.php b/core/modules/responsive_image/src/FunctionalJavascript/ResponsiveImageFieldUiTest.php index e7e3f753a0..396ec10579 100644 --- a/core/modules/responsive_image/src/FunctionalJavascript/ResponsiveImageFieldUiTest.php +++ b/core/modules/responsive_image/src/FunctionalJavascript/ResponsiveImageFieldUiTest.php @@ -117,7 +117,7 @@ public function testResponsiveImageFormatterUi() { 'image_mapping' => 'large', ]) ->save(); - \Drupal::entityManager()->clearCachedFieldDefinitions(); + \Drupal::service('entity_field.manager')->clearCachedFieldDefinitions(); // Refresh the page. $this->drupalGet($manage_display); $assert_session->responseContains("Select a responsive image style."); diff --git a/core/modules/search/tests/src/Functional/SearchConfigSettingsFormTest.php b/core/modules/search/tests/src/Functional/SearchConfigSettingsFormTest.php index ac058bd064..24477afbcc 100644 --- a/core/modules/search/tests/src/Functional/SearchConfigSettingsFormTest.php +++ b/core/modules/search/tests/src/Functional/SearchConfigSettingsFormTest.php @@ -228,7 +228,7 @@ public function testDefaultSearchPageOrdering() { */ public function testMultipleSearchPages() { $this->assertDefaultSearch('node_search', 'The default page is set to the installer default.'); - $search_storage = \Drupal::entityManager()->getStorage('search_page'); + $search_storage = \Drupal::entityTypeManager()->getStorage('search_page'); $entities = $search_storage->loadMultiple(); $search_storage->delete($entities); $this->assertDefaultSearch(FALSE); diff --git a/core/modules/serialization/tests/src/Kernel/EntitySerializationTest.php b/core/modules/serialization/tests/src/Kernel/EntitySerializationTest.php index eff749805a..5cd9fa8f7d 100644 --- a/core/modules/serialization/tests/src/Kernel/EntitySerializationTest.php +++ b/core/modules/serialization/tests/src/Kernel/EntitySerializationTest.php @@ -88,7 +88,7 @@ protected function setUp() { ])->save(); // Create a test user to use as the entity owner. - $this->user = \Drupal::entityManager()->getStorage('user')->create([ + $this->user = \Drupal::entityTypeManager()->getStorage('user')->create([ 'name' => 'serialization_test_user', 'mail' => 'foo@example.com', 'pass' => '123456', diff --git a/core/modules/shortcut/shortcut.api.php b/core/modules/shortcut/shortcut.api.php index c60e456731..c5c609c38f 100644 --- a/core/modules/shortcut/shortcut.api.php +++ b/core/modules/shortcut/shortcut.api.php @@ -32,7 +32,7 @@ */ function hook_shortcut_default_set($account) { // Use a special set of default shortcuts for administrators only. - $roles = \Drupal::entityManager()->getStorage('user_role')->loadByProperties(['is_admin' => TRUE]); + $roles = \Drupal::entityTypeManager()->getStorage('user_role')->loadByProperties(['is_admin' => TRUE]); $user_admin_roles = array_intersect(array_keys($roles), $account->getRoles()); if ($user_admin_roles) { return 'admin-shortcuts'; diff --git a/core/modules/shortcut/shortcut.module b/core/modules/shortcut/shortcut.module index e242f8c52e..d0747cb242 100644 --- a/core/modules/shortcut/shortcut.module +++ b/core/modules/shortcut/shortcut.module @@ -123,10 +123,10 @@ function shortcut_set_switch_access($account = NULL) { * A user account that will be assigned to use the set. * * @deprecated in Drupal 8.x, will be removed before Drupal 9.0. - * Use \Drupal::entityManager()->getStorage('shortcut_set')->assignUser(). + * Use \Drupal::entityTypeManager()->getStorage('shortcut_set')->assignUser(). */ function shortcut_set_assign_user($shortcut_set, $account) { - \Drupal::entityManager() + \Drupal::entityTypeManager() ->getStorage('shortcut_set') ->assignUser($shortcut_set, $account); } @@ -145,10 +145,10 @@ function shortcut_set_assign_user($shortcut_set, $account) { * to any set. * * @deprecated in Drupal 8.x, will be removed before Drupal 9.0. - * Use \Drupal::entityManager()->getStorage('shortcut_set')->unassignUser(). + * Use \Drupal::entityTypeManager()->getStorage('shortcut_set')->unassignUser(). */ function shortcut_set_unassign_user($account) { - return (bool) \Drupal::entityManager() + return (bool) \Drupal::entityTypeManager() ->getStorage('shortcut_set') ->unassignUser($account); } @@ -177,7 +177,7 @@ function shortcut_current_displayed_set($account = NULL) { } // If none was found, try to find a shortcut set that is explicitly assigned // to this user. - $shortcut_set_name = \Drupal::entityManager() + $shortcut_set_name = \Drupal::entityTypeManager() ->getStorage('shortcut_set') ->getAssignedToUser($account); if ($shortcut_set_name) { @@ -325,7 +325,7 @@ function shortcut_preprocess_page_title(&$variables) { $shortcut_set = shortcut_current_displayed_set(); // Check if $link is already a shortcut and set $link_mode accordingly. - $shortcuts = \Drupal::entityManager()->getStorage('shortcut')->loadByProperties(['shortcut_set' => $shortcut_set->id()]); + $shortcuts = \Drupal::entityTypeManager()->getStorage('shortcut')->loadByProperties(['shortcut_set' => $shortcut_set->id()]); /** @var \Drupal\shortcut\ShortcutInterface $shortcut */ foreach ($shortcuts as $shortcut) { if (($shortcut_url = $shortcut->getUrl()) && $shortcut_url->isRouted() && $shortcut_url->getRouteName() == $route_match->getRouteName() && $shortcut_url->getRouteParameters() == $route_match->getRawParameters()->all()) { diff --git a/core/modules/shortcut/src/Entity/ShortcutSet.php b/core/modules/shortcut/src/Entity/ShortcutSet.php index 819f6475dd..fba28ac41e 100644 --- a/core/modules/shortcut/src/Entity/ShortcutSet.php +++ b/core/modules/shortcut/src/Entity/ShortcutSet.php @@ -100,7 +100,7 @@ public static function preDelete(EntityStorageInterface $storage, array $entitie ->condition('shortcut_set', $entity->id(), '=') ->execute(); - $controller = \Drupal::entityManager()->getStorage('shortcut'); + $controller = \Drupal::entityTypeManager()->getStorage('shortcut'); $entities = $controller->loadMultiple($shortcut_ids); $controller->delete($entities); } @@ -123,7 +123,7 @@ public function resetLinkWeights() { * {@inheritdoc} */ public function getShortcuts() { - $shortcuts = \Drupal::entityManager()->getStorage('shortcut')->loadByProperties(['shortcut_set' => $this->id()]); + $shortcuts = \Drupal::entityTypeManager()->getStorage('shortcut')->loadByProperties(['shortcut_set' => $this->id()]); uasort($shortcuts, ['\Drupal\shortcut\Entity\Shortcut', 'sort']); return $shortcuts; } diff --git a/core/modules/shortcut/src/Tests/ShortcutTestBase.php b/core/modules/shortcut/src/Tests/ShortcutTestBase.php index 584a6154c3..6f89201937 100644 --- a/core/modules/shortcut/src/Tests/ShortcutTestBase.php +++ b/core/modules/shortcut/src/Tests/ShortcutTestBase.php @@ -94,7 +94,7 @@ protected function setUp() { // Log in as admin and grab the default shortcut set. $this->drupalLogin($this->adminUser); $this->set = ShortcutSet::load('default'); - \Drupal::entityManager()->getStorage('shortcut_set')->assignUser($this->set, $this->adminUser); + \Drupal::entityTypeManager()->getStorage('shortcut_set')->assignUser($this->set, $this->adminUser); } /** @@ -125,7 +125,7 @@ public function generateShortcutSet($label = '', $id = NULL) { */ public function getShortcutInformation(ShortcutSetInterface $set, $key) { $info = []; - \Drupal::entityManager()->getStorage('shortcut')->resetCache(); + \Drupal::entityTypeManager()->getStorage('shortcut')->resetCache(); foreach ($set->getShortcuts() as $shortcut) { if ($key == 'link') { $info[] = $shortcut->link->uri; diff --git a/core/modules/shortcut/tests/src/Functional/ShortcutSetsTest.php b/core/modules/shortcut/tests/src/Functional/ShortcutSetsTest.php index b897df752d..636813cc8f 100644 --- a/core/modules/shortcut/tests/src/Functional/ShortcutSetsTest.php +++ b/core/modules/shortcut/tests/src/Functional/ShortcutSetsTest.php @@ -91,7 +91,7 @@ public function testShortcutSetEdit() { $this->drupalPostForm(NULL, $edit, t('Save')); $this->assertRaw(t('The shortcut set has been updated.')); - \Drupal::entityManager()->getStorage('shortcut')->resetCache(); + \Drupal::entityTypeManager()->getStorage('shortcut')->resetCache(); // Check to ensure that the shortcut weights have changed and that // ShortcutSet::.getShortcuts() returns shortcuts in the new order. $this->assertIdentical(array_reverse(array_keys($shortcuts)), array_keys($set->getShortcuts())); @@ -117,7 +117,7 @@ public function testShortcutSetSwitchOwn() { public function testShortcutSetAssign() { $new_set = $this->generateShortcutSet($this->randomMachineName()); - \Drupal::entityManager()->getStorage('shortcut_set')->assignUser($new_set, $this->shortcutUser); + \Drupal::entityTypeManager()->getStorage('shortcut_set')->assignUser($new_set, $this->shortcutUser); $current_set = shortcut_current_displayed_set($this->shortcutUser); $this->assertTrue($new_set->id() == $current_set->id(), "Successfully switched another user's shortcut set."); } @@ -169,7 +169,7 @@ public function testShortcutSetRename() { public function testShortcutSetUnassign() { $new_set = $this->generateShortcutSet($this->randomMachineName()); - $shortcut_set_storage = \Drupal::entityManager()->getStorage('shortcut_set'); + $shortcut_set_storage = \Drupal::entityTypeManager()->getStorage('shortcut_set'); $shortcut_set_storage->assignUser($new_set, $this->shortcutUser); $shortcut_set_storage->unassignUser($this->shortcutUser); $current_set = shortcut_current_displayed_set($this->shortcutUser); diff --git a/core/modules/shortcut/tests/src/Functional/ShortcutTestBase.php b/core/modules/shortcut/tests/src/Functional/ShortcutTestBase.php index 3f9cc87be3..c11c418ae9 100644 --- a/core/modules/shortcut/tests/src/Functional/ShortcutTestBase.php +++ b/core/modules/shortcut/tests/src/Functional/ShortcutTestBase.php @@ -87,7 +87,7 @@ protected function setUp() { // Log in as admin and grab the default shortcut set. $this->drupalLogin($this->adminUser); $this->set = ShortcutSet::load('default'); - \Drupal::entityManager()->getStorage('shortcut_set')->assignUser($this->set, $this->adminUser); + \Drupal::entityTypeManager()->getStorage('shortcut_set')->assignUser($this->set, $this->adminUser); } /** @@ -118,7 +118,7 @@ public function generateShortcutSet($label = '', $id = NULL) { */ public function getShortcutInformation(ShortcutSetInterface $set, $key) { $info = []; - \Drupal::entityManager()->getStorage('shortcut')->resetCache(); + \Drupal::entityTypeManager()->getStorage('shortcut')->resetCache(); foreach ($set->getShortcuts() as $shortcut) { if ($key == 'link') { $info[] = $shortcut->link->uri; diff --git a/core/modules/simpletest/src/Tests/KernelTestBaseTest.php b/core/modules/simpletest/src/Tests/KernelTestBaseTest.php index c92381fab8..d34ff91e6e 100644 --- a/core/modules/simpletest/src/Tests/KernelTestBaseTest.php +++ b/core/modules/simpletest/src/Tests/KernelTestBaseTest.php @@ -240,7 +240,7 @@ public function testInstallConfig() { public function testEnableModulesFixedList() { // Install system module. $this->container->get('module_installer')->install(['system', 'user', 'menu_link_content']); - $entity_manager = \Drupal::entityManager(); + $entity_manager = \Drupal::entityTypeManager(); // entity_test is loaded via $modules; its entity type should exist. $this->assertEqual($this->container->get('module_handler')->moduleExists('entity_test'), TRUE); diff --git a/core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php b/core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php index 92587b3628..4f0cf484b0 100644 --- a/core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php +++ b/core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php @@ -210,7 +210,7 @@ protected function getAdditionalCacheTagsForEntityListing() { * chooses 'default'. */ protected function selectViewMode($entity_type) { - $view_modes = \Drupal::entityManager() + $view_modes = \Drupal::entityTypeManager() ->getStorage('entity_view_mode') ->loadByProperties(['targetEntityType' => $entity_type]); @@ -292,7 +292,7 @@ protected function createReferenceTestEntities($referenced_entity) { } // Create an entity that does reference the entity being tested. - $label_key = \Drupal::entityManager()->getDefinition($entity_type)->getKey('label'); + $label_key = \Drupal::entityTypeManager()->getDefinition($entity_type)->getKey('label'); $referencing_entity = $this->container->get('entity_type.manager') ->getStorage($entity_type) ->create([ @@ -359,7 +359,7 @@ public function testReferencedEntity() { $view_cache_tag = []; if ($this->entity->getEntityType()->hasHandlerClass('view_builder')) { - $view_cache_tag = \Drupal::entityManager()->getViewBuilder($entity_type) + $view_cache_tag = \Drupal::entityTypeManager()->getViewBuilder($entity_type) ->getCacheTags(); } @@ -367,7 +367,7 @@ public function testReferencedEntity() { $cache_context_tags = $context_metadata->getCacheTags(); // Generate the cache tags for the (non) referencing entities. - $referencing_entity_cache_tags = Cache::mergeTags($this->referencingEntity->getCacheTags(), \Drupal::entityManager()->getViewBuilder('entity_test')->getCacheTags()); + $referencing_entity_cache_tags = Cache::mergeTags($this->referencingEntity->getCacheTags(), \Drupal::entityTypeManager()->getViewBuilder('entity_test')->getCacheTags()); // Includes the main entity's cache tags, since this entity references it. $referencing_entity_cache_tags = Cache::mergeTags($referencing_entity_cache_tags, $this->entity->getCacheTags()); $referencing_entity_cache_tags = Cache::mergeTags($referencing_entity_cache_tags, $this->getAdditionalCacheTagsForEntity($this->entity)); @@ -375,7 +375,7 @@ public function testReferencedEntity() { $referencing_entity_cache_tags = Cache::mergeTags($referencing_entity_cache_tags, $cache_context_tags); $referencing_entity_cache_tags = Cache::mergeTags($referencing_entity_cache_tags, ['rendered']); - $non_referencing_entity_cache_tags = Cache::mergeTags($this->nonReferencingEntity->getCacheTags(), \Drupal::entityManager()->getViewBuilder('entity_test')->getCacheTags()); + $non_referencing_entity_cache_tags = Cache::mergeTags($this->nonReferencingEntity->getCacheTags(), \Drupal::entityTypeManager()->getViewBuilder('entity_test')->getCacheTags()); $non_referencing_entity_cache_tags = Cache::mergeTags($non_referencing_entity_cache_tags, ['rendered']); // Generate the cache tags for all two possible entity listing paths. @@ -636,7 +636,7 @@ public function testReferencedEntity() { $this->verifyPageCache($non_referencing_entity_url, 'HIT'); // Verify cache hits. - $referencing_entity_cache_tags = Cache::mergeTags($this->referencingEntity->getCacheTags(), \Drupal::entityManager()->getViewBuilder('entity_test')->getCacheTags()); + $referencing_entity_cache_tags = Cache::mergeTags($this->referencingEntity->getCacheTags(), \Drupal::entityTypeManager()->getViewBuilder('entity_test')->getCacheTags()); $referencing_entity_cache_tags = Cache::mergeTags($referencing_entity_cache_tags, ['http_response', 'rendered']); $nonempty_entity_listing_cache_tags = Cache::mergeTags($this->entity->getEntityType()->getListCacheTags(), $this->getAdditionalCacheTagsForEntityListing()); diff --git a/core/modules/system/src/Tests/Entity/EntityWithUriCacheTagsTestBase.php b/core/modules/system/src/Tests/Entity/EntityWithUriCacheTagsTestBase.php index 69b35028a7..381f039cc4 100644 --- a/core/modules/system/src/Tests/Entity/EntityWithUriCacheTagsTestBase.php +++ b/core/modules/system/src/Tests/Entity/EntityWithUriCacheTagsTestBase.php @@ -38,7 +38,7 @@ public function testEntityUri() { // Generate the standardized entity cache tags. $cache_tag = $this->entity->getCacheTags(); - $view_cache_tag = \Drupal::entityManager()->getViewBuilder($entity_type)->getCacheTags(); + $view_cache_tag = \Drupal::entityTypeManager()->getViewBuilder($entity_type)->getCacheTags(); $render_cache_tag = 'rendered'; $this->pass("Test entity.", 'Debug'); @@ -49,7 +49,7 @@ public function testEntityUri() { // Also verify the existence of an entity render cache entry, if this entity // type supports render caching. - if (\Drupal::entityManager()->getDefinition($entity_type)->isRenderCacheable()) { + if (\Drupal::entityTypeManager()->getDefinition($entity_type)->isRenderCacheable()) { $cache_keys = ['entity_view', $entity_type, $this->entity->id(), $view_mode]; $cid = $this->createCacheId($cache_keys, $entity_cache_contexts); $redirected_cid = NULL; diff --git a/core/modules/system/system.install b/core/modules/system/system.install index 5c40677e4c..5299abf719 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -762,7 +762,7 @@ function system_requirements($phase) { if ($change_list = \Drupal::entityDefinitionUpdateManager()->getChangeSummary()) { $build = []; foreach ($change_list as $entity_type_id => $changes) { - $entity_type = \Drupal::entityManager()->getDefinition($entity_type_id); + $entity_type = \Drupal::entityTypeManager()->getDefinition($entity_type_id); $build[] = [ '#theme' => 'item_list', '#title' => $entity_type->getLabel(), @@ -1330,7 +1330,7 @@ function system_update_8004() { // https://www.drupal.org/node/2542748. Regenerate the related schemas to // ensure they match the currently expected status. $manager = \Drupal::entityDefinitionUpdateManager(); - foreach (array_keys(\Drupal::entityManager() + foreach (array_keys(\Drupal::entityTypeManager() ->getDefinitions()) as $entity_type_id) { // Only update the entity type if it already exists. This condition is // needed in case new entity types are introduced after this update. @@ -1591,7 +1591,7 @@ function _system_update_create_block($name, $theme_name, array $values) { function system_update_8007() { $database = \Drupal::database(); $database_schema = $database->schema(); - $entity_types = \Drupal::entityManager()->getDefinitions(); + $entity_types = \Drupal::entityTypeManager()->getDefinitions(); $schema = \Drupal::keyValue('entity.storage_schema.sql')->getAll(); $schema_copy = $schema; @@ -1649,7 +1649,7 @@ function system_update_8007() { * Purge field schema data for uninstalled entity types. */ function system_update_8008() { - $entity_types = \Drupal::entityManager()->getDefinitions(); + $entity_types = \Drupal::entityTypeManager()->getDefinitions(); /** @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface $schema */ $schema = \Drupal::keyValue('entity.storage_schema.sql'); foreach ($schema->getAll() as $key => $item) { diff --git a/core/modules/system/tests/modules/entity_test/entity_test.module b/core/modules/system/tests/modules/entity_test/entity_test.module index 6eb738f6d4..4f73639240 100644 --- a/core/modules/system/tests/modules/entity_test/entity_test.module +++ b/core/modules/system/tests/modules/entity_test/entity_test.module @@ -217,7 +217,7 @@ function entity_test_delete_bundle($bundle, $entity_type = 'entity_test') { */ function entity_test_entity_bundle_info() { $bundles = []; - $entity_types = \Drupal::entityManager()->getDefinitions(); + $entity_types = \Drupal::entityTypeManager()->getDefinitions(); foreach ($entity_types as $entity_type_id => $entity_type) { if ($entity_type->getProvider() == 'entity_test' && $entity_type_id != 'entity_test_with_bundle') { $bundles[$entity_type_id] = \Drupal::state()->get($entity_type_id . '.bundles') ?: [$entity_type_id => ['label' => 'Entity Test Bundle']]; @@ -250,7 +250,7 @@ function entity_test_entity_bundle_info_alter(&$bundles) { * Implements hook_entity_view_mode_info_alter(). */ function entity_test_entity_view_mode_info_alter(&$view_modes) { - $entity_info = \Drupal::entityManager()->getDefinitions(); + $entity_info = \Drupal::entityTypeManager()->getDefinitions(); foreach ($entity_info as $entity_type => $info) { if ($entity_info[$entity_type]->getProvider() == 'entity_test' && !isset($view_modes[$entity_type])) { $view_modes[$entity_type] = [ @@ -273,7 +273,7 @@ function entity_test_entity_view_mode_info_alter(&$view_modes) { * Implements hook_entity_form_mode_info_alter(). */ function entity_test_entity_form_mode_info_alter(&$form_modes) { - $entity_info = \Drupal::entityManager()->getDefinitions(); + $entity_info = \Drupal::entityTypeManager()->getDefinitions(); foreach ($entity_info as $entity_type => $info) { if ($entity_info[$entity_type]->getProvider() == 'entity_test') { $form_modes[$entity_type] = [ diff --git a/core/modules/system/tests/src/Functional/Datetime/DrupalDateTimeTest.php b/core/modules/system/tests/src/Functional/Datetime/DrupalDateTimeTest.php index 488fa6ef42..6843e54f75 100644 --- a/core/modules/system/tests/src/Functional/Datetime/DrupalDateTimeTest.php +++ b/core/modules/system/tests/src/Functional/Datetime/DrupalDateTimeTest.php @@ -88,7 +88,7 @@ public function testDateTimezone() { $this->drupalPostForm('user/' . $test_user->id() . '/edit', $edit, t('Save')); // Reload the user and reset the timezone in AccountProxy::setAccount(). - \Drupal::entityManager()->getStorage('user')->resetCache(); + \Drupal::entityTypeManager()->getStorage('user')->resetCache(); $this->container->get('current_user')->setAccount(User::load($test_user->id())); // Create a date object with an unspecified timezone, which should diff --git a/core/modules/system/tests/src/Functional/Entity/EntityCacheTagsTestBase.php b/core/modules/system/tests/src/Functional/Entity/EntityCacheTagsTestBase.php index 36d8d0670f..d7c20544b9 100644 --- a/core/modules/system/tests/src/Functional/Entity/EntityCacheTagsTestBase.php +++ b/core/modules/system/tests/src/Functional/Entity/EntityCacheTagsTestBase.php @@ -203,7 +203,7 @@ protected function getAdditionalCacheTagsForEntityListing() { * chooses 'default'. */ protected function selectViewMode($entity_type) { - $view_modes = \Drupal::entityManager() + $view_modes = \Drupal::entityTypeManager() ->getStorage('entity_view_mode') ->loadByProperties(['targetEntityType' => $entity_type]); @@ -285,7 +285,7 @@ protected function createReferenceTestEntities($referenced_entity) { } // Create an entity that does reference the entity being tested. - $label_key = \Drupal::entityManager()->getDefinition($entity_type)->getKey('label'); + $label_key = \Drupal::entityTypeManager()->getDefinition($entity_type)->getKey('label'); $referencing_entity = $this->container->get('entity_type.manager') ->getStorage($entity_type) ->create([ @@ -352,7 +352,7 @@ public function testReferencedEntity() { $view_cache_tag = []; if ($this->entity->getEntityType()->hasHandlerClass('view_builder')) { - $view_cache_tag = \Drupal::entityManager()->getViewBuilder($entity_type) + $view_cache_tag = \Drupal::entityTypeManager()->getViewBuilder($entity_type) ->getCacheTags(); } @@ -360,7 +360,7 @@ public function testReferencedEntity() { $cache_context_tags = $context_metadata->getCacheTags(); // Generate the cache tags for the (non) referencing entities. - $referencing_entity_cache_tags = Cache::mergeTags($this->referencingEntity->getCacheTags(), \Drupal::entityManager()->getViewBuilder('entity_test')->getCacheTags()); + $referencing_entity_cache_tags = Cache::mergeTags($this->referencingEntity->getCacheTags(), \Drupal::entityTypeManager()->getViewBuilder('entity_test')->getCacheTags()); // Includes the main entity's cache tags, since this entity references it. $referencing_entity_cache_tags = Cache::mergeTags($referencing_entity_cache_tags, $this->entity->getCacheTags()); $referencing_entity_cache_tags = Cache::mergeTags($referencing_entity_cache_tags, $this->getAdditionalCacheTagsForEntity($this->entity)); @@ -368,7 +368,7 @@ public function testReferencedEntity() { $referencing_entity_cache_tags = Cache::mergeTags($referencing_entity_cache_tags, $cache_context_tags); $referencing_entity_cache_tags = Cache::mergeTags($referencing_entity_cache_tags, ['rendered']); - $non_referencing_entity_cache_tags = Cache::mergeTags($this->nonReferencingEntity->getCacheTags(), \Drupal::entityManager()->getViewBuilder('entity_test')->getCacheTags()); + $non_referencing_entity_cache_tags = Cache::mergeTags($this->nonReferencingEntity->getCacheTags(), \Drupal::entityTypeManager()->getViewBuilder('entity_test')->getCacheTags()); $non_referencing_entity_cache_tags = Cache::mergeTags($non_referencing_entity_cache_tags, ['rendered']); // Generate the cache tags for all two possible entity listing paths. @@ -629,7 +629,7 @@ public function testReferencedEntity() { $this->verifyPageCache($non_referencing_entity_url, 'HIT'); // Verify cache hits. - $referencing_entity_cache_tags = Cache::mergeTags($this->referencingEntity->getCacheTags(), \Drupal::entityManager()->getViewBuilder('entity_test')->getCacheTags()); + $referencing_entity_cache_tags = Cache::mergeTags($this->referencingEntity->getCacheTags(), \Drupal::entityTypeManager()->getViewBuilder('entity_test')->getCacheTags()); $referencing_entity_cache_tags = Cache::mergeTags($referencing_entity_cache_tags, ['http_response', 'rendered']); $nonempty_entity_listing_cache_tags = Cache::mergeTags($this->entity->getEntityType()->getListCacheTags(), $this->getAdditionalCacheTagsForEntityListing()); diff --git a/core/modules/system/tests/src/Functional/Entity/EntityWithUriCacheTagsTestBase.php b/core/modules/system/tests/src/Functional/Entity/EntityWithUriCacheTagsTestBase.php index 27f896b9a6..d5a3f94a1c 100644 --- a/core/modules/system/tests/src/Functional/Entity/EntityWithUriCacheTagsTestBase.php +++ b/core/modules/system/tests/src/Functional/Entity/EntityWithUriCacheTagsTestBase.php @@ -31,7 +31,7 @@ public function testEntityUri() { // Generate the standardized entity cache tags. $cache_tag = $this->entity->getCacheTags(); - $view_cache_tag = \Drupal::entityManager()->getViewBuilder($entity_type)->getCacheTags(); + $view_cache_tag = \Drupal::entityTypeManager()->getViewBuilder($entity_type)->getCacheTags(); $render_cache_tag = 'rendered'; $this->pass("Test entity.", 'Debug'); @@ -42,7 +42,7 @@ public function testEntityUri() { // Also verify the existence of an entity render cache entry, if this entity // type supports render caching. - if (\Drupal::entityManager()->getDefinition($entity_type)->isRenderCacheable()) { + if (\Drupal::entityTypeManager()->getDefinition($entity_type)->isRenderCacheable()) { $cache_keys = ['entity_view', $entity_type, $this->entity->id(), $view_mode]; $cid = $this->createCacheId($cache_keys, $entity_cache_contexts); $redirected_cid = NULL; diff --git a/core/modules/system/tests/src/Functional/Menu/LocalTasksTest.php b/core/modules/system/tests/src/Functional/Menu/LocalTasksTest.php index 1a49336777..fc6e8c1ac0 100644 --- a/core/modules/system/tests/src/Functional/Menu/LocalTasksTest.php +++ b/core/modules/system/tests/src/Functional/Menu/LocalTasksTest.php @@ -176,7 +176,7 @@ public function testPluginLocalTask() { // Test that we we correctly apply the active class to tabs where one of the // request attributes is upcast to an entity object. - $entity = \Drupal::entityManager()->getStorage('entity_test')->create(['bundle' => 'test']); + $entity = \Drupal::entityTypeManager()->getStorage('entity_test')->create(['bundle' => 'test']); $entity->save(); $this->drupalGet(Url::fromRoute('menu_test.local_task_test_upcasting_sub1', ['entity_test' => '1'])); diff --git a/core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php b/core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php index d1f6be457f..bcdf8ea33d 100644 --- a/core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php +++ b/core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php @@ -352,7 +352,7 @@ protected function preUninstallForum() { $query = \Drupal::entityQuery('taxonomy_term'); $query->condition('vid', 'forums'); $ids = $query->execute(); - $storage = \Drupal::entityManager()->getStorage('taxonomy_term'); + $storage = \Drupal::entityTypeManager()->getStorage('taxonomy_term'); $terms = $storage->loadMultiple($ids); $storage->delete($terms); } diff --git a/core/modules/system/tests/src/Functional/Module/UninstallTest.php b/core/modules/system/tests/src/Functional/Module/UninstallTest.php index 98b96ee91e..d061646f7e 100644 --- a/core/modules/system/tests/src/Functional/Module/UninstallTest.php +++ b/core/modules/system/tests/src/Functional/Module/UninstallTest.php @@ -104,7 +104,7 @@ public function testUninstallPage() { } $entity_types = array_unique($entity_types); foreach ($entity_types as $entity_type_id) { - $entity_type = \Drupal::entityManager()->getDefinition($entity_type_id); + $entity_type = \Drupal::entityTypeManager()->getDefinition($entity_type_id); // Add h3's since the entity type label is often repeated in the entity // labels. $this->assertRaw('

' . $entity_type->getLabel() . '

'); diff --git a/core/modules/system/tests/src/Functional/System/DateTimeTest.php b/core/modules/system/tests/src/Functional/System/DateTimeTest.php index bdecab5d4c..347afda414 100644 --- a/core/modules/system/tests/src/Functional/System/DateTimeTest.php +++ b/core/modules/system/tests/src/Functional/System/DateTimeTest.php @@ -64,7 +64,7 @@ public function testTimeZoneHandling() { // Set time zone to Los Angeles time. $config->set('timezone.default', 'America/Los_Angeles')->save(); - \Drupal::entityManager()->getViewBuilder('node')->resetCache([$node1, $node2]); + \Drupal::entityTypeManager()->getViewBuilder('node')->resetCache([$node1, $node2]); // Confirm date format and time zone. $this->drupalGet('node/' . $node1->id()); diff --git a/core/modules/system/tests/src/Functional/Update/LocalActionsAndTasksConvertedIntoBlocksUpdateTest.php b/core/modules/system/tests/src/Functional/Update/LocalActionsAndTasksConvertedIntoBlocksUpdateTest.php index cfa8221040..ff4075e9e6 100644 --- a/core/modules/system/tests/src/Functional/Update/LocalActionsAndTasksConvertedIntoBlocksUpdateTest.php +++ b/core/modules/system/tests/src/Functional/Update/LocalActionsAndTasksConvertedIntoBlocksUpdateTest.php @@ -42,7 +42,7 @@ public function testUpdateHookN() { $this->runUpdates(); /** @var \Drupal\block\BlockInterface $block_storage */ - $block_storage = \Drupal::entityManager()->getStorage('block'); + $block_storage = \Drupal::entityTypeManager()->getStorage('block'); /* @var \Drupal\block\BlockInterface[] $help_blocks */ $help_blocks = $block_storage->loadByProperties(['theme' => 'bartik', 'region' => 'help']); diff --git a/core/modules/system/tests/src/Functional/Update/PageTitleConvertedIntoBlockUpdateTest.php b/core/modules/system/tests/src/Functional/Update/PageTitleConvertedIntoBlockUpdateTest.php index c9c264c96b..6e17506220 100644 --- a/core/modules/system/tests/src/Functional/Update/PageTitleConvertedIntoBlockUpdateTest.php +++ b/core/modules/system/tests/src/Functional/Update/PageTitleConvertedIntoBlockUpdateTest.php @@ -43,7 +43,7 @@ public function testUpdateHookN() { $this->runUpdates(); /** @var \Drupal\block\BlockInterface $block_storage */ - $block_storage = \Drupal::entityManager()->getStorage('block'); + $block_storage = \Drupal::entityTypeManager()->getStorage('block'); $this->assertRaw('Because your site has custom theme(s) installed, we have placed the page title block in the content region. Please manually review the block configuration and remove the page title variables from your page templates.'); diff --git a/core/modules/system/tests/src/Functional/Update/SevenSecondaryLocalTasksConvertedIntoBlockUpdateTest.php b/core/modules/system/tests/src/Functional/Update/SevenSecondaryLocalTasksConvertedIntoBlockUpdateTest.php index 172897497d..b0a58623a5 100644 --- a/core/modules/system/tests/src/Functional/Update/SevenSecondaryLocalTasksConvertedIntoBlockUpdateTest.php +++ b/core/modules/system/tests/src/Functional/Update/SevenSecondaryLocalTasksConvertedIntoBlockUpdateTest.php @@ -41,7 +41,7 @@ public function testUpdateHookN() { $this->runUpdates(); /** @var \Drupal\block\BlockInterface $block_storage */ - $block_storage = \Drupal::entityManager()->getStorage('block'); + $block_storage = \Drupal::entityTypeManager()->getStorage('block'); // Disable maintenance mode. // @todo Can be removed once maintenance mode is automatically turned off diff --git a/core/modules/system/tests/src/Functional/Update/SiteBrandingConvertedIntoBlockUpdateTest.php b/core/modules/system/tests/src/Functional/Update/SiteBrandingConvertedIntoBlockUpdateTest.php index 72f3a27824..56b988e956 100644 --- a/core/modules/system/tests/src/Functional/Update/SiteBrandingConvertedIntoBlockUpdateTest.php +++ b/core/modules/system/tests/src/Functional/Update/SiteBrandingConvertedIntoBlockUpdateTest.php @@ -39,7 +39,7 @@ public function testUpdateHookN() { $this->runUpdates(); /** @var \Drupal\block\BlockInterface $block_storage */ - $block_storage = \Drupal::entityManager()->getStorage('block'); + $block_storage = \Drupal::entityTypeManager()->getStorage('block'); $this->assertRaw('Because your site has custom theme(s) installed, we had to set the branding block into the content region. Please manually review the block configuration and remove the site name, slogan, and logo variables from your templates.'); diff --git a/core/modules/system/tests/src/Functional/Update/UpdatePathRC1TestBaseTest.php b/core/modules/system/tests/src/Functional/Update/UpdatePathRC1TestBaseTest.php index da53ba6e63..af2552492a 100644 --- a/core/modules/system/tests/src/Functional/Update/UpdatePathRC1TestBaseTest.php +++ b/core/modules/system/tests/src/Functional/Update/UpdatePathRC1TestBaseTest.php @@ -62,7 +62,7 @@ public function testDatabaseLoaded() { $this->assertText('Site-Install'); $extensions = \Drupal::service('config.storage')->read('core.extension'); $this->assertTrue(isset($extensions['theme']['stable']), 'Stable is installed after updating.'); - $blocks = \Drupal::entityManager()->getStorage('block')->loadByProperties(['theme' => 'stable']); + $blocks = \Drupal::entityTypeManager()->getStorage('block')->loadByProperties(['theme' => 'stable']); $this->assertTrue(empty($blocks), 'No blocks have been placed for Stable.'); } diff --git a/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php b/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php index 976032e050..63229a9139 100644 --- a/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php +++ b/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php @@ -269,7 +269,7 @@ public function testUninstallContentDependency() { $this->assertTrue($this->moduleHandler()->moduleExists('module_test'), 'Test module is enabled.'); $this->installSchema('user', 'users_data'); - $entity_types = \Drupal::entityManager()->getDefinitions(); + $entity_types = \Drupal::entityTypeManager()->getDefinitions(); foreach ($entity_types as $entity_type) { if ('entity_test' == $entity_type->getProvider()) { $this->installEntitySchema($entity_type->id()); diff --git a/core/modules/taxonomy/src/Plugin/views/field/TaxonomyIndexTid.php b/core/modules/taxonomy/src/Plugin/views/field/TaxonomyIndexTid.php index 785629e1fe..7dda500d7c 100644 --- a/core/modules/taxonomy/src/Plugin/views/field/TaxonomyIndexTid.php +++ b/core/modules/taxonomy/src/Plugin/views/field/TaxonomyIndexTid.php @@ -139,7 +139,7 @@ public function preRender(&$values) { if (empty($this->options['limit'])) { $vocabs = []; } - $result = \Drupal::entityManager()->getStorage('taxonomy_term')->getNodeTerms($nids, $vocabs); + $result = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->getNodeTerms($nids, $vocabs); foreach ($result as $node_nid => $data) { foreach ($data as $tid => $term) { diff --git a/core/modules/taxonomy/src/Tests/TaxonomyTranslationTestTrait.php b/core/modules/taxonomy/src/Tests/TaxonomyTranslationTestTrait.php index 84e4a0b01b..debad0e208 100644 --- a/core/modules/taxonomy/src/Tests/TaxonomyTranslationTestTrait.php +++ b/core/modules/taxonomy/src/Tests/TaxonomyTranslationTestTrait.php @@ -71,7 +71,7 @@ protected function enableTranslation() { \Drupal::service('content_translation.manager')->setEnabled('node', 'article', TRUE); \Drupal::service('content_translation.manager')->setEnabled('taxonomy_term', $this->vocabulary->id(), TRUE); drupal_static_reset(); - \Drupal::entityManager()->clearCachedDefinitions(); + \Drupal::entityTypeManager()->clearCachedDefinitions(); \Drupal::service('router.builder')->rebuild(); } diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module index 1d724c2535..c94732f7c9 100644 --- a/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -271,7 +271,7 @@ function taxonomy_term_is_page(Term $term) { * Clear all static cache variables for terms. */ function taxonomy_terms_static_reset() { - \Drupal::entityManager()->getStorage('taxonomy_term')->resetCache(); + \Drupal::entityTypeManager()->getStorage('taxonomy_term')->resetCache(); } /** @@ -281,7 +281,7 @@ function taxonomy_terms_static_reset() { * An array of ids to reset in the entity cache. */ function taxonomy_vocabulary_static_reset(array $ids = NULL) { - \Drupal::entityManager()->getStorage('taxonomy_vocabulary')->resetCache($ids); + \Drupal::entityTypeManager()->getStorage('taxonomy_vocabulary')->resetCache($ids); } /** @@ -495,7 +495,7 @@ function taxonomy_node_insert(EntityInterface $node) { function taxonomy_build_node_index($node) { // We maintain a denormalized table of term/node relationships, containing // only data for current, published nodes. - if (!\Drupal::config('taxonomy.settings')->get('maintain_index_table') || !(\Drupal::entityManager()->getStorage('node') instanceof SqlContentEntityStorage)) { + if (!\Drupal::config('taxonomy.settings')->get('maintain_index_table') || !(\Drupal::entityTypeManager()->getStorage('node') instanceof SqlContentEntityStorage)) { return; } diff --git a/core/modules/taxonomy/taxonomy.tokens.inc b/core/modules/taxonomy/taxonomy.tokens.inc index b6931b7cbb..39d7da5e14 100644 --- a/core/modules/taxonomy/taxonomy.tokens.inc +++ b/core/modules/taxonomy/taxonomy.tokens.inc @@ -95,7 +95,7 @@ function taxonomy_tokens($type, $tokens, array $data, array $options, Bubbleable $token_service = \Drupal::token(); $replacements = []; - $taxonomy_storage = \Drupal::entityManager()->getStorage('taxonomy_term'); + $taxonomy_storage = \Drupal::entityTypeManager()->getStorage('taxonomy_term'); if ($type == 'term' && !empty($data['term'])) { $term = $data['term']; diff --git a/core/modules/taxonomy/tests/src/Functional/TaxonomyQueryAlterTest.php b/core/modules/taxonomy/tests/src/Functional/TaxonomyQueryAlterTest.php index 0958df3e5d..7ff8316391 100644 --- a/core/modules/taxonomy/tests/src/Functional/TaxonomyQueryAlterTest.php +++ b/core/modules/taxonomy/tests/src/Functional/TaxonomyQueryAlterTest.php @@ -36,7 +36,7 @@ public function testTaxonomyQueryAlter() { $terms[2]->parent = $terms[1]->id(); $terms[2]->save(); - $term_storage = \Drupal::entityManager()->getStorage('taxonomy_term'); + $term_storage = \Drupal::entityTypeManager()->getStorage('taxonomy_term'); $this->setupQueryTagTestHooks(); $loaded_term = $term_storage->load($terms[0]->id()); diff --git a/core/modules/taxonomy/tests/src/Functional/TaxonomyTermIndentationTest.php b/core/modules/taxonomy/tests/src/Functional/TaxonomyTermIndentationTest.php index c701dfeeba..eb57142c87 100644 --- a/core/modules/taxonomy/tests/src/Functional/TaxonomyTermIndentationTest.php +++ b/core/modules/taxonomy/tests/src/Functional/TaxonomyTermIndentationTest.php @@ -87,7 +87,7 @@ public function testTermIndentation() { $this->assertSession()->responseNotMatches('|
 
|'); // Check explicitly that term 2 has no parents. - \Drupal::entityManager()->getStorage('taxonomy_term')->resetCache(); + \Drupal::entityTypeManager()->getStorage('taxonomy_term')->resetCache(); $parents = $taxonomy_storage->loadParents($term2->id()); $this->assertTrue(empty($parents), 'Term 2 has no parents now'); } diff --git a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTaxonomyTermTest.php b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTaxonomyTermTest.php index 20ecb63903..6eb3ed1ea4 100644 --- a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTaxonomyTermTest.php +++ b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTaxonomyTermTest.php @@ -96,7 +96,7 @@ public function testTaxonomyTerms() { } else { $parents = []; - foreach (\Drupal::entityManager()->getStorage('taxonomy_term')->loadParents($tid) as $parent) { + foreach (\Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadParents($tid) as $parent) { $parents[] = (int) $parent->id(); } $this->assertSame($parents, $values['parent']); diff --git a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTermNodeRevisionTest.php b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTermNodeRevisionTest.php index 25544486ab..3fd755440a 100644 --- a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTermNodeRevisionTest.php +++ b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTermNodeRevisionTest.php @@ -31,7 +31,7 @@ protected function setUp() { * Tests the Drupal 6 term-node revision association to Drupal 8 migration. */ public function testTermRevisionNode() { - $node = \Drupal::entityManager()->getStorage('node')->loadRevision(2001); + $node = \Drupal::entityTypeManager()->getStorage('node')->loadRevision(2001); $this->assertSame(2, count($node->field_vocabulary_3_i_2_)); $this->assertSame('4', $node->field_vocabulary_3_i_2_[0]->target_id); $this->assertSame('5', $node->field_vocabulary_3_i_2_[1]->target_id); diff --git a/core/modules/taxonomy/tests/src/Kernel/Migrate/d7/MigrateTaxonomyTermTest.php b/core/modules/taxonomy/tests/src/Kernel/Migrate/d7/MigrateTaxonomyTermTest.php index c5da7790a5..758ed47df5 100644 --- a/core/modules/taxonomy/tests/src/Kernel/Migrate/d7/MigrateTaxonomyTermTest.php +++ b/core/modules/taxonomy/tests/src/Kernel/Migrate/d7/MigrateTaxonomyTermTest.php @@ -138,7 +138,7 @@ public function testTaxonomyTerms() { * List of parent term IDs. */ protected function getParentIDs($tid) { - return array_keys(\Drupal::entityManager()->getStorage('taxonomy_term')->loadParents($tid)); + return array_keys(\Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadParents($tid)); } /** diff --git a/core/modules/taxonomy/tests/src/Kernel/TermKernelTest.php b/core/modules/taxonomy/tests/src/Kernel/TermKernelTest.php index 3d8bff80a3..7cc0dcffe8 100644 --- a/core/modules/taxonomy/tests/src/Kernel/TermKernelTest.php +++ b/core/modules/taxonomy/tests/src/Kernel/TermKernelTest.php @@ -131,7 +131,7 @@ public function testTaxonomyVocabularyTree() { $this->assertEqual(1, $depth_count[3], 'One element in taxonomy tree depth 3.'); /** @var \Drupal\taxonomy\TermStorageInterface $storage */ - $storage = \Drupal::entityManager()->getStorage('taxonomy_term'); + $storage = \Drupal::entityTypeManager()->getStorage('taxonomy_term'); // Count parents of $term[2]. $parents = $storage->loadParents($term[2]->id()); $this->assertEqual(2, count($parents), 'The term has two parents.'); diff --git a/core/modules/tracker/tracker.pages.inc b/core/modules/tracker/tracker.pages.inc index 507f14b64e..575c31bae0 100644 --- a/core/modules/tracker/tracker.pages.inc +++ b/core/modules/tracker/tracker.pages.inc @@ -124,7 +124,7 @@ function tracker_page($account = NULL) { } // Add the list cache tag for nodes. - $cache_tags = Cache::mergeTags($cache_tags, \Drupal::entityManager()->getDefinition('node')->getListCacheTags()); + $cache_tags = Cache::mergeTags($cache_tags, \Drupal::entityTypeManager()->getDefinition('node')->getListCacheTags()); $page['tracker'] = [ '#rows' => $rows, diff --git a/core/modules/user/src/Entity/User.php b/core/modules/user/src/Entity/User.php index ebb1134128..8ed8dfdac8 100644 --- a/core/modules/user/src/Entity/User.php +++ b/core/modules/user/src/Entity/User.php @@ -420,8 +420,8 @@ public static function getAnonymousUser() { // @todo Use the entity factory once available, see // https://www.drupal.org/node/1867228. - $entity_manager = \Drupal::entityManager(); - $entity_type = $entity_manager->getDefinition('user'); + $entity_type_manager = \Drupal::entityTypeManager(); + $entity_type = $entity_type_manager->getDefinition('user'); $class = $entity_type->getClass(); static::$anonymousUser = new $class([ @@ -557,7 +557,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { * The role storage object. */ protected function getRoleStorage() { - return \Drupal::entityManager()->getStorage('user_role'); + return \Drupal::entityTypeManager()->getStorage('user_role'); } /** diff --git a/core/modules/user/src/Plugin/Validation/Constraint/UserMailRequiredValidator.php b/core/modules/user/src/Plugin/Validation/Constraint/UserMailRequiredValidator.php index 7e20b7a8c8..4a03179deb 100644 --- a/core/modules/user/src/Plugin/Validation/Constraint/UserMailRequiredValidator.php +++ b/core/modules/user/src/Plugin/Validation/Constraint/UserMailRequiredValidator.php @@ -23,7 +23,7 @@ public function validate($items, Constraint $constraint) { $account = $items->getEntity(); $existing_value = NULL; if ($account->id()) { - $account_unchanged = \Drupal::entityManager() + $account_unchanged = \Drupal::entityTypeManager() ->getStorage('user') ->loadUnchanged($account->id()); $existing_value = $account_unchanged->getEmail(); diff --git a/core/modules/user/tests/src/Functional/UserCancelTest.php b/core/modules/user/tests/src/Functional/UserCancelTest.php index b216a5a575..cc7c647c4e 100644 --- a/core/modules/user/tests/src/Functional/UserCancelTest.php +++ b/core/modules/user/tests/src/Functional/UserCancelTest.php @@ -268,7 +268,7 @@ public function testUserBlockUnpublish() { $test_node = node_revision_load($node->getRevisionId()); $this->assertFalse($test_node->isPublished(), 'Node revision of the user has been unpublished.'); - $storage = \Drupal::entityManager()->getStorage('comment'); + $storage = \Drupal::entityTypeManager()->getStorage('comment'); $storage->resetCache([$comment->id()]); $comment = $storage->load($comment->id()); $this->assertFalse($comment->isPublished(), 'Comment of the user has been unpublished.'); @@ -345,7 +345,7 @@ public function testUserAnonymize() { $test_node = $node_storage->load($revision_node->id()); $this->assertTrue(($test_node->getOwnerId() != 0 && $test_node->isPublished()), "Current revision of the user's node was not attributed to anonymous user."); - $storage = \Drupal::entityManager()->getStorage('comment'); + $storage = \Drupal::entityTypeManager()->getStorage('comment'); $storage->resetCache([$comment->id()]); $test_comment = $storage->load($comment->id()); $this->assertTrue(($test_comment->getOwnerId() == 0 && $test_comment->isPublished()), 'Comment of the user has been attributed to anonymous user.'); @@ -467,7 +467,7 @@ public function testUserDelete() { $this->assertFalse(node_revision_load($revision), 'Node revision of the user has been deleted.'); $node_storage->resetCache([$revision_node->id()]); $this->assertTrue($node_storage->load($revision_node->id()), "Current revision of the user's node was not deleted."); - \Drupal::entityManager()->getStorage('comment')->resetCache([$comment->id()]); + \Drupal::entityTypeManager()->getStorage('comment')->resetCache([$comment->id()]); $this->assertFalse(Comment::load($comment->id()), 'Comment of the user has been deleted.'); // Confirm that the confirmation message made it through to the end user. diff --git a/core/modules/user/tests/src/Functional/UserPasswordResetTest.php b/core/modules/user/tests/src/Functional/UserPasswordResetTest.php index 2f73e55506..e3c3f295a0 100644 --- a/core/modules/user/tests/src/Functional/UserPasswordResetTest.php +++ b/core/modules/user/tests/src/Functional/UserPasswordResetTest.php @@ -307,7 +307,7 @@ public function testResetImpersonation() { ->fields(['pass' => NULL]) ->condition('uid', [$user1->id(), $user2->id()], 'IN') ->execute(); - \Drupal::entityManager()->getStorage('user')->resetCache(); + \Drupal::entityTypeManager()->getStorage('user')->resetCache(); $user1 = User::load($user1->id()); $user2 = User::load($user2->id()); diff --git a/core/modules/user/tests/src/Functional/UserPermissionsTest.php b/core/modules/user/tests/src/Functional/UserPermissionsTest.php index baa848ae14..30ff65648e 100644 --- a/core/modules/user/tests/src/Functional/UserPermissionsTest.php +++ b/core/modules/user/tests/src/Functional/UserPermissionsTest.php @@ -107,7 +107,7 @@ public function testAdministratorRole() { $edit['user_admin_role'] = $this->rid; $this->drupalPostForm('admin/config/people/accounts', $edit, t('Save configuration')); - \Drupal::entityManager()->getStorage('user_role')->resetCache(); + \Drupal::entityTypeManager()->getStorage('user_role')->resetCache(); $this->assertTrue(Role::load($this->rid)->isAdmin()); // Enable aggregator module and ensure the 'administer news feeds' @@ -121,7 +121,7 @@ public function testAdministratorRole() { $edit['user_admin_role'] = ''; $this->drupalPostForm('admin/config/people/accounts', $edit, t('Save configuration')); - \Drupal::entityManager()->getStorage('user_role')->resetCache(); + \Drupal::entityTypeManager()->getStorage('user_role')->resetCache(); \Drupal::configFactory()->reset(); $this->assertFalse(Role::load($this->rid)->isAdmin()); diff --git a/core/modules/user/tests/src/Functional/UserRegistrationTest.php b/core/modules/user/tests/src/Functional/UserRegistrationTest.php index 19ec4e3b09..e8974ad25e 100644 --- a/core/modules/user/tests/src/Functional/UserRegistrationTest.php +++ b/core/modules/user/tests/src/Functional/UserRegistrationTest.php @@ -208,7 +208,7 @@ public function testUuidFormState() { $this->drupalPostForm('user/register', $edit, t('Create new account')); $this->assertResponse(200); - $user_storage = \Drupal::entityManager()->getStorage('user'); + $user_storage = \Drupal::entityTypeManager()->getStorage('user'); $this->assertTrue($user_storage->loadByProperties(['name' => $edit['name']])); $this->drupalLogout(); diff --git a/core/modules/user/tests/src/Functional/UserRoleAdminTest.php b/core/modules/user/tests/src/Functional/UserRoleAdminTest.php index 739da54840..c7e52135d6 100644 --- a/core/modules/user/tests/src/Functional/UserRoleAdminTest.php +++ b/core/modules/user/tests/src/Functional/UserRoleAdminTest.php @@ -72,7 +72,7 @@ public function testRoleAdministration() { $edit = ['label' => $role_name]; $this->drupalPostForm("admin/people/roles/manage/{$role->id()}", $edit, t('Save')); $this->assertRaw(t('Role %label has been updated.', ['%label' => $role_name])); - \Drupal::entityManager()->getStorage('user_role')->resetCache([$role->id()]); + \Drupal::entityTypeManager()->getStorage('user_role')->resetCache([$role->id()]); $new_role = Role::load($role->id()); $this->assertEqual($new_role->label(), $role_name, 'The role name has been successfully changed.'); @@ -82,7 +82,7 @@ public function testRoleAdministration() { $this->drupalPostForm(NULL, [], t('Delete')); $this->assertRaw(t('The role %label has been deleted.', ['%label' => $role_name])); $this->assertNoLinkByHref("admin/people/roles/manage/{$role->id()}", 'Role edit link removed.'); - \Drupal::entityManager()->getStorage('user_role')->resetCache([$role->id()]); + \Drupal::entityTypeManager()->getStorage('user_role')->resetCache([$role->id()]); $this->assertFalse(Role::load($role->id()), 'A deleted role can no longer be loaded.'); // Make sure that the system-defined roles can be edited via the user diff --git a/core/modules/user/tests/src/Functional/UserTranslationUITest.php b/core/modules/user/tests/src/Functional/UserTranslationUITest.php index 1250268036..d087d528d7 100644 --- a/core/modules/user/tests/src/Functional/UserTranslationUITest.php +++ b/core/modules/user/tests/src/Functional/UserTranslationUITest.php @@ -31,7 +31,7 @@ protected function setUp() { $this->name = $this->randomMachineName(); parent::setUp(); - \Drupal::entityManager()->getStorage('user')->resetCache(); + \Drupal::entityTypeManager()->getStorage('user')->resetCache(); } /** diff --git a/core/modules/user/tests/src/Functional/Views/AccessRoleTest.php b/core/modules/user/tests/src/Functional/Views/AccessRoleTest.php index 7f847234aa..7f92860f8b 100644 --- a/core/modules/user/tests/src/Functional/Views/AccessRoleTest.php +++ b/core/modules/user/tests/src/Functional/Views/AccessRoleTest.php @@ -30,7 +30,7 @@ class AccessRoleTest extends AccessTestBase { */ public function testAccessRole() { /** @var \Drupal\views\ViewEntityInterface $view */ - $view = \Drupal::entityManager()->getStorage('view')->load('test_access_role'); + $view = \Drupal::entityTypeManager()->getStorage('view')->load('test_access_role'); $display = &$view->getDisplay('default'); $display['display_options']['access']['options']['role'] = [ $this->normalRole => $this->normalRole, diff --git a/core/modules/user/user.install b/core/modules/user/user.install index 600c2ec265..2540ac2cd3 100644 --- a/core/modules/user/user.install +++ b/core/modules/user/user.install @@ -69,7 +69,7 @@ function user_schema() { * Implements hook_install(). */ function user_install() { - $storage = \Drupal::entityManager()->getStorage('user'); + $storage = \Drupal::entityTypeManager()->getStorage('user'); // Insert a row for the anonymous user. $storage ->create([ diff --git a/core/modules/user/user.module b/core/modules/user/user.module index b081cce74d..bce42fcba8 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -149,7 +149,7 @@ function user_js_settings_alter(&$settings, AttachedAssetsInterface $assets) { * preprocess stage. */ function user_picture_enabled() { - $field_definitions = \Drupal::entityManager()->getFieldDefinitions('user', 'user'); + $field_definitions = \Drupal::service('entity_field.manager')->getFieldDefinitions('user', 'user'); return isset($field_definitions['user_picture']); } @@ -208,7 +208,7 @@ function user_entity_extra_field_info() { function user_load_multiple(array $uids = NULL, $reset = FALSE) { @trigger_error('user_load_multiple() is deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal\user\Entity\User::loadMultiple(). See https://www.drupal.org/node/2266845', E_USER_DEPRECATED); if ($reset) { - \Drupal::entityManager()->getStorage('user')->resetCache($uids); + \Drupal::entityTypeManager()->getStorage('user')->resetCache($uids); } return User::loadMultiple($uids); } @@ -234,7 +234,7 @@ function user_load_multiple(array $uids = NULL, $reset = FALSE) { function user_load($uid, $reset = FALSE) { @trigger_error('user_load() is deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal\user\Entity\User::load(). See https://www.drupal.org/node/2266845', E_USER_DEPRECATED); if ($reset) { - \Drupal::entityManager()->getStorage('user')->resetCache([$uid]); + \Drupal::entityTypeManager()->getStorage('user')->resetCache([$uid]); } return User::load($uid); } @@ -557,7 +557,7 @@ function user_login_finalize(UserInterface $account) { // Update the user table timestamp noting user has logged in. // This is also used to invalidate one-time login links. $account->setLastLoginTime(REQUEST_TIME); - \Drupal::entityManager() + \Drupal::entityTypeManager() ->getStorage('user') ->updateLastLoginTimestamp($account); @@ -1041,7 +1041,7 @@ function user_user_role_insert(RoleInterface $role) { */ function user_user_role_delete(RoleInterface $role) { // Delete role references for all users. - $user_storage = \Drupal::entityManager()->getStorage('user'); + $user_storage = \Drupal::entityTypeManager()->getStorage('user'); $user_storage->deleteRoleReferences([$role->id()]); // Ignore the authenticated and anonymous roles or the role is being synced. diff --git a/core/modules/views/src/Plugin/views/cache/CachePluginBase.php b/core/modules/views/src/Plugin/views/cache/CachePluginBase.php index 280ccf4d16..14ac7994fd 100644 --- a/core/modules/views/src/Plugin/views/cache/CachePluginBase.php +++ b/core/modules/views/src/Plugin/views/cache/CachePluginBase.php @@ -241,7 +241,7 @@ public function getCacheTags() { if (!empty($entity_information)) { // Add the list cache tags for each entity type used by this view. foreach ($entity_information as $table => $metadata) { - $tags = Cache::mergeTags($tags, \Drupal::entityManager()->getDefinition($metadata['entity_type'])->getListCacheTags()); + $tags = Cache::mergeTags($tags, \Drupal::entityTypeManager()->getDefinition($metadata['entity_type'])->getListCacheTags()); } } diff --git a/core/modules/views/src/Plugin/views/query/QueryPluginBase.php b/core/modules/views/src/Plugin/views/query/QueryPluginBase.php index 83e0bcfa24..5d39b9cb1c 100644 --- a/core/modules/views/src/Plugin/views/query/QueryPluginBase.php +++ b/core/modules/views/src/Plugin/views/query/QueryPluginBase.php @@ -316,7 +316,7 @@ public function getEntityTableInfo() { // Determine which of the tables are revision tables. foreach ($entity_tables as $table_alias => $table) { - $entity_type = \Drupal::entityManager()->getDefinition($table['entity_type']); + $entity_type = \Drupal::entityTypeManager()->getDefinition($table['entity_type']); if ($entity_type->getRevisionTable() == $table['base']) { $entity_tables[$table_alias]['revision'] = TRUE; } @@ -339,7 +339,7 @@ public function getCacheContexts() { $contexts = []; if (($views_data = Views::viewsData()->get($this->view->storage->get('base_table'))) && !empty($views_data['table']['entity type'])) { $entity_type_id = $views_data['table']['entity type']; - $entity_type = \Drupal::entityManager()->getDefinition($entity_type_id); + $entity_type = \Drupal::entityTypeManager()->getDefinition($entity_type_id); $contexts = $entity_type->getListCacheContexts(); } return $contexts; diff --git a/core/modules/views/src/Plugin/views/query/Sql.php b/core/modules/views/src/Plugin/views/query/Sql.php index 03749a329b..7503e1d8b1 100644 --- a/core/modules/views/src/Plugin/views/query/Sql.php +++ b/core/modules/views/src/Plugin/views/query/Sql.php @@ -1346,7 +1346,7 @@ public function query($get_count = FALSE) { } foreach ($entity_information as $entity_type_id => $info) { - $entity_type = \Drupal::entityManager()->getDefinition($info['entity_type']); + $entity_type = \Drupal::entityTypeManager()->getDefinition($info['entity_type']); $base_field = !$info['revision'] ? $entity_type->getKey('id') : $entity_type->getKey('revision'); $this->addField($info['alias'], $base_field, '', $params); } diff --git a/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php b/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php index 20ff84dad7..ea9cf95f98 100644 --- a/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php +++ b/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php @@ -139,7 +139,7 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition $this->bundleInfoService = $bundle_info_service; $this->base_table = $this->definition['base_table']; - $entity_types = \Drupal::entityManager()->getDefinitions(); + $entity_types = \Drupal::entityTypeManager()->getDefinitions(); foreach ($entity_types as $entity_type_id => $entity_type) { if (in_array($this->base_table, [$entity_type->getBaseTable(), $entity_type->getDataTable(), $entity_type->getRevisionTable(), $entity_type->getRevisionDataTable()], TRUE)) { $this->entityType = $entity_type; diff --git a/core/modules/views/src/Tests/ViewTestData.php b/core/modules/views/src/Tests/ViewTestData.php index f0c8cfce7d..6033fcfd33 100644 --- a/core/modules/views/src/Tests/ViewTestData.php +++ b/core/modules/views/src/Tests/ViewTestData.php @@ -31,7 +31,7 @@ public static function createTestViews($class, array $modules) { $class = get_parent_class($class); } if (!empty($views)) { - $storage = \Drupal::entityManager()->getStorage('view'); + $storage = \Drupal::entityTypeManager()->getStorage('view'); $module_handler = \Drupal::moduleHandler(); foreach ($modules as $module) { $config_dir = drupal_get_path('module', $module) . '/test_views'; diff --git a/core/modules/views/src/Views.php b/core/modules/views/src/Views.php index dd241f714b..32cf016fd4 100644 --- a/core/modules/views/src/Views.php +++ b/core/modules/views/src/Views.php @@ -242,7 +242,7 @@ public static function getApplicableViews($type) { * An array of loaded view entities. */ public static function getAllViews() { - return \Drupal::entityManager()->getStorage('view')->loadMultiple(); + return \Drupal::entityTypeManager()->getStorage('view')->loadMultiple(); } /** @@ -256,7 +256,7 @@ public static function getEnabledViews() { ->condition('status', TRUE) ->execute(); - return \Drupal::entityManager()->getStorage('view')->loadMultiple($query); + return \Drupal::entityTypeManager()->getStorage('view')->loadMultiple($query); } /** @@ -270,7 +270,7 @@ public static function getDisabledViews() { ->condition('status', FALSE) ->execute(); - return \Drupal::entityManager()->getStorage('view')->loadMultiple($query); + return \Drupal::entityTypeManager()->getStorage('view')->loadMultiple($query); } /** diff --git a/core/modules/views/tests/src/Functional/FieldApiDataTest.php b/core/modules/views/tests/src/Functional/FieldApiDataTest.php index 7bcb0e70d9..8f10610628 100644 --- a/core/modules/views/tests/src/Functional/FieldApiDataTest.php +++ b/core/modules/views/tests/src/Functional/FieldApiDataTest.php @@ -191,7 +191,7 @@ protected function setUp($import_test_views = TRUE) { * We check data structure for both node and node revision tables. */ public function testViewsData() { - $table_mapping = \Drupal::entityManager()->getStorage('node')->getTableMapping(); + $table_mapping = \Drupal::entityTypeManager()->getStorage('node')->getTableMapping(); $field_storage = $this->fieldStorages[0]; $current_table = $table_mapping->getDedicatedDataTableName($field_storage); $revision_table = $table_mapping->getDedicatedRevisionTableName($field_storage); @@ -274,7 +274,7 @@ protected function getViewsData($field_storage_key = 0) { // Check the table and the joins of the first field. // Attached to node only. /** @var \Drupal\Core\Entity\Sql\DefaultTableMapping $table_mapping */ - $table_mapping = \Drupal::entityManager()->getStorage('node')->getTableMapping(); + $table_mapping = \Drupal::entityTypeManager()->getStorage('node')->getTableMapping(); $current_table = $table_mapping->getDedicatedDataTableName($this->fieldStorages[$field_storage_key]); $revision_table = $table_mapping->getDedicatedRevisionTableName($this->fieldStorages[$field_storage_key]); $data[$current_table] = $views_data->get($current_table); diff --git a/core/modules/views/tests/src/Functional/Handler/FieldEntityOperationsTest.php b/core/modules/views/tests/src/Functional/Handler/FieldEntityOperationsTest.php index 7ced4f7071..0eb54d6993 100644 --- a/core/modules/views/tests/src/Functional/Handler/FieldEntityOperationsTest.php +++ b/core/modules/views/tests/src/Functional/Handler/FieldEntityOperationsTest.php @@ -69,7 +69,7 @@ public function testEntityOperations() { /** @var \Drupal\Core\Language\LanguageInterface $language */ foreach ($entity->getTranslationLanguages() as $language) { $entity = $entity->getTranslation($language->getId()); - $operations = \Drupal::entityManager()->getListBuilder('node')->getOperations($entity); + $operations = \Drupal::service('entity_field.manager')->getListBuilder('node')->getOperations($entity); $this->assertTrue(count($operations) > 0, 'There are operations.'); foreach ($operations as $operation) { $expected_destination = Url::fromUri('internal:/test-entity-operations')->toString(); diff --git a/core/modules/views/tests/src/Functional/Wizard/NodeWizardTest.php b/core/modules/views/tests/src/Functional/Wizard/NodeWizardTest.php index 41870b6db9..21bdf1709d 100644 --- a/core/modules/views/tests/src/Functional/Wizard/NodeWizardTest.php +++ b/core/modules/views/tests/src/Functional/Wizard/NodeWizardTest.php @@ -25,7 +25,7 @@ public function testViewAddWithNodeTitles() { $view['page[style][row_plugin]'] = 'titles'; $this->drupalPostForm('admin/structure/views/add', $view, t('Save and edit')); - $view_storage_controller = \Drupal::entityManager()->getStorage('view'); + $view_storage_controller = \Drupal::entityTypeManager()->getStorage('view'); /** @var \Drupal\views\Entity\View $view */ $view = $view_storage_controller->load($view['id']); diff --git a/core/modules/views/tests/src/Kernel/Entity/RowEntityRenderersTest.php b/core/modules/views/tests/src/Kernel/Entity/RowEntityRenderersTest.php index a110f00209..83e0cb97f5 100644 --- a/core/modules/views/tests/src/Kernel/Entity/RowEntityRenderersTest.php +++ b/core/modules/views/tests/src/Kernel/Entity/RowEntityRenderersTest.php @@ -94,7 +94,7 @@ protected function setUp($import_test_views = TRUE) { $this->values = []; $this->ids = []; - $controller = \Drupal::entityManager()->getStorage('node'); + $controller = \Drupal::entityTypeManager()->getStorage('node'); $langcode_index = 0; for ($i = 0; $i < count($this->langcodes); $i++) { diff --git a/core/modules/views/tests/src/Kernel/Handler/AreaEntityTest.php b/core/modules/views/tests/src/Kernel/Handler/AreaEntityTest.php index 2ccaac6f31..0d3ce325d4 100644 --- a/core/modules/views/tests/src/Kernel/Handler/AreaEntityTest.php +++ b/core/modules/views/tests/src/Kernel/Handler/AreaEntityTest.php @@ -149,7 +149,7 @@ public function doTestRender($entities) { $this->assertTrue(strpos(trim((string) $result[0]), 'full') !== FALSE, 'The rendered entity appeared in the right view mode.'); // Mark entity_test test view_mode as customizable. - $entity_view_mode = \Drupal::entityManager()->getStorage('entity_view_mode')->load('entity_test.test'); + $entity_view_mode = \Drupal::entityTypeManager()->getStorage('entity_view_mode')->load('entity_test.test'); $entity_view_mode->enable(); $entity_view_mode->save(); diff --git a/core/modules/views/tests/src/Kernel/Handler/FieldFieldAccessTestBase.php b/core/modules/views/tests/src/Kernel/Handler/FieldFieldAccessTestBase.php index 5ff77bc9f4..327bfc1481 100644 --- a/core/modules/views/tests/src/Kernel/Handler/FieldFieldAccessTestBase.php +++ b/core/modules/views/tests/src/Kernel/Handler/FieldFieldAccessTestBase.php @@ -83,7 +83,7 @@ protected function setUp($import_test_views = TRUE) { protected function assertFieldAccess($entity_type_id, $field_name, $field_content) { \Drupal::state()->set('views_field_access_test-field', $field_name); - $entity_type = \Drupal::entityManager()->getDefinition($entity_type_id); + $entity_type = \Drupal::entityTypeManager()->getDefinition($entity_type_id); $view_id = $this->randomMachineName(); $data_table = $entity_type->getDataTable(); // Use the data table as long as the field is not 'uuid'. This is the only diff --git a/core/modules/views/tests/src/Kernel/ViewStorageTest.php b/core/modules/views/tests/src/Kernel/ViewStorageTest.php index e6cce86f2e..b60df267b3 100644 --- a/core/modules/views/tests/src/Kernel/ViewStorageTest.php +++ b/core/modules/views/tests/src/Kernel/ViewStorageTest.php @@ -59,7 +59,7 @@ class ViewStorageTest extends ViewsKernelTestBase { */ public function testConfigurationEntityCRUD() { // Get the configuration entity type and controller. - $this->entityType = \Drupal::entityManager()->getDefinition('view'); + $this->entityType = \Drupal::entityTypeManager()->getDefinition('view'); $this->controller = $this->container->get('entity.manager')->getStorage('view'); // Confirm that an info array has been returned. diff --git a/core/modules/views/views.api.php b/core/modules/views/views.api.php index bf0fd7014e..9889c93e32 100644 --- a/core/modules/views/views.api.php +++ b/core/modules/views/views.api.php @@ -557,9 +557,9 @@ function hook_field_views_data(\Drupal\field\FieldStorageConfigInterface $field_ function hook_field_views_data_alter(array &$data, \Drupal\field\FieldStorageConfigInterface $field_storage) { $entity_type_id = $field_storage->getTargetEntityTypeId(); $field_name = $field_storage->getName(); - $entity_type = \Drupal::entityManager()->getDefinition($entity_type_id); + $entity_type = \Drupal::entityTypeManager()->getDefinition($entity_type_id); $pseudo_field_name = 'reverse_' . $field_name . '_' . $entity_type_id; - $table_mapping = \Drupal::entityManager()->getStorage($entity_type_id)->getTableMapping(); + $table_mapping = \Drupal::entityTypeManager()->getStorage($entity_type_id)->getTableMapping(); list($label) = views_entity_field_label($entity_type_id, $field_name); @@ -614,10 +614,10 @@ function hook_field_views_data_views_data_alter(array &$data, \Drupal\field\Fiel $field_name = $field->getName(); $data_key = 'field_data_' . $field_name; $entity_type_id = $field->entity_type; - $entity_type = \Drupal::entityManager()->getDefinition($entity_type_id); + $entity_type = \Drupal::entityTypeManager()->getDefinition($entity_type_id); $pseudo_field_name = 'reverse_' . $field_name . '_' . $entity_type_id; list($label) = views_entity_field_label($entity_type_id, $field_name); - $table_mapping = \Drupal::entityManager()->getStorage($entity_type_id)->getTableMapping(); + $table_mapping = \Drupal::entityTypeManager()->getStorage($entity_type_id)->getTableMapping(); // Views data for this field is in $data[$data_key]. $data[$data_key][$pseudo_field_name]['relationship'] = [ diff --git a/core/modules/views/views.module b/core/modules/views/views.module index 9127c388f5..79973f7449 100644 --- a/core/modules/views/views.module +++ b/core/modules/views/views.module @@ -399,7 +399,7 @@ function views_add_contextual_links(&$render_element, $location, $display_id, ar $args = []; $valid = TRUE; if (!empty($link['route_parameters_names'])) { - $view_storage = \Drupal::entityManager() + $view_storage = \Drupal::entityTypeManager() ->getStorage('view') ->load($view_id); foreach ($link['route_parameters_names'] as $parameter_name => $property) { diff --git a/core/modules/views/views.post_update.php b/core/modules/views/views.post_update.php index 30749fcba8..8c10f65e4f 100644 --- a/core/modules/views/views.post_update.php +++ b/core/modules/views/views.post_update.php @@ -17,7 +17,7 @@ */ function views_post_update_update_cacheability_metadata() { // Load all views. - $views = \Drupal::entityManager()->getStorage('view')->loadMultiple(); + $views = \Drupal::entityTypeManager()->getStorage('view')->loadMultiple(); /* @var \Drupal\views\Entity\View[] $views */ foreach ($views as $view) { diff --git a/core/modules/views/views.views.inc b/core/modules/views/views.views.inc index a809b55b5c..a4625c784e 100644 --- a/core/modules/views/views.views.inc +++ b/core/modules/views/views.views.inc @@ -138,7 +138,7 @@ function views_views_data() { ]; // Registers an entity area handler per entity type. - foreach (\Drupal::entityManager()->getDefinitions() as $entity_type_id => $entity_type) { + foreach (\Drupal::entityTypeManager()->getDefinitions() as $entity_type_id => $entity_type) { // Excludes entity types, which cannot be rendered. if ($entity_type->hasViewBuilderClass()) { $label = $entity_type->getLabel(); @@ -154,8 +154,8 @@ function views_views_data() { } // Registers an action bulk form per entity. - foreach (\Drupal::entityManager()->getDefinitions() as $entity_type => $entity_info) { - $actions = array_filter(\Drupal::entityManager()->getStorage('action')->loadMultiple(), function (ActionConfigEntityInterface $action) use ($entity_type) { + foreach (\Drupal::entityTypeManager()->getDefinitions() as $entity_type => $entity_info) { + $actions = array_filter(\Drupal::entityTypeManager()->getStorage('action')->loadMultiple(), function (ActionConfigEntityInterface $action) use ($entity_type) { return $action->getType() == $entity_type; }); if (empty($actions)) { @@ -171,10 +171,10 @@ function views_views_data() { } // Registers views data for the entity itself. - foreach (\Drupal::entityManager()->getDefinitions() as $entity_type_id => $entity_type) { + foreach (\Drupal::entityTypeManager()->getDefinitions() as $entity_type_id => $entity_type) { if ($entity_type->hasHandlerClass('views_data')) { /** @var \Drupal\views\EntityViewsDataInterface $views_data */ - $views_data = \Drupal::entityManager()->getHandler($entity_type_id, 'views_data'); + $views_data = \Drupal::entityTypeManager()->getHandler($entity_type_id, 'views_data'); $data = NestedArray::mergeDeep($data, $views_data->getViewsData()); } } @@ -183,10 +183,10 @@ function views_views_data() { // behavior for adding fields. $module_handler = \Drupal::moduleHandler(); - $entity_manager = \Drupal::entityManager(); - if ($entity_manager->hasDefinition('field_storage_config')) { + $entity_type_manager = \Drupal::entityTypeManager(); + if ($entity_type_manager->hasDefinition('field_storage_config')) { /** @var \Drupal\field\FieldStorageConfigInterface $field_storage */ - foreach ($entity_manager->getStorage('field_storage_config')->loadMultiple() as $field_storage) { + foreach ($entity_type_manager->getStorage('field_storage_config')->loadMultiple() as $field_storage) { if (_views_field_get_entity_type_storage($field_storage)) { $result = (array) $module_handler->invoke($field_storage->getTypeProvider(), 'field_views_data', [$field_storage]); if (empty($result)) { @@ -213,7 +213,7 @@ function views_views_data() { * in views_views_data(). */ function views_views_data_alter(&$data) { - $entity_manager = \Drupal::entityManager(); + $entity_manager = \Drupal::entityTypeManager(); if (!$entity_manager->hasDefinition('field_storage_config')) { return; } @@ -239,7 +239,7 @@ function views_views_data_alter(&$data) { */ function _views_field_get_entity_type_storage(FieldStorageConfigInterface $field_storage) { $result = FALSE; - $entity_manager = \Drupal::entityManager(); + $entity_manager = \Drupal::entityTypeManager(); if ($entity_manager->hasDefinition($field_storage->getTargetEntityTypeId())) { $storage = $entity_manager->getStorage($field_storage->getTargetEntityTypeId()); $result = $storage instanceof SqlContentEntityStorage ? $storage : FALSE; @@ -257,7 +257,7 @@ function views_entity_field_label($entity_type, $field_name) { $all_labels = []; // Count the amount of fields per label per field storage. foreach (array_keys(\Drupal::service('entity_type.bundle.info')->getBundleInfo($entity_type)) as $bundle) { - $bundle_fields = array_filter(\Drupal::entityManager()->getFieldDefinitions($entity_type, $bundle), function ($field_definition) { + $bundle_fields = array_filter(\Drupal::service('entity_field.manager')->getFieldDefinitions($entity_type, $bundle), function ($field_definition) { return $field_definition instanceof FieldConfigInterface; }); if (isset($bundle_fields[$field_name])) { @@ -320,9 +320,9 @@ function views_field_default_views_data(FieldStorageConfigInterface $field_stora // Grab information about the entity type tables. // We need to join to both the base table and the data table, if available. - $entity_manager = \Drupal::entityManager(); + $entity_type_manager = \Drupal::entityTypeManager(); $entity_type_id = $field_storage->getTargetEntityTypeId(); - $entity_type = $entity_manager->getDefinition($entity_type_id); + $entity_type = $entity_type_manager->getDefinition($entity_type_id); if (!$base_table = $entity_type->getBaseTable()) { // We cannot do anything if for some reason there is no base table. return $data; @@ -775,17 +775,17 @@ function core_field_views_data(FieldStorageConfigInterface $field_storage) { return $data; } - $entity_manager = \Drupal::entityManager(); + $entity_type_manager = \Drupal::entityTypeManager(); $entity_type_id = $field_storage->getTargetEntityTypeId(); /** @var \Drupal\Core\Entity\Sql\DefaultTableMapping $table_mapping */ - $table_mapping = $entity_manager->getStorage($entity_type_id)->getTableMapping(); + $table_mapping = $entity_type_manager->getStorage($entity_type_id)->getTableMapping(); foreach ($data as $table_name => $table_data) { // Add a relationship to the target entity type. $target_entity_type_id = $field_storage->getSetting('target_type'); - $target_entity_type = $entity_manager->getDefinition($target_entity_type_id); + $target_entity_type = $entity_type_manager->getDefinition($target_entity_type_id); $entity_type_id = $field_storage->getTargetEntityTypeId(); - $entity_type = $entity_manager->getDefinition($entity_type_id); + $entity_type = $entity_type_manager->getDefinition($entity_type_id); $target_base_table = $target_entity_type->getDataTable() ?: $target_entity_type->getBaseTable(); $field_name = $field_storage->getName(); diff --git a/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php b/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php index 619b191465..65d45eee5c 100644 --- a/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php +++ b/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php @@ -165,7 +165,7 @@ public function getForm(ViewEntityInterface $view, $display_id, $js) { // If this form was for view-wide changes, there's no need to regenerate // the display section of the form. if ($display_id !== '') { - \Drupal::entityManager()->getFormObject('view', 'edit')->rebuildCurrentTab($view, $response, $display_id); + \Drupal::entityTypeManager()->getFormObject('view', 'edit')->rebuildCurrentTab($view, $response, $display_id); } return $response; diff --git a/core/modules/views_ui/tests/src/Functional/DisplayPathTest.php b/core/modules/views_ui/tests/src/Functional/DisplayPathTest.php index 2f007f193c..5973a5d59b 100644 --- a/core/modules/views_ui/tests/src/Functional/DisplayPathTest.php +++ b/core/modules/views_ui/tests/src/Functional/DisplayPathTest.php @@ -212,7 +212,7 @@ public function testDefaultMenuTabRegression() { ]; $this->drupalPostForm('admin/structure/menu/manage/admin/add', $edit, t('Save')); - $menu_items = \Drupal::entityManager()->getStorage('menu_link_content')->getQuery() + $menu_items = \Drupal::entityTypeManager()->getStorage('menu_link_content')->getQuery() ->sort('id', 'DESC') ->pager(1) ->execute(); diff --git a/core/modules/views_ui/tests/src/Functional/ViewEditTest.php b/core/modules/views_ui/tests/src/Functional/ViewEditTest.php index 94f9da8144..bfe5b05d07 100644 --- a/core/modules/views_ui/tests/src/Functional/ViewEditTest.php +++ b/core/modules/views_ui/tests/src/Functional/ViewEditTest.php @@ -58,7 +58,7 @@ public function testOtherOptions() { // Save the view, and test the new ID has been saved. $this->drupalPostForm(NULL, [], 'Save'); - $view = \Drupal::entityManager()->getStorage('view')->load('test_view'); + $view = \Drupal::entityTypeManager()->getStorage('view')->load('test_view'); $displays = $view->get('display'); $this->assertTrue(!empty($displays['test_1']), 'Display data found for new display ID key.'); $this->assertIdentical($displays['test_1']['id'], 'test_1', 'New display ID matches the display ID key.'); diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStaticCacheTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStaticCacheTest.php index 1cd9cb1753..aaeeb9d31e 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStaticCacheTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStaticCacheTest.php @@ -86,7 +86,7 @@ public function testReset() { */ public function testConfigOverride() { /** @var \Drupal\Core\Config\Entity\ConfigEntityStorage $storage */ - $storage = \Drupal::entityManager()->getStorage($this->entityTypeId); + $storage = \Drupal::entityTypeManager()->getStorage($this->entityTypeId); // Prime the cache prior to adding a config override. $storage->load($this->entityId); diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityUnitTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityUnitTest.php index 1fce8a498d..fcc472f9e2 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityUnitTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityUnitTest.php @@ -46,7 +46,7 @@ protected function setUp() { * Tests storage methods. */ public function testStorageMethods() { - $entity_type = \Drupal::entityManager()->getDefinition('config_test'); + $entity_type = \Drupal::entityTypeManager()->getDefinition('config_test'); // Test the static extractID() method. $expected_id = 'test_id'; diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php index 6489b06799..70dbb874c9 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php @@ -244,7 +244,7 @@ public function testSecondaryWritePrimaryFirst() { // Import. $this->configImporter->reset()->import(); - $entity_storage = \Drupal::entityManager()->getStorage('config_test'); + $entity_storage = \Drupal::entityTypeManager()->getStorage('config_test'); $primary = $entity_storage->load('primary'); $this->assertEqual($primary->id(), 'primary'); $this->assertEqual($primary->uuid(), $values_primary['uuid']); @@ -290,7 +290,7 @@ public function testSecondaryWriteSecondaryFirst() { // Import. $this->configImporter->reset()->import(); - $entity_storage = \Drupal::entityManager()->getStorage('config_test'); + $entity_storage = \Drupal::entityTypeManager()->getStorage('config_test'); $primary = $entity_storage->load('primary'); $this->assertEqual($primary->id(), 'primary'); $this->assertEqual($primary->uuid(), $values_primary['uuid']); @@ -367,7 +367,7 @@ public function testSecondaryUpdateDeletedDeleterFirst() { // Import. $this->configImporter->import(); - $entity_storage = \Drupal::entityManager()->getStorage('config_test'); + $entity_storage = \Drupal::entityTypeManager()->getStorage('config_test'); $deleter = $entity_storage->load('deleter'); $this->assertEqual($deleter->id(), 'deleter'); $this->assertEqual($deleter->uuid(), $values_deleter['uuid']); @@ -427,7 +427,7 @@ public function testSecondaryUpdateDeletedDeleteeFirst() { // Import. $this->configImporter->reset()->import(); - $entity_storage = \Drupal::entityManager()->getStorage('config_test'); + $entity_storage = \Drupal::entityTypeManager()->getStorage('config_test'); // Both entities are deleted. ConfigTest::postSave() causes updates of the // deleter entity to delete the deletee entity. Since the deleter depends on // the deletee, removing the deletee causes the deleter to be removed. @@ -469,7 +469,7 @@ public function testSecondaryDeletedDeleteeSecond() { // Import. $this->configImporter->reset()->import(); - $entity_storage = \Drupal::entityManager()->getStorage('config_test'); + $entity_storage = \Drupal::entityTypeManager()->getStorage('config_test'); $this->assertFalse($entity_storage->load('deleter')); $this->assertFalse($entity_storage->load('deletee')); // The deletee entity does not exist as the delete worked and although the diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigInstallTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigInstallTest.php index 5efd20bbb1..89b284612c 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/ConfigInstallTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigInstallTest.php @@ -223,7 +223,7 @@ public function testDependencyChecking() { } $this->installModules(['config_other_module_config_test']); $this->installModules(['config_install_dependency_test']); - $entity = \Drupal::entityManager()->getStorage('config_test')->load('other_module_test_with_dependency'); + $entity = \Drupal::entityTypeManager()->getStorage('config_test')->load('other_module_test_with_dependency'); $this->assertTrue($entity, 'The config_test.dynamic.other_module_test_with_dependency configuration has been created during install.'); // Ensure that dependencies can be added during module installation by // hooks. diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityApiTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityApiTest.php index 23d1734b74..cea13ba5b7 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityApiTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityApiTest.php @@ -93,7 +93,7 @@ protected function assertCRUD($entity_type, UserInterface $user1) { $this->assertTrue(empty($all), format_string('%entity_type: Deleted all entities.', ['%entity_type' => $entity_type])); // Verify that all data got deleted. - $definition = \Drupal::entityManager()->getDefinition($entity_type); + $definition = \Drupal::entityTypeManager()->getDefinition($entity_type); $this->assertEqual(0, db_query('SELECT COUNT(*) FROM {' . $definition->getBaseTable() . '}')->fetchField(), 'Base table was emptied'); if ($data_table = $definition->getDataTable()) { $this->assertEqual(0, db_query('SELECT COUNT(*) FROM {' . $data_table . '}')->fetchField(), 'Data table was emptied'); @@ -113,7 +113,7 @@ protected function assertCRUD($entity_type, UserInterface $user1) { $entity = entity_create($entity_type, ['name' => 'test2', 'user_id' => $user1->id()]); $entity->save(); $entities['test2'] = $entity; - $controller = \Drupal::entityManager()->getStorage($entity_type); + $controller = \Drupal::entityTypeManager()->getStorage($entity_type); $controller->delete($entities); // Verify that entities got deleted. @@ -121,7 +121,7 @@ protected function assertCRUD($entity_type, UserInterface $user1) { $this->assertTrue(empty($all), format_string('%entity_type: Deleted all entities.', ['%entity_type' => $entity_type])); // Verify that all data got deleted from the tables. - $definition = \Drupal::entityManager()->getDefinition($entity_type); + $definition = \Drupal::entityTypeManager()->getDefinition($entity_type); $this->assertEqual(0, db_query('SELECT COUNT(*) FROM {' . $definition->getBaseTable() . '}')->fetchField(), 'Base table was emptied'); if ($data_table = $definition->getDataTable()) { $this->assertEqual(0, db_query('SELECT COUNT(*) FROM {' . $data_table . '}')->fetchField(), 'Data table was emptied'); diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityBundleFieldTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityBundleFieldTest.php index 774db4b36b..07c81e4f96 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityBundleFieldTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityBundleFieldTest.php @@ -63,7 +63,7 @@ public function testCustomBundleFieldUsage() { $this->assertTrue($entity->hasField('custom_bundle_field')); // Ensure that the field exists in the field map. - $field_map = \Drupal::entityManager()->getFieldMap(); + $field_map = \Drupal::service('entity_field.manager')->getFieldMap(); $this->assertEqual($field_map['entity_test_update']['custom_bundle_field'], ['type' => 'string', 'bundles' => ['custom' => 'custom']]); $entity->custom_bundle_field->value = 'swanky'; @@ -103,7 +103,7 @@ public function testCustomBundleFieldUsage() { $this->assertEqual(1, $result->fetchField(), 'Field data has been deleted'); // Ensure that the field no longer exists in the field map. - $field_map = \Drupal::entityManager()->getFieldMap(); + $field_map = \Drupal::service('entity_field.manager')->getFieldMap(); $this->assertFalse(isset($field_map['entity_test_update']['custom_bundle_field'])); // Purge field data, and check that the storage definition has been diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php index 826d123198..7ee87b0412 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php @@ -415,7 +415,7 @@ public function testIntrospection() { protected function doTestIntrospection($entity_type) { // Test getting metadata upfront. The entity types used for this test have // a default bundle that is the same as the entity type. - $definitions = \Drupal::entityManager()->getFieldDefinitions($entity_type, $entity_type); + $definitions = \Drupal::service('entity_field.manager')->getFieldDefinitions($entity_type, $entity_type); $this->assertEqual($definitions['name']->getType(), 'string', $entity_type . ': Name field found.'); $this->assertEqual($definitions['user_id']->getType(), 'entity_reference', $entity_type . ': User field found.'); $this->assertEqual($definitions['field_test_text']->getType(), 'text', $entity_type . ': Test-text-field field found.'); diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntitySchemaTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntitySchemaTest.php index 9dab3359b7..3ea35af7da 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntitySchemaTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntitySchemaTest.php @@ -322,7 +322,7 @@ public function testCleanUpStorageDefinition() { // Find all the entity types provided by the entity_test module and install // the schema for them. $entity_type_ids = []; - $entities = \Drupal::entityManager()->getDefinitions(); + $entities = \Drupal::entityTypeManager()->getDefinitions(); foreach ($entities as $entity_type_id => $definition) { if ($definition->getProvider() == 'entity_test') { $this->installEntitySchema($entity_type_id); diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityTypedDataDefinitionTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityTypedDataDefinitionTest.php index d0c01bccb5..e94bb99825 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityTypedDataDefinitionTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityTypedDataDefinitionTest.php @@ -104,7 +104,7 @@ public function testEntities() { $field_definitions = $entity_definition->getPropertyDefinitions(); // Comparison should ignore the internal static cache, so compare the // serialized objects instead. - $this->assertEqual(serialize($field_definitions), serialize(\Drupal::entityManager()->getBaseFieldDefinitions('node'))); + $this->assertEqual(serialize($field_definitions), serialize(\Drupal::service('entity_field.manager')->getBaseFieldDefinitions('node'))); $this->assertEqual($entity_definition->getPropertyDefinition('title')->getItemDefinition()->getDataType(), 'field_item:string'); $this->assertNull($entity_definition->getMainPropertyName()); $this->assertNull($entity_definition->getPropertyDefinition('invalid')); diff --git a/core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php b/core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php index 40d9488c60..76e7004d23 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php @@ -93,7 +93,7 @@ protected function setUp() { $this->field->save(); /** @var \Drupal\Core\Entity\Sql\DefaultTableMapping $table_mapping */ - $table_mapping = \Drupal::entityManager()->getStorage($entity_type)->getTableMapping(); + $table_mapping = \Drupal::entityTypeManager()->getStorage($entity_type)->getTableMapping(); $this->tableMapping = $table_mapping; $this->table = $table_mapping->getDedicatedDataTableName($this->fieldStorage); $this->revisionTable = $table_mapping->getDedicatedRevisionTableName($this->fieldStorage); diff --git a/core/tests/Drupal/KernelTests/Core/Entity/FieldTranslationSqlStorageTest.php b/core/tests/Drupal/KernelTests/Core/Entity/FieldTranslationSqlStorageTest.php index c398732f3c..b0ca040a6c 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/FieldTranslationSqlStorageTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/FieldTranslationSqlStorageTest.php @@ -78,7 +78,7 @@ protected function assertFieldStorageLangcode(FieldableEntityInterface $entity, $langcode = $entity->getUntranslated()->language()->getId(); $fields = [$this->fieldName, $this->untranslatableFieldName]; /** @var \Drupal\Core\Entity\Sql\DefaultTableMapping $table_mapping */ - $table_mapping = \Drupal::entityManager()->getStorage($entity_type)->getTableMapping(); + $table_mapping = \Drupal::entityTypeManager()->getStorage($entity_type)->getTableMapping(); foreach ($fields as $field_name) { $field_storage = FieldStorageConfig::loadByName($entity_type, $field_name); diff --git a/core/tests/Drupal/KernelTests/Core/Entity/FieldWidgetConstraintValidatorTest.php b/core/tests/Drupal/KernelTests/Core/Entity/FieldWidgetConstraintValidatorTest.php index d3d5e5b1d4..4cf22487c8 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/FieldWidgetConstraintValidatorTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/FieldWidgetConstraintValidatorTest.php @@ -44,7 +44,7 @@ public function testValidation() { $display->buildForm($entity, $form, $form_state); // Pretend the form has been built. - $form_state->setFormObject(\Drupal::entityManager()->getFormObject($entity_type, 'default')); + $form_state->setFormObject(\Drupal::entityTypeManager()->getFormObject($entity_type, 'default')); \Drupal::formBuilder()->prepareForm('field_test_entity_form', $form, $form_state); \Drupal::formBuilder()->processForm('field_test_entity_form', $form, $form_state); @@ -81,7 +81,7 @@ protected function getErrorsForEntity(EntityInterface $entity, $hidden_fields = $form_state = new FormState(); $display->buildForm($entity, $form, $form_state); - $form_state->setFormObject(\Drupal::entityManager()->getFormObject($entity_type_id, 'default')); + $form_state->setFormObject(\Drupal::entityTypeManager()->getFormObject($entity_type_id, 'default')); \Drupal::formBuilder()->prepareForm('field_test_entity_form', $form, $form_state); \Drupal::formBuilder()->processForm('field_test_entity_form', $form, $form_state); diff --git a/core/tests/Drupal/KernelTests/Core/Entity/RevisionableContentEntityBaseTest.php b/core/tests/Drupal/KernelTests/Core/Entity/RevisionableContentEntityBaseTest.php index 941e937c00..a95e5a55a7 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/RevisionableContentEntityBaseTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/RevisionableContentEntityBaseTest.php @@ -42,7 +42,7 @@ protected function setUp() { */ public function testRevisionableContentEntity() { $entity_type = 'entity_test_mul_revlog'; - $definition = \Drupal::entityManager()->getDefinition($entity_type); + $definition = \Drupal::entityTypeManager()->getDefinition($entity_type); $user = User::create(['name' => 'test name']); $user->save(); /** @var \Drupal\entity_test_mul_revlog\Entity\EntityTestMulWithRevisionLog $entity */ diff --git a/core/tests/Drupal/KernelTests/Core/Menu/MenuLinkTreeTest.php b/core/tests/Drupal/KernelTests/Core/Menu/MenuLinkTreeTest.php index a998f0fea8..42d8110e19 100644 --- a/core/tests/Drupal/KernelTests/Core/Menu/MenuLinkTreeTest.php +++ b/core/tests/Drupal/KernelTests/Core/Menu/MenuLinkTreeTest.php @@ -61,12 +61,12 @@ protected function setUp() { * Tests deleting all the links in a menu. */ public function testDeleteLinksInMenu() { - \Drupal::entityManager()->getStorage('menu')->create(['id' => 'menu1'])->save(); - \Drupal::entityManager()->getStorage('menu')->create(['id' => 'menu2'])->save(); + \Drupal::entityTypeManager()->getStorage('menu')->create(['id' => 'menu1'])->save(); + \Drupal::entityTypeManager()->getStorage('menu')->create(['id' => 'menu2'])->save(); - \Drupal::entityManager()->getStorage('menu_link_content')->create(['link' => ['uri' => 'internal:/menu_name_test'], 'menu_name' => 'menu1', 'bundle' => 'menu_link_content', 'title' => 'Link test'])->save(); - \Drupal::entityManager()->getStorage('menu_link_content')->create(['link' => ['uri' => 'internal:/menu_name_test'], 'menu_name' => 'menu1', 'bundle' => 'menu_link_content', 'title' => 'Link test'])->save(); - \Drupal::entityManager()->getStorage('menu_link_content')->create(['link' => ['uri' => 'internal:/menu_name_test'], 'menu_name' => 'menu2', 'bundle' => 'menu_link_content', 'title' => 'Link test'])->save(); + \Drupal::entityTypeManager()->getStorage('menu_link_content')->create(['link' => ['uri' => 'internal:/menu_name_test'], 'menu_name' => 'menu1', 'bundle' => 'menu_link_content', 'title' => 'Link test'])->save(); + \Drupal::entityTypeManager()->getStorage('menu_link_content')->create(['link' => ['uri' => 'internal:/menu_name_test'], 'menu_name' => 'menu1', 'bundle' => 'menu_link_content', 'title' => 'Link test'])->save(); + \Drupal::entityTypeManager()->getStorage('menu_link_content')->create(['link' => ['uri' => 'internal:/menu_name_test'], 'menu_name' => 'menu2', 'bundle' => 'menu_link_content', 'title' => 'Link test'])->save(); $output = $this->linkTree->load('menu1', new MenuTreeParameters()); $this->assertEqual(count($output), 2); diff --git a/core/tests/Drupal/Tests/Core/DrupalTest.php b/core/tests/Drupal/Tests/Core/DrupalTest.php index 53f40af8f3..eccbf57ce3 100644 --- a/core/tests/Drupal/Tests/Core/DrupalTest.php +++ b/core/tests/Drupal/Tests/Core/DrupalTest.php @@ -79,6 +79,7 @@ public function testCurrentUser() { * Tests the entityManager() method. * * @covers ::entityManager + * @group legacy */ public function testEntityManager() { $this->setMockContainerService('entity.manager'); diff --git a/core/tests/Drupal/Tests/Core/Session/UserSessionTest.php b/core/tests/Drupal/Tests/Core/Session/UserSessionTest.php index 4ae5182903..aa5807f8f9 100644 --- a/core/tests/Drupal/Tests/Core/Session/UserSessionTest.php +++ b/core/tests/Drupal/Tests/Core/Session/UserSessionTest.php @@ -110,13 +110,13 @@ protected function setUp() { [['anonymous', 'role_one', 'role_two'], [$roles['role_one'], $roles['role_two']]], ])); - $entity_manager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface'); - $entity_manager->expects($this->any()) + $entity_type_manager = $this->getMock('Drupal\Core\Entity\EntityTypeManagerInterface'); + $entity_type_manager->expects($this->any()) ->method('getStorage') ->with($this->equalTo('user_role')) ->will($this->returnValue($role_storage)); $container = new ContainerBuilder(); - $container->set('entity.manager', $entity_manager); + $container->set('entity_type.manager', $entity_type_manager); \Drupal::setContainer($container); $this->users['user_one'] = $this->createUserSession(['role_one']);