diff --git a/core/core.api.php b/core/core.api.php index 4f937e375fb..cfb8800728e 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/install.core.inc b/core/includes/install.core.inc index ffdaaf319e4..92bf908e7ac 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.php b/core/lib/Drupal.php index fbbfba7e0e8..b33e0bc040b 100644 --- a/core/lib/Drupal.php +++ b/core/lib/Drupal.php @@ -270,6 +270,7 @@ class Drupal { * correct interface or service. */ public static function entityManager() { + @trigger_error("\Drupal::entityManager() is deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal::entityTypeManager() instead in most cases. If the needed method is not on \Drupal\Core\Entity\EntityTypeManagerInterface, see the deprecated \Drupal\Core\Entity\EntityManager to find the correct interface or service. See https://www.drupal.org/node/2549139", E_USER_DEPRECATED); return static::getContainer()->get('entity.manager'); } diff --git a/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php b/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php index 3aabc9f5168..26bdf67b32a 100644 --- a/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php +++ b/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php @@ -96,7 +96,7 @@ class EntityFormDisplay extends EntityDisplayBase implements EntityFormDisplayIn ->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); diff --git a/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php b/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php index 8ae9e72821a..00800b58395 100644 --- a/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php +++ b/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php @@ -112,7 +112,7 @@ class EntityViewDisplay extends EntityDisplayBase implements EntityViewDisplayIn } // 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 @@ class EntityViewDisplay extends EntityDisplayBase implements EntityViewDisplayIn 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/EntityDisplayModeBase.php b/core/lib/Drupal/Core/Entity/EntityDisplayModeBase.php index c6ec9169e28..a611487fa1c 100644 --- a/core/lib/Drupal/Core/Entity/EntityDisplayModeBase.php +++ b/core/lib/Drupal/Core/Entity/EntityDisplayModeBase.php @@ -86,7 +86,7 @@ abstract class EntityDisplayModeBase extends ConfigEntityBase implements EntityD */ 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; } diff --git a/core/lib/Drupal/Core/Entity/EntityStorageBase.php b/core/lib/Drupal/Core/Entity/EntityStorageBase.php index 2ceb19c2b1f..1a27a7738ac 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 71aea12b804..db0def37dec 100644 --- a/core/lib/Drupal/Core/Entity/EntityType.php +++ b/core/lib/Drupal/Core/Entity/EntityType.php @@ -910,7 +910,7 @@ class EntityType extends PluginDefinition implements EntityTypeInterface { // 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/EntityTypeManager.php b/core/lib/Drupal/Core/Entity/EntityTypeManager.php index 5544e4a43db..6ae723f8d79 100644 --- a/core/lib/Drupal/Core/Entity/EntityTypeManager.php +++ b/core/lib/Drupal/Core/Entity/EntityTypeManager.php @@ -232,7 +232,7 @@ class EntityTypeManager extends DefaultPluginManager implements EntityTypeManage ->setOperation($operation) // The entity manager cannot be injected due to a circular dependency. // @todo Remove this set call in https://www.drupal.org/node/2603542. - ->setEntityManager(\Drupal::entityManager()); + ->setEntityManager(\Drupal::service('entity.manager')); } /** 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 28d81ba6e4d..5a7b4b90c63 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 @@ class EntityChangedConstraintValidator extends ConstraintValidator { 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 7860c90d654..eec95bca50a 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 @@ class ReferenceAccessConstraintValidator extends ConstraintValidator { $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 cbd2b00f346..74463ee2c3c 100644 --- a/core/lib/Drupal/Core/Entity/TypedData/EntityDataDefinition.php +++ b/core/lib/Drupal/Core/Entity/TypedData/EntityDataDefinition.php @@ -70,7 +70,7 @@ class EntityDataDefinition extends ComplexDataDefinitionBase implements EntityDa 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 = []; } diff --git a/core/lib/Drupal/Core/Entity/entity.api.php b/core/lib/Drupal/Core/Entity/entity.api.php index 846c757128d..74ddd1b4d70 100644 --- a/core/lib/Drupal/Core/Entity/entity.api.php +++ b/core/lib/Drupal/Core/Entity/entity.api.php @@ -580,7 +580,7 @@ use Drupal\node\Entity\NodeType; * 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/module.api.php b/core/lib/Drupal/Core/Extension/module.api.php index 572ba8a3af8..74580705f6f 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 7ffb8ba57b8..1178cb007b9 100644 --- a/core/lib/Drupal/Core/Field/Entity/BaseFieldOverride.php +++ b/core/lib/Drupal/Core/Field/Entity/BaseFieldOverride.php @@ -64,7 +64,7 @@ class BaseFieldOverride extends FieldConfigBase { $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); } /** @@ -238,7 +238,7 @@ class BaseFieldOverride extends FieldConfigBase { * 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 3fa199b7276..07449e8e913 100644 --- a/core/lib/Drupal/Core/Field/EntityReferenceFieldItemList.php +++ b/core/lib/Drupal/Core/Field/EntityReferenceFieldItemList.php @@ -43,7 +43,7 @@ class EntityReferenceFieldItemList extends FieldItemList implements EntityRefere // 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 @@ class EntityReferenceFieldItemList extends FieldItemList implements EntityRefere $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 @@ class EntityReferenceFieldItemList extends FieldItemList implements EntityRefere } $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 5aa4ad11d3c..a6e4092a858 100644 --- a/core/lib/Drupal/Core/Field/FieldItemBase.php +++ b/core/lib/Drupal/Core/Field/FieldItemBase.php @@ -184,7 +184,7 @@ abstract class FieldItemBase extends Map implements FieldItemInterface { * {@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 5dd4f376bf2..ae7298e43cf 100644 --- a/core/lib/Drupal/Core/Field/FieldItemList.php +++ b/core/lib/Drupal/Core/Field/FieldItemList.php @@ -150,7 +150,7 @@ class FieldItemList extends ItemList implements FieldItemListInterface { * {@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 @@ class FieldItemList extends ItemList implements FieldItemListInterface { * {@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 9333d7e2275..b04cf9d91d9 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 @@ class EntityReferenceEntityFormatter extends EntityReferenceFormatterBase implem // 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 d2a691f0773..1db3f0ed9af 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 @@ abstract class EntityReferenceFormatterBase extends FormatterBase { } 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 4951c232db3..758013f494e 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 147bb62a772..bc7f554c33d 100644 --- a/core/lib/Drupal/Core/Session/AccountProxy.php +++ b/core/lib/Drupal/Core/Session/AccountProxy.php @@ -195,7 +195,7 @@ class AccountProxy implements AccountProxyInterface { * 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 ec002beb732..ba3b929a4c7 100644 --- a/core/lib/Drupal/Core/Session/UserSession.php +++ b/core/lib/Drupal/Core/Session/UserSession.php @@ -203,7 +203,7 @@ class UserSession implements AccountInterface { * 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 74e795efaed..082681ed762 100644 --- a/core/modules/aggregator/aggregator.module +++ b/core/modules/aggregator/aggregator.module @@ -143,7 +143,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 e653008458f..4c3a5b856e1 100644 --- a/core/modules/aggregator/src/Entity/Feed.php +++ b/core/modules/aggregator/src/Entity/Feed.php @@ -125,7 +125,7 @@ class Feed extends ContentEntityBase implements FeedInterface { ->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 8e6ade467dd..2f95f69db96 100644 --- a/core/modules/aggregator/tests/src/Functional/FeedProcessorPluginTest.php +++ b/core/modules/aggregator/tests/src/Functional/FeedProcessorPluginTest.php @@ -57,7 +57,7 @@ class FeedProcessorPluginTest extends AggregatorTestBase { $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 0d49ead480b..e9e332ad086 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 9c2c1b44b79..c34e30f0854 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 @@ class BlockContentTranslationUITest extends ContentTranslationUITestBase { // 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/PageEditTest.php b/core/modules/block_content/tests/src/Functional/PageEditTest.php index f623cfa28ac..e751c70b097 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 @@ class PageEditTest extends BlockContentTestBase { $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 7d703bae511..8bb1bb38a5a 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 a863ff1529f..5271c8e7b87 100644 --- a/core/modules/book/tests/src/Functional/BookBreadcrumbTest.php +++ b/core/modules/book/tests/src/Functional/BookBreadcrumbTest.php @@ -118,7 +118,7 @@ class BookBreadcrumbTest extends BrowserTestBase { $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 972c240ceb5..92dfa00425a 100644 --- a/core/modules/book/tests/src/Functional/BookTest.php +++ b/core/modules/book/tests/src/Functional/BookTest.php @@ -405,7 +405,7 @@ class BookTest extends BrowserTestBase { $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()); @@ -428,7 +428,7 @@ class BookTest extends BrowserTestBase { $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()); @@ -519,7 +519,7 @@ class BookTest extends BrowserTestBase { $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 edc6cbfe67e..67520c4851f 100644 --- a/core/modules/book/tests/src/Functional/BookTestTrait.php +++ b/core/modules/book/tests/src/Functional/BookTestTrait.php @@ -198,7 +198,7 @@ trait BookTestTrait { $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 9ee79c78dc6..30b8a8445a1 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 @@ class BookRelationshipTest extends ViewTestBase { $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 35732728153..051f335c809 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(); } } @@ -357,7 +357,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)) { @@ -426,7 +426,7 @@ 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; @@ -453,7 +453,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')) { @@ -477,10 +477,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 11abede944c..e5df31a1a05 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 7fb74217c4c..956a33544b0 100644 --- a/core/modules/comment/src/CommentViewsData.php +++ b/core/modules/comment/src/CommentViewsData.php @@ -193,7 +193,7 @@ class CommentViewsData extends EntityViewsData { 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 444033caf54..b1a3de16f41 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 @@ namespace Drupal\comment\Plugin\views\field; 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 @@ class NodeNewComments extends NumericField { */ 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 @@ class NodeNewComments extends NumericField { * 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 @@ class NodeNewComments extends NumericField { // 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_type_manager = \Drupal::entityTypeManager(); - $field_map = \Drupal::service('entity_field.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 @@ class NodeNewComments extends NumericField { } } } - $page_number = $entity_type_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 b3c3d990b15..4c239816047 100644 --- a/core/modules/comment/src/Tests/CommentTestBase.php +++ b/core/modules/comment/src/Tests/CommentTestBase.php @@ -176,7 +176,7 @@ abstract class CommentTestBase extends WebTestBase { } 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/CommentPagerTest.php b/core/modules/comment/tests/src/Functional/CommentPagerTest.php index ff5f17cf455..3c4d46b1c11 100644 --- a/core/modules/comment/tests/src/Functional/CommentPagerTest.php +++ b/core/modules/comment/tests/src/Functional/CommentPagerTest.php @@ -283,7 +283,7 @@ class CommentPagerTest extends CommentTestBase { $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 @@ class CommentPagerTest extends CommentTestBase { 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 cee08ae39c9..c64eeaa6db4 100644 --- a/core/modules/comment/tests/src/Functional/CommentPreviewTest.php +++ b/core/modules/comment/tests/src/Functional/CommentPreviewTest.php @@ -185,7 +185,7 @@ class CommentPreviewTest extends CommentTestBase { $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 9574681872e..e9907b3bea1 100644 --- a/core/modules/comment/tests/src/Functional/CommentTestBase.php +++ b/core/modules/comment/tests/src/Functional/CommentTestBase.php @@ -171,7 +171,7 @@ abstract class CommentTestBase extends BrowserTestBase { } 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 68a60a47904..2d7787e7446 100644 --- a/core/modules/comment/tests/src/Functional/CommentTranslationUITest.php +++ b/core/modules/comment/tests/src/Functional/CommentTranslationUITest.php @@ -125,8 +125,8 @@ class CommentTranslationUITest extends ContentTranslationUITestBase { * {@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 04173c43cb9..c2eeb928cf8 100644 --- a/core/modules/comment/tests/src/Functional/CommentTypeTest.php +++ b/core/modules/comment/tests/src/Functional/CommentTypeTest.php @@ -84,7 +84,7 @@ class CommentTypeTest extends CommentTestBase { // 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 bdea71df15f..e681a4d9ad6 100644 --- a/core/modules/comment/tests/src/Kernel/CommentDefaultFormatterCacheTagsTest.php +++ b/core/modules/comment/tests/src/Kernel/CommentDefaultFormatterCacheTagsTest.php @@ -74,7 +74,7 @@ class CommentDefaultFormatterCacheTagsTest extends EntityKernelTestBase { $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 @@ class CommentDefaultFormatterCacheTagsTest extends EntityKernelTestBase { $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 @@ class CommentDefaultFormatterCacheTagsTest extends EntityKernelTestBase { // 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 67bbda8fb61..411ad546084 100644 --- a/core/modules/comment/tests/src/Kernel/CommentValidationTest.php +++ b/core/modules/comment/tests/src/Kernel/CommentValidationTest.php @@ -138,7 +138,7 @@ class CommentValidationTest extends EntityKernelTestBase { $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->entityTypeManager->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 3b0674222cd..fdb415e46ee 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 @@ class MigrateCommentStubTest extends MigrateDrupalTestBase { $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 30a8a64ffa2..1a8db39d4b3 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 @@ class CommentUserNameTest extends ViewsKernelTestBase { $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 7c5fa1fac19..cf9ff99f221 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 b92629d1977..16fcc89dd64 100644 --- a/core/modules/config/tests/src/Functional/ConfigEntityListTest.php +++ b/core/modules/config/tests/src/Functional/ConfigEntityListTest.php @@ -30,7 +30,7 @@ class ConfigEntityListTest extends BrowserTestBase { 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 @@ class ConfigEntityListTest extends BrowserTestBase { * Tests entity list builder methods. */ public function testList() { - $controller = \Drupal::entityManager()->getListBuilder('config_test'); + $controller = \Drupal::entityTypeManager()->getListBuilder('config_test'); // Test getStorage() method. $this->assertTrue($controller->getStorage() instanceof EntityStorageInterface, 'EntityStorage instance in storage.'); @@ -252,7 +252,7 @@ class ConfigEntityListTest extends BrowserTestBase { public function testPager() { $this->drupalLogin($this->drupalCreateUser(['administer site configuration'])); - $storage = \Drupal::entityManager()->getListBuilder('config_test')->getStorage(); + $storage = \Drupal::service('entity_type.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 8615da5865b..167d2a7e26e 100644 --- a/core/modules/config/tests/src/Functional/ConfigInstallProfileOverrideTest.php +++ b/core/modules/config/tests/src/Functional/ConfigInstallProfileOverrideTest.php @@ -94,7 +94,7 @@ class ConfigInstallProfileOverrideTest extends BrowserTestBase { // 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 @@ class ConfigInstallProfileOverrideTest extends BrowserTestBase { // 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 69a7ed74ea2..65e76e05835 100644 --- a/core/modules/config/tests/src/Functional/ConfigSingleImportExportTest.php +++ b/core/modules/config/tests/src/Functional/ConfigSingleImportExportTest.php @@ -36,7 +36,7 @@ class ConfigSingleImportExportTest extends BrowserTestBase { * 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 @@ EOD; $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 f97e25997ad..8e337309c02 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 e6818386e0a..5ca9313f717 100644 --- a/core/modules/config_translation/config_translation.module +++ b/core/modules/config_translation/config_translation.module @@ -102,13 +102,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'] = [ @@ -123,7 +123,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 9ccbb135d2f..e4aae1a6bce 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 @@ class ConfigTranslationOverviewTest extends BrowserTestBase { $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 e7343b9166c..f3025e7b1ce 100644 --- a/core/modules/contact/tests/src/Kernel/MessageEntityTest.php +++ b/core/modules/contact/tests/src/Kernel/MessageEntityTest.php @@ -62,8 +62,8 @@ class MessageEntityTest extends EntityKernelTestBase { $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.module b/core/modules/content_translation/content_translation.module index 8ebe702ed41..10f546dfd52 100644 --- a/core/modules/content_translation/content_translation.module +++ b/core/modules/content_translation/content_translation.module @@ -334,7 +334,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) { @@ -393,7 +393,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 @@ -454,7 +454,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 2f4158bec2a..d7f18c4c766 100644 --- a/core/modules/content_translation/src/Tests/ContentTranslationTestBase.php +++ b/core/modules/content_translation/src/Tests/ContentTranslationTestBase.php @@ -127,7 +127,7 @@ abstract class ContentTranslationTestBase extends WebTestBase { * 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 @@ abstract class ContentTranslationTestBase extends WebTestBase { // picked up. \Drupal::service('content_translation.manager')->setEnabled($this->entityTypeId, $this->bundle, TRUE); - \Drupal::entityManager()->clearCachedDefinitions(); + \Drupal::entityTypeManager()->clearCachedDefinitions(); \Drupal::service('router.builder')->rebuild(); } @@ -224,7 +224,7 @@ abstract class ContentTranslationTestBase extends WebTestBase { 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/ContentTranslationOperationsTest.php b/core/modules/content_translation/tests/src/Functional/ContentTranslationOperationsTest.php index fc0f788a6a9..8486ac529ff 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 @@ class ContentTranslationOperationsTest extends NodeTestBase { * @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/ContentTranslationTestBase.php b/core/modules/content_translation/tests/src/Functional/ContentTranslationTestBase.php index 5c9fc23ee6e..7451e17dbad 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 @@ abstract class ContentTranslationTestBase extends BrowserTestBase { * 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}"; } @@ -218,7 +218,7 @@ abstract class ContentTranslationTestBase extends BrowserTestBase { 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/editor/editor.module b/core/modules/editor/editor.module index 43cb782f354..619d01f9b79 100644 --- a/core/modules/editor/editor.module +++ b/core/modules/editor/editor.module @@ -624,7 +624,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 07c9d24aa87..5d60313a427 100644 --- a/core/modules/editor/src/Entity/Editor.php +++ b/core/modules/editor/src/Entity/Editor.php @@ -127,7 +127,7 @@ class Editor extends ConfigEntityBase implements EditorInterface { */ 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 6500d1adefd..0d0ecaaa605 100644 --- a/core/modules/editor/tests/src/Kernel/EditorImageDialogTest.php +++ b/core/modules/editor/tests/src/Kernel/EditorImageDialogTest.php @@ -108,7 +108,7 @@ class EditorImageDialogTest extends EntityKernelTestBase { ->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 37b6517a52c..987727a9b8d 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 @@ -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 a2b2b929758..11b2ac11a63 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 c38fc4b1363..22bf7c2058a 100644 --- a/core/modules/field/src/ConfigImporterFieldPurger.php +++ b/core/modules/field/src/ConfigImporterFieldPurger.php @@ -71,7 +71,7 @@ class ConfigImporterFieldPurger { $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 @@ class ConfigImporterFieldPurger { // 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 411943b11c2..2e06d2a4727 100644 --- a/core/modules/field/src/Entity/FieldConfig.php +++ b/core/modules/field/src/Entity/FieldConfig.php @@ -147,7 +147,6 @@ class FieldConfig extends FieldConfigBase implements FieldConfigInterface { * 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(); @@ -248,7 +247,7 @@ class FieldConfig extends FieldConfigBase implements FieldConfigInterface { } } if ($storages_to_delete) { - \Drupal::entityManager()->getStorage('field_storage_config')->delete($storages_to_delete); + \Drupal::entityTypeManager()->getStorage('field_storage_config')->delete($storages_to_delete); } } @@ -274,7 +273,7 @@ class FieldConfig extends FieldConfigBase implements FieldConfigInterface { */ 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; @@ -372,7 +371,7 @@ class FieldConfig extends FieldConfigBase implements FieldConfigInterface { * 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 3277c541697..2c02eebf442 100644 --- a/core/modules/field/src/Entity/FieldStorageConfig.php +++ b/core/modules/field/src/Entity/FieldStorageConfig.php @@ -351,7 +351,7 @@ class FieldStorageConfig extends ConfigEntityBase implements FieldStorageConfigI $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; } @@ -389,10 +389,10 @@ class FieldStorageConfig extends ConfigEntityBase implements FieldStorageConfigI 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(); } } } @@ -707,7 +707,7 @@ class FieldStorageConfig extends ConfigEntityBase implements FieldStorageConfigI * 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); } /** @@ -806,7 +806,7 @@ class FieldStorageConfig extends ConfigEntityBase implements FieldStorageConfigI * 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/EntityReferenceIntegrationTest.php b/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceIntegrationTest.php index 40d0bfa4720..39dd1632db3 100644 --- a/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceIntegrationTest.php +++ b/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceIntegrationTest.php @@ -163,7 +163,7 @@ class EntityReferenceIntegrationTest extends BrowserTestBase { // 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 20544419e6c..7b6fabe488c 100644 --- a/core/modules/field/tests/src/FunctionalJavascript/EntityReference/EntityReferenceAdminTest.php +++ b/core/modules/field/tests/src/FunctionalJavascript/EntityReference/EntityReferenceAdminTest.php @@ -84,7 +84,7 @@ class EntityReferenceAdminTest extends WebDriverTestBase { $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 1c5a4aea4b5..fb0e87d0f00 100644 --- a/core/modules/field/tests/src/Kernel/BulkDeleteTest.php +++ b/core/modules/field/tests/src/Kernel/BulkDeleteTest.php @@ -278,7 +278,7 @@ class BulkDeleteTest extends FieldKernelTestBase { } // 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 2b191e9c792..b42d83c13db 100644 --- a/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceFormatterTest.php +++ b/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceFormatterTest.php @@ -213,7 +213,7 @@ class EntityReferenceFormatterTest extends EntityKernelTestBase { '; $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 5c8c667f5e5..f8f57dfe8b9 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 @@ class EntityReferenceItemTest extends FieldKernelTestBase { $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 c3b1f930545..a8b087461d8 100644 --- a/core/modules/field/tests/src/Kernel/FieldAttachOtherTest.php +++ b/core/modules/field/tests/src/Kernel/FieldAttachOtherTest.php @@ -343,7 +343,7 @@ class FieldAttachOtherTest extends FieldKernelTestBase { $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 04d997d77d6..7aa6359c7f7 100644 --- a/core/modules/field/tests/src/Kernel/FieldAttachStorageTest.php +++ b/core/modules/field/tests/src/Kernel/FieldAttachStorageTest.php @@ -127,7 +127,7 @@ class FieldAttachStorageTest extends FieldKernelTestBase { } // 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/FieldDataCountTest.php b/core/modules/field/tests/src/Kernel/FieldDataCountTest.php index 82ef6d09f0a..3224763293f 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 @@ class FieldDataCountTest extends FieldKernelTestBase { $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 b4180a0170c..cfede1e3861 100644 --- a/core/modules/field/tests/src/Kernel/FieldImportDeleteTest.php +++ b/core/modules/field/tests/src/Kernel/FieldImportDeleteTest.php @@ -82,19 +82,19 @@ class FieldImportDeleteTest extends FieldKernelTestBase { $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 65dcd9aa5af..92dd7d7a31d 100644 --- a/core/modules/field/tests/src/Kernel/FieldKernelTestBase.php +++ b/core/modules/field/tests/src/Kernel/FieldKernelTestBase.php @@ -52,7 +52,7 @@ abstract class FieldKernelTestBase extends KernelTestBase { $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 1734a7213b9..d7a771729d5 100644 --- a/core/modules/field/tests/src/Kernel/Timestamp/TimestampFormatterTest.php +++ b/core/modules/field/tests/src/Kernel/Timestamp/TimestampFormatterTest.php @@ -103,7 +103,7 @@ class TimestampFormatterTest extends KernelTestBase { $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 31ee4b41fde..605c5574b4a 100644 --- a/core/modules/field/tests/src/Kernel/TranslationTest.php +++ b/core/modules/field/tests/src/Kernel/TranslationTest.php @@ -109,7 +109,7 @@ class TranslationTest extends FieldKernelTestBase { 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. @@ -203,7 +203,7 @@ class TranslationTest extends FieldKernelTestBase { * @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 a73f1532716..488be766b20 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 b9351a4b77f..0d5d7771dc3 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/file/file.module b/core/modules/file/file.module index b3df3718185..93b277f3e4c 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. diff --git a/core/modules/file/file.views.inc b/core/modules/file/file.views.inc index 8e45101bd84..f2c2482f564 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 c7cf0f04e48..ab936177bb3 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 @@ class FileFieldItemList extends EntityReferenceFieldItemList { // 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/tests/src/Functional/FileManagedFileElementTest.php b/core/modules/file/tests/src/Functional/FileManagedFileElementTest.php index 7feaa507dab..2b448ba7dbf 100644 --- a/core/modules/file/tests/src/Functional/FileManagedFileElementTest.php +++ b/core/modules/file/tests/src/Functional/FileManagedFileElementTest.php @@ -142,7 +142,7 @@ class FileManagedFileElementTest extends FileFieldTestBase { $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/FilePrivateTest.php b/core/modules/file/tests/src/Functional/FilePrivateTest.php index 2e5b0a1dac5..7a6824b1323 100644 --- a/core/modules/file/tests/src/Functional/FilePrivateTest.php +++ b/core/modules/file/tests/src/Functional/FilePrivateTest.php @@ -46,7 +46,7 @@ class FilePrivateTest extends FileFieldTestBase { $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 @@ class FilePrivateTest extends FileFieldTestBase { // 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 ab31eb757f3..44b2ee10c9c 100644 --- a/core/modules/file/tests/src/Functional/PrivateFileOnTranslatedEntityTest.php +++ b/core/modules/file/tests/src/Functional/PrivateFileOnTranslatedEntityTest.php @@ -87,7 +87,7 @@ class PrivateFileOnTranslatedEntityTest extends FileFieldTestBase { $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 @@ class PrivateFileOnTranslatedEntityTest extends FileFieldTestBase { $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 3246f10db81..4d72ff1625a 100644 --- a/core/modules/filter/filter.module +++ b/core/modules/filter/filter.module @@ -103,9 +103,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 8ce4fa91089..ed6bff8668d 100644 --- a/core/modules/filter/tests/src/Kernel/FilterAPITest.php +++ b/core/modules/filter/tests/src/Kernel/FilterAPITest.php @@ -487,7 +487,7 @@ class FilterAPITest extends EntityKernelTestBase { $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 @@ class FilterAPITest extends EntityKernelTestBase { // 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 108ee648e2e..f75a810b13f 100644 --- a/core/modules/forum/forum.module +++ b/core/modules/forum/forum.module @@ -472,7 +472,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 cca0e3d904d..483f989faf9 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 ba4677d7ea0..3880a689615 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 @@ class ImageItem extends FileItem { 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 2dde5527886..47aa51fa15c 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 @@ class ImageWidget extends FileWidget { 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/jsonapi/tests/src/Functional/JsonApiFunctionalTest.php b/core/modules/jsonapi/tests/src/Functional/JsonApiFunctionalTest.php index b2d6f1033ff..bea8773efbc 100644 --- a/core/modules/jsonapi/tests/src/Functional/JsonApiFunctionalTest.php +++ b/core/modules/jsonapi/tests/src/Functional/JsonApiFunctionalTest.php @@ -748,7 +748,7 @@ class JsonApiFunctionalTest extends JsonApiFunctionalTestBase { $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 0df467dc143..368248c75b6 100644 --- a/core/modules/language/language.module +++ b/core/modules/language/language.module @@ -330,7 +330,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 59803defe1a..509dbaf3c71 100644 --- a/core/modules/language/src/Entity/ContentLanguageSettings.php +++ b/core/modules/language/src/Entity/ContentLanguageSettings.php @@ -190,7 +190,7 @@ class ContentLanguageSettings extends ConfigEntityBase implements ContentLanguag 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]); } @@ -204,7 +204,7 @@ class ContentLanguageSettings extends ConfigEntityBase implements ContentLanguag 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 9e71064c0bd..7d400cab4cb 100644 --- a/core/modules/language/tests/src/Functional/LanguageConfigurationElementTest.php +++ b/core/modules/language/tests/src/Functional/LanguageConfigurationElementTest.php @@ -203,15 +203,15 @@ class LanguageConfigurationElementTest extends BrowserTestBase { $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/menu_link_content/menu_link_content.module b/core/modules/menu_link_content/menu_link_content.module index a0ea8da55bf..559405dfbe9 100644 --- a/core/modules/menu_link_content/menu_link_content.module +++ b/core/modules/menu_link_content/menu_link_content.module @@ -44,7 +44,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); } @@ -66,7 +66,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/src/Tests/MenuWebTestBase.php b/core/modules/menu_ui/src/Tests/MenuWebTestBase.php index a8b9862223d..136b246b1c3 100644 --- a/core/modules/menu_ui/src/Tests/MenuWebTestBase.php +++ b/core/modules/menu_ui/src/Tests/MenuWebTestBase.php @@ -37,7 +37,7 @@ abstract class MenuWebTestBase extends WebTestBase { $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 @@ abstract class MenuWebTestBase extends WebTestBase { 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/MenuUninstallTest.php b/core/modules/menu_ui/tests/src/Functional/MenuUninstallTest.php index a0320f44b0f..b2d64cece5c 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 b0f2fa8a1a1..c3a0506419d 100644 --- a/core/modules/migrate/src/MigrateExecutable.php +++ b/core/modules/migrate/src/MigrateExecutable.php @@ -546,9 +546,9 @@ class MigrateExecutable implements MigrateExecutableInterface { 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 3bf00281a03..5a5fa043325 100644 --- a/core/modules/migrate_drupal/src/Tests/StubTestTrait.php +++ b/core/modules/migrate_drupal/src/Tests/StubTestTrait.php @@ -65,7 +65,7 @@ trait StubTestTrait { * 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 1380d63ae8e..e05c841128f 100644 --- a/core/modules/node/node.install +++ b/core/modules/node/node.install @@ -19,7 +19,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 dfe5370faf2..4560a7c66e8 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -431,7 +431,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); } /** @@ -458,7 +458,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); } @@ -483,7 +483,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); } @@ -772,7 +772,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, @@ -792,7 +792,7 @@ function node_user_predelete($account) { ->accessCheck(FALSE) ->execute(); // Delete old revisions. - $storage_controller = \Drupal::entityManager()->getStorage('node'); + $storage_controller = \Drupal::entityTypeManager()->getStorage('node'); $nodes = $storage_controller->loadMultiple($nids); $storage_controller->delete($nodes); $revisions = $storage_controller->userRevisionIds($account); @@ -1091,7 +1091,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()]; @@ -1235,9 +1235,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'))) { @@ -1301,7 +1301,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; @@ -1328,7 +1328,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); } @@ -1408,7 +1408,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 b3d19d4e89e..88bac5aadd5 100644 --- a/core/modules/node/src/Entity/Node.php +++ b/core/modules/node/src/Entity/Node.php @@ -144,7 +144,7 @@ class Node extends EditorialContentEntityBase implements NodeInterface { // 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/Tests/NodeTestBase.php b/core/modules/node/src/Tests/NodeTestBase.php index e520b3283e7..08e33e6f22d 100644 --- a/core/modules/node/src/Tests/NodeTestBase.php +++ b/core/modules/node/src/Tests/NodeTestBase.php @@ -47,7 +47,7 @@ abstract class NodeTestBase extends WebTestBase { ]); $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/NodeAccessPagerTest.php b/core/modules/node/tests/src/Functional/NodeAccessPagerTest.php index ad6cc549446..6e7e0f216a4 100644 --- a/core/modules/node/tests/src/Functional/NodeAccessPagerTest.php +++ b/core/modules/node/tests/src/Functional/NodeAccessPagerTest.php @@ -74,7 +74,7 @@ class NodeAccessPagerTest extends BrowserTestBase { $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 f5b69208329..1ac6965fca5 100644 --- a/core/modules/node/tests/src/Functional/NodeCreationTest.php +++ b/core/modules/node/tests/src/Functional/NodeCreationTest.php @@ -34,7 +34,7 @@ class NodeCreationTest extends NodeTestBase { * 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(); @@ -248,7 +248,7 @@ class NodeCreationTest extends NodeTestBase { $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 89f891a6431..642fba31b82 100644 --- a/core/modules/node/tests/src/Functional/NodeEditFormTest.php +++ b/core/modules/node/tests/src/Functional/NodeEditFormTest.php @@ -167,7 +167,7 @@ class NodeEditFormTest extends NodeTestBase { // 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 6c508aee68d..64b38610d60 100644 --- a/core/modules/node/tests/src/Functional/NodeSaveTest.php +++ b/core/modules/node/tests/src/Functional/NodeSaveTest.php @@ -44,7 +44,7 @@ class NodeSaveTest extends NodeTestBase { */ 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 dcadf934ded..371cf1c32d6 100644 --- a/core/modules/node/tests/src/Functional/NodeTemplateSuggestionsTest.php +++ b/core/modules/node/tests/src/Functional/NodeTemplateSuggestionsTest.php @@ -18,7 +18,7 @@ class NodeTemplateSuggestionsTest extends NodeTestBase { $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 @@ class NodeTemplateSuggestionsTest extends NodeTestBase { // 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 e52708632b9..264ac31535e 100644 --- a/core/modules/node/tests/src/Functional/NodeTestBase.php +++ b/core/modules/node/tests/src/Functional/NodeTestBase.php @@ -40,7 +40,7 @@ abstract class NodeTestBase extends BrowserTestBase { ]); $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 3348ad9d907..00722fdfff0 100644 --- a/core/modules/node/tests/src/Functional/NodeTranslationUITest.php +++ b/core/modules/node/tests/src/Functional/NodeTranslationUITest.php @@ -279,7 +279,7 @@ class NodeTranslationUITest extends ContentTranslationUITestBase { $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 @@ class NodeTranslationUITest extends ContentTranslationUITestBase { $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 19c409719d0..a51fe21b747 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 @@ class BulkFormAccessTest extends NodeTestBase { // 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 3a3c5723a68..2dc97b00c33 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/MigrateNodeRevisionTest.php b/core/modules/node/tests/src/Kernel/Migrate/d6/MigrateNodeRevisionTest.php index 47366b788a2..131219a710a 100644 --- a/core/modules/node/tests/src/Kernel/Migrate/d6/MigrateNodeRevisionTest.php +++ b/core/modules/node/tests/src/Kernel/Migrate/d6/MigrateNodeRevisionTest.php @@ -26,7 +26,7 @@ class MigrateNodeRevisionTest extends MigrateNodeTestBase { * 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()); @@ -38,7 +38,7 @@ class MigrateNodeRevisionTest extends MigrateNodeTestBase { $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/Kernel/Migrate/d6/MigrateNodeTest.php b/core/modules/node/tests/src/Kernel/Migrate/d6/MigrateNodeTest.php index 997df83b52f..c390af2db4e 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 @@ class MigrateNodeTest extends MigrateNodeTestBase { $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 0e660060321..7caeb724278 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 @@ class MigrateNodeTest extends MigrateDrupal7TestBase { * 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/NodeAccessLanguageTest.php b/core/modules/node/tests/src/Kernel/NodeAccessLanguageTest.php index 1b8699198e6..06709021c62 100644 --- a/core/modules/node/tests/src/Kernel/NodeAccessLanguageTest.php +++ b/core/modules/node/tests/src/Kernel/NodeAccessLanguageTest.php @@ -73,7 +73,7 @@ class NodeAccessLanguageTest extends NodeAccessTestBase { $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.'); @@ -97,7 +97,7 @@ class NodeAccessLanguageTest extends NodeAccessTestBase { $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); @@ -142,7 +142,7 @@ class NodeAccessLanguageTest extends NodeAccessTestBase { $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. @@ -160,7 +160,7 @@ class NodeAccessLanguageTest extends NodeAccessTestBase { $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/quickedit/tests/src/FunctionalJavascript/QuickEditLoadingTest.php b/core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditLoadingTest.php index 3699995dc50..2424374570b 100644 --- a/core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditLoadingTest.php +++ b/core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditLoadingTest.php @@ -138,7 +138,7 @@ class QuickEditLoadingTest extends WebDriverTestBase { $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 @@ class QuickEditLoadingTest extends WebDriverTestBase { $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 a4f268f8120..e33f24a59a5 100644 --- a/core/modules/rdf/src/Entity/RdfMapping.php +++ b/core/modules/rdf/src/Entity/RdfMapping.php @@ -145,7 +145,7 @@ class RdfMapping extends ConfigEntityBase implements RdfMappingInterface { 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 @@ class RdfMapping extends ConfigEntityBase implements RdfMappingInterface { 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/search/tests/src/Functional/SearchConfigSettingsFormTest.php b/core/modules/search/tests/src/Functional/SearchConfigSettingsFormTest.php index 8dccf3e26ab..40aa3e9994f 100644 --- a/core/modules/search/tests/src/Functional/SearchConfigSettingsFormTest.php +++ b/core/modules/search/tests/src/Functional/SearchConfigSettingsFormTest.php @@ -228,7 +228,7 @@ class SearchConfigSettingsFormTest extends BrowserTestBase { */ 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 eff749805a5..5cd9fa8f7d2 100644 --- a/core/modules/serialization/tests/src/Kernel/EntitySerializationTest.php +++ b/core/modules/serialization/tests/src/Kernel/EntitySerializationTest.php @@ -88,7 +88,7 @@ class EntitySerializationTest extends NormalizerTestBase { ])->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 c60e4567310..c5c609c38f5 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 3941eb3621d..1b281b2b02b 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 819f6475dd5..fba28ac41e1 100644 --- a/core/modules/shortcut/src/Entity/ShortcutSet.php +++ b/core/modules/shortcut/src/Entity/ShortcutSet.php @@ -100,7 +100,7 @@ class ShortcutSet extends ConfigEntityBundleBase implements ShortcutSetInterface ->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 @@ class ShortcutSet extends ConfigEntityBundleBase implements ShortcutSetInterface * {@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 584a6154c30..6f89201937e 100644 --- a/core/modules/shortcut/src/Tests/ShortcutTestBase.php +++ b/core/modules/shortcut/src/Tests/ShortcutTestBase.php @@ -94,7 +94,7 @@ abstract class ShortcutTestBase extends WebTestBase { // 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 @@ abstract class ShortcutTestBase extends WebTestBase { */ 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 b897df752db..636813cc8f5 100644 --- a/core/modules/shortcut/tests/src/Functional/ShortcutSetsTest.php +++ b/core/modules/shortcut/tests/src/Functional/ShortcutSetsTest.php @@ -91,7 +91,7 @@ class ShortcutSetsTest extends ShortcutTestBase { $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 @@ class ShortcutSetsTest extends ShortcutTestBase { 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 @@ class ShortcutSetsTest extends ShortcutTestBase { 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 3f9cc87be38..c11c418ae9a 100644 --- a/core/modules/shortcut/tests/src/Functional/ShortcutTestBase.php +++ b/core/modules/shortcut/tests/src/Functional/ShortcutTestBase.php @@ -87,7 +87,7 @@ abstract class ShortcutTestBase extends BrowserTestBase { // 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 @@ abstract class ShortcutTestBase extends BrowserTestBase { */ 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 c92381fab8d..d34ff91e6e1 100644 --- a/core/modules/simpletest/src/Tests/KernelTestBaseTest.php +++ b/core/modules/simpletest/src/Tests/KernelTestBaseTest.php @@ -240,7 +240,7 @@ EOS; 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 6b3e3c4ab12..2aa64e86940 100644 --- a/core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php +++ b/core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php @@ -210,7 +210,7 @@ abstract class EntityCacheTagsTestBase extends PageCacheTagsTestBase { * chooses 'default'. */ protected function selectViewMode($entity_type) { - $view_modes = \Drupal::entityManager() + $view_modes = \Drupal::entityTypeManager() ->getStorage('entity_view_mode') ->loadByProperties(['targetEntityType' => $entity_type]); @@ -295,7 +295,7 @@ abstract class EntityCacheTagsTestBase extends PageCacheTagsTestBase { } // 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([ @@ -362,7 +362,7 @@ abstract class EntityCacheTagsTestBase extends PageCacheTagsTestBase { $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(); } @@ -370,7 +370,7 @@ abstract class EntityCacheTagsTestBase extends PageCacheTagsTestBase { $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)); @@ -378,7 +378,7 @@ abstract class EntityCacheTagsTestBase extends PageCacheTagsTestBase { $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. @@ -640,7 +640,7 @@ abstract class EntityCacheTagsTestBase extends PageCacheTagsTestBase { $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 a3006b498b4..1e2fb6145db 100644 --- a/core/modules/system/src/Tests/Entity/EntityWithUriCacheTagsTestBase.php +++ b/core/modules/system/src/Tests/Entity/EntityWithUriCacheTagsTestBase.php @@ -38,7 +38,7 @@ abstract class EntityWithUriCacheTagsTestBase extends EntityCacheTagsTestBase { // 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 @@ abstract class EntityWithUriCacheTagsTestBase extends EntityCacheTagsTestBase { // 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 ceff294c9ce..b7f99d9bf98 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 0ee7e35b871..9a080bfa3b6 100644 --- a/core/modules/system/tests/modules/entity_test/entity_test.module +++ b/core/modules/system/tests/modules/entity_test/entity_test.module @@ -221,7 +221,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']]; @@ -254,7 +254,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] = [ @@ -277,7 +277,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 488fa6ef42e..6843e54f753 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 @@ class DrupalDateTimeTest extends BrowserTestBase { $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 453af58fd59..e92b6470016 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 @@ abstract class EntityCacheTagsTestBase extends PageCacheTagsTestBase { * chooses 'default'. */ protected function selectViewMode($entity_type) { - $view_modes = \Drupal::entityManager() + $view_modes = \Drupal::entityTypeManager() ->getStorage('entity_view_mode') ->loadByProperties(['targetEntityType' => $entity_type]); @@ -287,7 +287,7 @@ abstract class EntityCacheTagsTestBase extends PageCacheTagsTestBase { } // 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([ @@ -354,7 +354,7 @@ abstract class EntityCacheTagsTestBase extends PageCacheTagsTestBase { $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(); } @@ -362,7 +362,7 @@ abstract class EntityCacheTagsTestBase extends PageCacheTagsTestBase { $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)); @@ -370,7 +370,7 @@ abstract class EntityCacheTagsTestBase extends PageCacheTagsTestBase { $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. @@ -633,7 +633,7 @@ abstract class EntityCacheTagsTestBase extends PageCacheTagsTestBase { $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 a102e6f7940..e62d343ced9 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 @@ abstract class EntityWithUriCacheTagsTestBase extends EntityCacheTagsTestBase { // 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 @@ abstract class EntityWithUriCacheTagsTestBase extends EntityCacheTagsTestBase { // 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/Entity/Update/SqlContentEntityStorageSchemaConverterTestBase.php b/core/modules/system/tests/src/Functional/Entity/Update/SqlContentEntityStorageSchemaConverterTestBase.php index 05876bff62f..33f2ca5cd18 100644 --- a/core/modules/system/tests/src/Functional/Entity/Update/SqlContentEntityStorageSchemaConverterTestBase.php +++ b/core/modules/system/tests/src/Functional/Entity/Update/SqlContentEntityStorageSchemaConverterTestBase.php @@ -14,13 +14,6 @@ abstract class SqlContentEntityStorageSchemaConverterTestBase extends UpdatePath use EntityDefinitionTestTrait; use ExpectDeprecationTrait; - /** - * The entity manager service. - * - * @var \Drupal\Core\Entity\EntityManagerInterface - */ - protected $entityManager; - /** * The entity definition update manager. * @@ -55,7 +48,6 @@ abstract class SqlContentEntityStorageSchemaConverterTestBase extends UpdatePath protected function setUp() { parent::setUp(); - $this->entityManager = \Drupal::entityManager(); $this->entityDefinitionUpdateManager = \Drupal::entityDefinitionUpdateManager(); $this->lastInstalledSchemaRepository = \Drupal::service('entity.last_installed_schema.repository'); $this->installedStorageSchema = \Drupal::keyValue('entity.storage_schema.sql'); diff --git a/core/modules/system/tests/src/Functional/Menu/LocalTasksTest.php b/core/modules/system/tests/src/Functional/Menu/LocalTasksTest.php index 1a49336777e..fc6e8c1ac09 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 @@ class LocalTasksTest extends BrowserTestBase { // 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 d1f6be457f0..bcdf8ea33df 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 @@ class InstallUninstallTest extends ModuleTestBase { $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 98b96ee91ef..d061646f7e9 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 @@ class UninstallTest extends BrowserTestBase { } $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 15f3608885b..0a365a7a7da 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 @@ class DateTimeTest extends BrowserTestBase { // 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 cfa82210408..ff4075e9e69 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 @@ class LocalActionsAndTasksConvertedIntoBlocksUpdateTest extends UpdatePathTestBa $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 c9c264c96b5..6e17506220d 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 @@ class PageTitleConvertedIntoBlockUpdateTest extends UpdatePathTestBase { $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 172897497d3..b0a58623a54 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 @@ class SevenSecondaryLocalTasksConvertedIntoBlockUpdateTest extends UpdatePathTes $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 72f3a278246..56b988e956d 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 @@ class SiteBrandingConvertedIntoBlockUpdateTest extends UpdatePathTestBase { $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 da53ba6e630..af2552492aa 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 @@ class UpdatePathRC1TestBaseTest extends UpdatePathTestBase { $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 976032e0506..63229a91398 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 @@ class ModuleHandlerTest extends KernelTestBase { $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 785629e1fe5..7dda500d7c9 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 @@ class TaxonomyIndexTid extends PrerenderList { 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/taxonomy.module b/core/modules/taxonomy/taxonomy.module index 4ba6d195ad7..160bcbe635c 100644 --- a/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -289,7 +289,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(); } /** @@ -299,7 +299,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); } /** @@ -513,7 +513,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 b6931b7cbb0..39d7da5e14c 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 0e2c5aa3993..ab708d40481 100644 --- a/core/modules/taxonomy/tests/src/Functional/TaxonomyQueryAlterTest.php +++ b/core/modules/taxonomy/tests/src/Functional/TaxonomyQueryAlterTest.php @@ -37,7 +37,7 @@ class TaxonomyQueryAlterTest extends BrowserTestBase { $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 c701dfeebaf..eb57142c87e 100644 --- a/core/modules/taxonomy/tests/src/Functional/TaxonomyTermIndentationTest.php +++ b/core/modules/taxonomy/tests/src/Functional/TaxonomyTermIndentationTest.php @@ -87,7 +87,7 @@ class TaxonomyTermIndentationTest extends TaxonomyTestBase { $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 20ecb639034..6eb3ed1ea45 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 @@ class MigrateTaxonomyTermTest extends MigrateDrupal6TestBase { } 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 25544486ab2..3fd755440aa 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 @@ class MigrateTermNodeRevisionTest extends MigrateDrupal6TestBase { * 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 d735232a678..b8b0169bbd0 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 @@ class MigrateTaxonomyTermTest extends MigrateDrupal7TestBase { * 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 4e1eaafa1e5..c2d9d667c97 100644 --- a/core/modules/taxonomy/tests/src/Kernel/TermKernelTest.php +++ b/core/modules/taxonomy/tests/src/Kernel/TermKernelTest.php @@ -127,7 +127,7 @@ class TermKernelTest extends KernelTestBase { $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 507f14b64ef..575c31bae06 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 ebb11341282..8ed8dfdac8c 100644 --- a/core/modules/user/src/Entity/User.php +++ b/core/modules/user/src/Entity/User.php @@ -420,8 +420,8 @@ class User extends ContentEntityBase implements UserInterface { // @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 @@ class User extends ContentEntityBase implements UserInterface { * 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/tests/src/Functional/UserCancelTest.php b/core/modules/user/tests/src/Functional/UserCancelTest.php index 968330c2a5e..631b35183a7 100644 --- a/core/modules/user/tests/src/Functional/UserCancelTest.php +++ b/core/modules/user/tests/src/Functional/UserCancelTest.php @@ -268,7 +268,7 @@ class UserCancelTest extends BrowserTestBase { $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 @@ class UserCancelTest extends BrowserTestBase { $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 @@ class UserCancelTest extends BrowserTestBase { $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 9a660ef3eff..866b2d32428 100644 --- a/core/modules/user/tests/src/Functional/UserPasswordResetTest.php +++ b/core/modules/user/tests/src/Functional/UserPasswordResetTest.php @@ -307,7 +307,7 @@ class UserPasswordResetTest extends PageCacheTagsTestBase { ->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 baa848ae143..30ff65648e8 100644 --- a/core/modules/user/tests/src/Functional/UserPermissionsTest.php +++ b/core/modules/user/tests/src/Functional/UserPermissionsTest.php @@ -107,7 +107,7 @@ class UserPermissionsTest extends BrowserTestBase { $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 @@ class UserPermissionsTest extends BrowserTestBase { $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 c9a68328add..ce1568d8387 100644 --- a/core/modules/user/tests/src/Functional/UserRegistrationTest.php +++ b/core/modules/user/tests/src/Functional/UserRegistrationTest.php @@ -208,7 +208,7 @@ class UserRegistrationTest extends BrowserTestBase { $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 739da548403..c7e52135d69 100644 --- a/core/modules/user/tests/src/Functional/UserRoleAdminTest.php +++ b/core/modules/user/tests/src/Functional/UserRoleAdminTest.php @@ -72,7 +72,7 @@ class UserRoleAdminTest extends BrowserTestBase { $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 @@ class UserRoleAdminTest extends BrowserTestBase { $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 12502680364..d087d528d71 100644 --- a/core/modules/user/tests/src/Functional/UserTranslationUITest.php +++ b/core/modules/user/tests/src/Functional/UserTranslationUITest.php @@ -31,7 +31,7 @@ class UserTranslationUITest extends ContentTranslationUITestBase { $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 7f847234aa2..7f92860f8bb 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 600c2ec2654..2540ac2cd34 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 772c4e23b95..47771e2e61d 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -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); @@ -1075,7 +1075,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 280ccf4d162..14ac7994fdb 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 @@ abstract class CachePluginBase extends PluginBase { 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 83e0bcfa240..5d39b9cb1c6 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 @@ abstract class QueryPluginBase extends PluginBase implements CacheableDependency // 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 @@ abstract class QueryPluginBase extends PluginBase implements CacheableDependency $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 03749a329b3..7503e1d8b15 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 @@ class Sql extends QueryPluginBase { } 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 20ff84dad7b..ea9cf95f98a 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 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface { $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 f0c8cfce7d9..6033fcfd33f 100644 --- a/core/modules/views/src/Tests/ViewTestData.php +++ b/core/modules/views/src/Tests/ViewTestData.php @@ -31,7 +31,7 @@ class ViewTestData { $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 dd241f714b6..32cf016fd41 100644 --- a/core/modules/views/src/Views.php +++ b/core/modules/views/src/Views.php @@ -242,7 +242,7 @@ class Views { * 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 @@ class Views { ->condition('status', TRUE) ->execute(); - return \Drupal::entityManager()->getStorage('view')->loadMultiple($query); + return \Drupal::entityTypeManager()->getStorage('view')->loadMultiple($query); } /** @@ -270,7 +270,7 @@ class Views { ->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/Handler/FieldEntityOperationsTest.php b/core/modules/views/tests/src/Functional/Handler/FieldEntityOperationsTest.php index 7ced4f7071e..c8f962dbe8e 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 @@ class FieldEntityOperationsTest extends ViewTestBase { /** @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_type.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 41870b6db90..21bdf1709da 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 @@ class NodeWizardTest extends WizardTestBase { $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 a110f002094..83e0cb97f5b 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 @@ class RowEntityRenderersTest extends ViewsKernelTestBase { $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 2ccaac6f31e..0d3ce325d44 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 @@ class AreaEntityTest extends ViewsKernelTestBase { $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 5ff77bc9f4d..327bfc14814 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 @@ abstract class FieldFieldAccessTestBase extends ViewsKernelTestBase { 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 e6cce86f2ef..b60df267b34 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 bf0fd7014e0..9889c93e325 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 4e06b7510c5..25349a33eeb 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 30749fcba87..8c10f65e4f0 100644 --- a/core/modules/views/views.post_update.php +++ b/core/modules/views/views.post_update.php @@ -17,7 +17,7 @@ use Drupal\views\Views; */ 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 9c86a3a3479..39a8f7239cf 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; @@ -321,9 +321,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; @@ -776,17 +776,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 619b1914654..65d45eee5c3 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 @@ abstract class ViewsFormBase extends FormBase implements ViewsFormInterface { // 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 2f007f193c6..5973a5d59bf 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 @@ class DisplayPathTest extends UITestBase { ]; $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 94f9da81444..bfe5b05d071 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 @@ class ViewEditTest extends UITestBase { // 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 1cd9cb17537..aaeeb9d31eb 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStaticCacheTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStaticCacheTest.php @@ -86,7 +86,7 @@ class ConfigEntityStaticCacheTest extends KernelTestBase { */ 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 1fce8a498dd..fcc472f9e2c 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityUnitTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityUnitTest.php @@ -46,7 +46,7 @@ class ConfigEntityUnitTest extends KernelTestBase { * 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 6489b06799e..70dbb874c96 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php @@ -244,7 +244,7 @@ class ConfigImporterTest extends KernelTestBase { // 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 @@ class ConfigImporterTest extends KernelTestBase { // 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 @@ class ConfigImporterTest extends KernelTestBase { // 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 @@ class ConfigImporterTest extends KernelTestBase { // 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 @@ class ConfigImporterTest extends KernelTestBase { // 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 5efd20bbb15..89b284612c5 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/ConfigInstallTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigInstallTest.php @@ -223,7 +223,7 @@ class ConfigInstallTest extends KernelTestBase { } $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 db556902955..3f253f6d182 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityApiTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityApiTest.php @@ -93,7 +93,7 @@ class EntityApiTest extends EntityKernelTestBase { $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 @@ class EntityApiTest extends EntityKernelTestBase { $entity = $storage->create(['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 @@ class EntityApiTest extends EntityKernelTestBase { $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/EntitySchemaTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntitySchemaTest.php index bb9645886b6..f8be106cbc8 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntitySchemaTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntitySchemaTest.php @@ -323,7 +323,7 @@ class EntitySchemaTest extends EntityKernelTestBase { // 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/FieldSqlStorageTest.php b/core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php index 40d9488c60d..76e7004d23c 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php @@ -93,7 +93,7 @@ class FieldSqlStorageTest extends EntityKernelTestBase { $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 1edc386b202..c1900c52a15 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/FieldTranslationSqlStorageTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/FieldTranslationSqlStorageTest.php @@ -78,7 +78,7 @@ class FieldTranslationSqlStorageTest extends EntityLanguageTestBase { $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 bcb68469a46..2f5f85218cf 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/FieldWidgetConstraintValidatorTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/FieldWidgetConstraintValidatorTest.php @@ -45,7 +45,7 @@ class FieldWidgetConstraintValidatorTest extends KernelTestBase { $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); @@ -83,7 +83,7 @@ class FieldWidgetConstraintValidatorTest extends KernelTestBase { $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 8a959c3c71d..aa2a042ddb7 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/RevisionableContentEntityBaseTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/RevisionableContentEntityBaseTest.php @@ -42,7 +42,7 @@ class RevisionableContentEntityBaseTest extends EntityKernelTestBase { */ 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 a998f0fea85..42d8110e196 100644 --- a/core/tests/Drupal/KernelTests/Core/Menu/MenuLinkTreeTest.php +++ b/core/tests/Drupal/KernelTests/Core/Menu/MenuLinkTreeTest.php @@ -61,12 +61,12 @@ class MenuLinkTreeTest extends KernelTestBase { * 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 dfb7d9d641c..3ed2b0d9dc2 100644 --- a/core/tests/Drupal/Tests/Core/DrupalTest.php +++ b/core/tests/Drupal/Tests/Core/DrupalTest.php @@ -79,6 +79,8 @@ class DrupalTest extends UnitTestCase { * Tests the entityManager() method. * * @covers ::entityManager + * @group legacy + * @expectedDeprecation \Drupal::entityManager() is deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal::entityTypeManager() instead in most cases. If the needed method is not on \Drupal\Core\Entity\EntityTypeManagerInterface, see the deprecated \Drupal\Core\Entity\EntityManager to find the correct interface or service. See https://www.drupal.org/node/2549139 */ 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 4ae51829035..aa5807f8f9c 100644 --- a/core/tests/Drupal/Tests/Core/Session/UserSessionTest.php +++ b/core/tests/Drupal/Tests/Core/Session/UserSessionTest.php @@ -110,13 +110,13 @@ class UserSessionTest extends UnitTestCase { [['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']);