diff --git a/core/core.api.php b/core/core.api.php index 4f937e375fbc2b86a77ea4bfccdfe8ce3705c5df..cfb8800728e79a9cdcab36eaa1e0a3f971902c52 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 ffdaaf319e497480b7e34963c1b730ce97089e5a..92bf908e7ace65ae6ad46d66ee9d73b04d3484be 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 fbbfba7e0e8abf877334623fc2c1bc66dbd451ad..b33e0bc040b03677e7ce5c637d8e7a9bad66231e 100644 --- a/core/lib/Drupal.php +++ b/core/lib/Drupal.php @@ -270,6 +270,7 @@ public static function currentUser() { * 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 3aabc9f5168b6610d45b70de15924c198751d0fd..26bdf67b32a568b50163fec90049381423af6e55 100644 --- a/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php +++ b/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php @@ -96,7 +96,7 @@ public static function collectRenderDisplay(FieldableEntityInterface $entity, $f ->execute(); // Load the first valid candidate display, if any. - $storage = \Drupal::entityManager()->getStorage('entity_form_display'); + $storage = \Drupal::entityTypeManager()->getStorage('entity_form_display'); foreach ($candidate_ids as $candidate_id) { if (isset($results[$candidate_id])) { $display = $storage->load($candidate_id); diff --git a/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php b/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php index 8ae9e72821a0a02494ba804e8fcf5e85895ad301..00800b583955859de59692f89829a1d6a4ac864b 100644 --- a/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php +++ b/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php @@ -112,7 +112,7 @@ public static function collectRenderDisplays($entities, $view_mode) { } // Load the selected displays. - $storage = \Drupal::entityManager()->getStorage('entity_view_display'); + $storage = \Drupal::entityTypeManager()->getStorage('entity_view_display'); $displays = $storage->loadMultiple($load_ids); $displays_by_bundle = []; @@ -182,8 +182,8 @@ public function __construct(array $values, $entity_type) { public function postSave(EntityStorageInterface $storage, $update = TRUE) { // Reset the render cache for the target entity type. parent::postSave($storage, $update); - if (\Drupal::entityManager()->hasHandler($this->targetEntityType, 'view_builder')) { - \Drupal::entityManager()->getViewBuilder($this->targetEntityType)->resetCache(); + if (\Drupal::entityTypeManager()->hasHandler($this->targetEntityType, 'view_builder')) { + \Drupal::entityTypeManager()->getViewBuilder($this->targetEntityType)->resetCache(); } } diff --git a/core/lib/Drupal/Core/Entity/EntityDisplayModeBase.php b/core/lib/Drupal/Core/Entity/EntityDisplayModeBase.php index c6ec9169e28348b769c83c756f22ffb5568594c7..a611487fa1c7e76e4bfd82ec869dc11db7abf14a 100644 --- a/core/lib/Drupal/Core/Entity/EntityDisplayModeBase.php +++ b/core/lib/Drupal/Core/Entity/EntityDisplayModeBase.php @@ -86,7 +86,7 @@ public function setTargetType($target_entity_type) { */ public function calculateDependencies() { parent::calculateDependencies(); - $target_entity_type = \Drupal::entityManager()->getDefinition($this->targetEntityType); + $target_entity_type = \Drupal::entityTypeManager()->getDefinition($this->targetEntityType); $this->addDependency('module', $target_entity_type->getProvider()); return $this; } diff --git a/core/lib/Drupal/Core/Entity/EntityStorageBase.php b/core/lib/Drupal/Core/Entity/EntityStorageBase.php index 2ceb19c2b1fc52afd32c5f5cfe118919e8fa657e..1a27a7738acd7ce0dc9bfb2b2a1ed15e0cf799eb 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 71aea12b80454b43e68a517d8877ff18b624e87e..db0def37decdd1220aa72689367156c498322e85 100644 --- a/core/lib/Drupal/Core/Entity/EntityType.php +++ b/core/lib/Drupal/Core/Entity/EntityType.php @@ -910,7 +910,7 @@ public function getBundleConfigDependency($bundle) { // If this entity type uses entities to manage its bundles then depend on // the bundle entity. if ($bundle_entity_type_id = $this->getBundleEntityType()) { - if (!$bundle_entity = \Drupal::entityManager()->getStorage($bundle_entity_type_id)->load($bundle)) { + if (!$bundle_entity = \Drupal::entityTypeManager()->getStorage($bundle_entity_type_id)->load($bundle)) { throw new \LogicException(sprintf('Missing bundle entity, entity type %s, entity id %s.', $bundle_entity_type_id, $bundle)); } $config_dependency = [ diff --git a/core/lib/Drupal/Core/Entity/EntityTypeManager.php b/core/lib/Drupal/Core/Entity/EntityTypeManager.php index 5544e4a43db54378d52b5da5035b1608b8efa94d..6ae723f8d79376b0dc0f4c7b80e85c8ddc0f7793 100644 --- a/core/lib/Drupal/Core/Entity/EntityTypeManager.php +++ b/core/lib/Drupal/Core/Entity/EntityTypeManager.php @@ -232,7 +232,7 @@ public function getFormObject($entity_type_id, $operation) { ->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 28d81ba6e4de28e14401950cfff5198ec37c16fe..5a7b4b90c63f8af115217c9c9f0ce1e7ab71f583 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityChangedConstraintValidator.php +++ b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityChangedConstraintValidator.php @@ -17,7 +17,7 @@ public function validate($entity, Constraint $constraint) { if (isset($entity)) { /** @var \Drupal\Core\Entity\EntityInterface $entity */ if (!$entity->isNew()) { - $saved_entity = \Drupal::entityManager()->getStorage($entity->getEntityTypeId())->loadUnchanged($entity->id()); + $saved_entity = \Drupal::entityTypeManager()->getStorage($entity->getEntityTypeId())->loadUnchanged($entity->id()); // Ensure that all the entity translations are the same as or newer // than their current version in the storage in order to avoid // reverting other changes. In fact the entity object that is being diff --git a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/ReferenceAccessConstraintValidator.php b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/ReferenceAccessConstraintValidator.php index 7860c90d6542a62c6625f309a645647bf9d5099a..eec95bca50afec8e7470a1d6a161022216fde418 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/ReferenceAccessConstraintValidator.php +++ b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/ReferenceAccessConstraintValidator.php @@ -29,7 +29,7 @@ public function validate($value, Constraint $constraint) { $entity = $value->getEntity(); $check_permission = TRUE; if (!$entity->isNew()) { - $existing_entity = \Drupal::entityManager()->getStorage($entity->getEntityTypeId())->loadUnchanged($entity->id()); + $existing_entity = \Drupal::entityTypeManager()->getStorage($entity->getEntityTypeId())->loadUnchanged($entity->id()); $referenced_entities = $existing_entity->{$value->getFieldDefinition()->getName()}->referencedEntities(); // Check permission if we are not already referencing the entity. foreach ($referenced_entities as $ref) { diff --git a/core/lib/Drupal/Core/Entity/TypedData/EntityDataDefinition.php b/core/lib/Drupal/Core/Entity/TypedData/EntityDataDefinition.php index cbd2b00f34670109d5dca4784ec81bde5958d5d4..74463ee2c3c7f84ac7dae440c998855f8dbc137e 100644 --- a/core/lib/Drupal/Core/Entity/TypedData/EntityDataDefinition.php +++ b/core/lib/Drupal/Core/Entity/TypedData/EntityDataDefinition.php @@ -70,7 +70,7 @@ public function getPropertyDefinitions() { if (!isset($this->propertyDefinitions)) { if ($entity_type_id = $this->getEntityTypeId()) { // Return an empty array for entities that are not content entities. - $entity_type_class = \Drupal::entityManager()->getDefinition($entity_type_id)->getClass(); + $entity_type_class = \Drupal::entityTypeManager()->getDefinition($entity_type_id)->getClass(); if (!in_array('Drupal\Core\Entity\FieldableEntityInterface', class_implements($entity_type_class))) { $this->propertyDefinitions = []; } diff --git a/core/lib/Drupal/Core/Entity/entity.api.php b/core/lib/Drupal/Core/Entity/entity.api.php index 846c757128ddece459468f30b9e24c316350f953..74ddd1b4d70046c3b273e820ff366ddba70d1f21 100644 --- a/core/lib/Drupal/Core/Entity/entity.api.php +++ b/core/lib/Drupal/Core/Entity/entity.api.php @@ -580,7 +580,7 @@ * implementing \Drupal\Core\Entity\EntityViewBuilderInterface that you can * retrieve with: * @code - * $view_builder = \Drupal::entityManager()->getViewBuilder('your_entity_type'); + * $view_builder = \Drupal::entityTypeManager()->getViewBuilder('your_entity_type'); * // Or if you have a $container variable: * $view_builder = $container->get('entity.manager')->getViewBuilder('your_entity_type'); * @endcode @@ -1943,7 +1943,7 @@ function hook_entity_bundle_field_info_alter(&$fields, \Drupal\Core\Entity\Entit * @see \Drupal\Core\Entity\EntityManagerInterface::getFieldStorageDefinitions() */ function hook_entity_field_storage_info(\Drupal\Core\Entity\EntityTypeInterface $entity_type) { - if (\Drupal::entityManager()->getStorage($entity_type->id()) instanceof DynamicallyFieldableEntityStorageInterface) { + if (\Drupal::entityTypeManager()->getStorage($entity_type->id()) instanceof DynamicallyFieldableEntityStorageInterface) { // Query by filtering on the ID as this is more efficient than filtering // on the entity_type property directly. $ids = \Drupal::entityQuery('field_storage_config') diff --git a/core/lib/Drupal/Core/Extension/module.api.php b/core/lib/Drupal/Core/Extension/module.api.php index 572ba8a3af8e37facb730f7a0038a0ba0ad790b0..74580705f6f2f17731974246392387f6fd29d7f4 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 7ffb8ba57b88d9eecad3c177b460a338957b8917..1178cb007b962d7815f232c58b94f18c388e13e8 100644 --- a/core/lib/Drupal/Core/Field/Entity/BaseFieldOverride.php +++ b/core/lib/Drupal/Core/Field/Entity/BaseFieldOverride.php @@ -64,7 +64,7 @@ public static function createFromBaseFieldDefinition(BaseFieldDefinition $base_f $values = $base_field_definition->toArray(); $values['bundle'] = $bundle; $values['baseFieldDefinition'] = $base_field_definition; - return \Drupal::entityManager()->getStorage('base_field_override')->create($values); + return \Drupal::entityTypeManager()->getStorage('base_field_override')->create($values); } /** @@ -238,7 +238,7 @@ public static function postDelete(EntityStorageInterface $storage, array $field_ * provided field name, otherwise NULL. */ public static function loadByName($entity_type_id, $bundle, $field_name) { - return \Drupal::entityManager()->getStorage('base_field_override')->load($entity_type_id . '.' . $bundle . '.' . $field_name); + return \Drupal::entityTypeManager()->getStorage('base_field_override')->load($entity_type_id . '.' . $bundle . '.' . $field_name); } /** diff --git a/core/lib/Drupal/Core/Field/EntityReferenceFieldItemList.php b/core/lib/Drupal/Core/Field/EntityReferenceFieldItemList.php index 3fa199b7276401e6076f70f210534fa6e6345b14..07449e8e913754dbfd4bd8ce29216b97a9965148 100644 --- a/core/lib/Drupal/Core/Field/EntityReferenceFieldItemList.php +++ b/core/lib/Drupal/Core/Field/EntityReferenceFieldItemList.php @@ -43,7 +43,7 @@ public function referencedEntities() { // Load and add the existing entities. if ($ids) { $target_type = $this->getFieldDefinition()->getSetting('target_type'); - $entities = \Drupal::entityManager()->getStorage($target_type)->loadMultiple($ids); + $entities = \Drupal::entityTypeManager()->getStorage($target_type)->loadMultiple($ids); foreach ($ids as $delta => $target_id) { if (isset($entities[$target_id])) { $target_entities[$delta] = $entities[$target_id]; @@ -75,7 +75,7 @@ public static function processDefaultValue($default_value, FieldableEntityInterf $entity_ids = \Drupal::entityQuery($target_type) ->condition('uuid', $uuids, 'IN') ->execute(); - $entities = \Drupal::entityManager() + $entities = \Drupal::entityTypeManager() ->getStorage($target_type) ->loadMultiple($entity_ids); @@ -117,7 +117,7 @@ public function defaultValuesFormSubmit(array $element, array &$form, FormStateI } $ids[] = $default_value[$delta]['target_id']; } - $entities = \Drupal::entityManager() + $entities = \Drupal::entityTypeManager() ->getStorage($this->getSetting('target_type')) ->loadMultiple($ids); diff --git a/core/lib/Drupal/Core/Field/FieldItemBase.php b/core/lib/Drupal/Core/Field/FieldItemBase.php index 5aa4ad11d3c000a1959fe540feb9e30de84bc75f..a6e4092a8588dce97669c35f813d470e2e71d325 100644 --- a/core/lib/Drupal/Core/Field/FieldItemBase.php +++ b/core/lib/Drupal/Core/Field/FieldItemBase.php @@ -184,7 +184,7 @@ public function __unset($name) { * {@inheritdoc} */ public function view($display_options = []) { - $view_builder = \Drupal::entityManager()->getViewBuilder($this->getEntity()->getEntityTypeId()); + $view_builder = \Drupal::entityTypeManager()->getViewBuilder($this->getEntity()->getEntityTypeId()); return $view_builder->viewFieldItem($this, $display_options); } diff --git a/core/lib/Drupal/Core/Field/FieldItemList.php b/core/lib/Drupal/Core/Field/FieldItemList.php index 5dd4f376bf216d487a30d206c598baaf7ae3014e..ae7298e43cf8749d557bd2e3f7dfbbde40c4e37c 100644 --- a/core/lib/Drupal/Core/Field/FieldItemList.php +++ b/core/lib/Drupal/Core/Field/FieldItemList.php @@ -150,7 +150,7 @@ public function __unset($property_name) { * {@inheritdoc} */ public function access($operation = 'view', AccountInterface $account = NULL, $return_as_object = FALSE) { - $access_control_handler = \Drupal::entityManager()->getAccessControlHandler($this->getEntity()->getEntityTypeId()); + $access_control_handler = \Drupal::entityTypeManager()->getAccessControlHandler($this->getEntity()->getEntityTypeId()); return $access_control_handler->fieldAccess($operation, $this->getFieldDefinition(), $account, $this, $return_as_object); } @@ -239,7 +239,7 @@ protected function delegateMethod($method) { * {@inheritdoc} */ public function view($display_options = []) { - $view_builder = \Drupal::entityManager()->getViewBuilder($this->getEntity()->getEntityTypeId()); + $view_builder = \Drupal::entityTypeManager()->getViewBuilder($this->getEntity()->getEntityTypeId()); return $view_builder->viewField($this, $display_options); } diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php index 9333d7e22755ec787d8b16024b328b2aa5977040..b04cf9d91d9671b3d5184a0cf522b3ceea99e8f9 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php @@ -213,7 +213,7 @@ public static function isApplicable(FieldDefinitionInterface $field_definition) // This formatter is only available for entity types that have a view // builder. $target_type = $field_definition->getFieldStorageDefinition()->getSetting('target_type'); - return \Drupal::entityManager()->getDefinition($target_type)->hasViewBuilderClass(); + return \Drupal::entityTypeManager()->getDefinition($target_type)->hasViewBuilderClass(); } } diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceFormatterBase.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceFormatterBase.php index d2a691f07733b8e73dfe2c6b610be8463ff7f884..1db3f0ed9afbe0371f21b69b51f4197bc5e81ecd 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceFormatterBase.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceFormatterBase.php @@ -136,7 +136,7 @@ public function prepareView(array $entities_items) { } if ($ids) { $target_type = $this->getFieldSetting('target_type'); - $target_entities = \Drupal::entityManager()->getStorage($target_type)->loadMultiple($ids); + $target_entities = \Drupal::entityTypeManager()->getStorage($target_type)->loadMultiple($ids); } // For each item, pre-populate the loaded entity in $item->entity, and set diff --git a/core/lib/Drupal/Core/Menu/menu.api.php b/core/lib/Drupal/Core/Menu/menu.api.php index 4951c232db3d7dcc574b6b6ba0d1f0762d79e373..758013f494e0a11fb0c6f40a6c06fbe6eb3ed753 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 147bb62a772fa1f7e95906d42db70e49668cf362..bc7f554c33d30fe8246c2e4eb52851ec8098cf42 100644 --- a/core/lib/Drupal/Core/Session/AccountProxy.php +++ b/core/lib/Drupal/Core/Session/AccountProxy.php @@ -195,7 +195,7 @@ public function setInitialAccountId($account_id) { * An account or NULL if none is found. */ protected function loadUserEntity($account_id) { - return \Drupal::entityManager()->getStorage('user')->load($account_id); + return \Drupal::entityTypeManager()->getStorage('user')->load($account_id); } } diff --git a/core/lib/Drupal/Core/Session/UserSession.php b/core/lib/Drupal/Core/Session/UserSession.php index ec002beb7323cad88c6c4059de2360904d67c0e1..ba3b929a4c7706dac6f45c7d39fc551b00f5d7a2 100644 --- a/core/lib/Drupal/Core/Session/UserSession.php +++ b/core/lib/Drupal/Core/Session/UserSession.php @@ -203,7 +203,7 @@ public function getLastAccessedTime() { * The role storage object. */ protected function getRoleStorage() { - return \Drupal::entityManager()->getStorage('user_role'); + return \Drupal::entityTypeManager()->getStorage('user_role'); } } diff --git a/core/modules/aggregator/aggregator.module b/core/modules/aggregator/aggregator.module index 74e795efaede156102fb5bbcca3f3b29f1226a00..082681ed7624484db600d6d5718d87b0abe96d95 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 e653008458fe01c9cd3838b29d8cfbfa00b5e58e..4c3a5b856e1572220951a893f85339a0076d9c58 100644 --- a/core/modules/aggregator/src/Entity/Feed.php +++ b/core/modules/aggregator/src/Entity/Feed.php @@ -125,7 +125,7 @@ public static function postDelete(EntityStorageInterface $storage, array $entiti ->condition('settings.feed', array_keys($entities)) ->execute(); if ($ids) { - $block_storage = \Drupal::entityManager()->getStorage('block'); + $block_storage = \Drupal::entityTypeManager()->getStorage('block'); $block_storage->delete($block_storage->loadMultiple($ids)); } } diff --git a/core/modules/aggregator/tests/src/Functional/FeedProcessorPluginTest.php b/core/modules/aggregator/tests/src/Functional/FeedProcessorPluginTest.php index 8e6ade467ddf274ad526bda69cc44e2598a1270e..2f95f69db96b75a125eb1460067ad26422bd952e 100644 --- a/core/modules/aggregator/tests/src/Functional/FeedProcessorPluginTest.php +++ b/core/modules/aggregator/tests/src/Functional/FeedProcessorPluginTest.php @@ -57,7 +57,7 @@ public function testPostProcess() { $this->updateFeedItems($feed); $feed_id = $feed->id(); // Reset entity cache manually. - \Drupal::entityManager()->getStorage('aggregator_feed')->resetCache([$feed_id]); + \Drupal::entityTypeManager()->getStorage('aggregator_feed')->resetCache([$feed_id]); // Reload the feed to get new values. $feed = Feed::load($feed_id); // Make sure its refresh rate doubled. diff --git a/core/modules/block/block.post_update.php b/core/modules/block/block.post_update.php index 0d49ead480b4b480aab674479e48aff990b21c11..e9e332ad086f10314354e443653f500c87f13506 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 9c2c1b44b795ae7024b2f584b24952b1f0e956e7..c34e30f0854de0cce34399fd62a817f847b483a8 100644 --- a/core/modules/block_content/tests/src/Functional/BlockContentTranslationUITest.php +++ b/core/modules/block_content/tests/src/Functional/BlockContentTranslationUITest.php @@ -132,7 +132,7 @@ protected function doTestBasicTranslation() { // as in the original language. $default_langcode = $this->langcodes[0]; $values = $this->getNewEntityValues($default_langcode); - $storage = \Drupal::entityManager()->getStorage($this->entityTypeId); + $storage = \Drupal::entityTypeManager()->getStorage($this->entityTypeId); /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */ $entity = $storage->create(['type' => 'basic'] + $values); $entity->save(); diff --git a/core/modules/block_content/tests/src/Functional/PageEditTest.php b/core/modules/block_content/tests/src/Functional/PageEditTest.php index f623cfa28acb06c7c1451cae2e2736620e5b4929..e751c70b097a4841680a2f100a35bed47e9728ab 100644 --- a/core/modules/block_content/tests/src/Functional/PageEditTest.php +++ b/core/modules/block_content/tests/src/Functional/PageEditTest.php @@ -57,7 +57,7 @@ public function testPageEdit() { $this->drupalPostForm(NULL, $edit, t('Save')); // Ensure that the block revision has been created. - \Drupal::entityManager()->getStorage('block_content')->resetCache([$block->id()]); + \Drupal::entityTypeManager()->getStorage('block_content')->resetCache([$block->id()]); $revised_block = BlockContent::load($block->id()); $this->assertNotIdentical($block->getRevisionId(), $revised_block->getRevisionId(), 'A new revision has been created.'); diff --git a/core/modules/book/book.module b/core/modules/book/book.module index 7d703bae5115a69eb664191330cdb8d89b1ab48a..8bb1bb38a5ac14194d5c73a290a82a14c6ee9dfb 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 a863ff1529fc2494f512956d4825115e33c42fd4..5271c8e7b87d492b959b1dad887359eae04a8b77 100644 --- a/core/modules/book/tests/src/Functional/BookBreadcrumbTest.php +++ b/core/modules/book/tests/src/Functional/BookBreadcrumbTest.php @@ -118,7 +118,7 @@ protected function createBookNode($book_nid, $parent = NULL) { $edit['book[pid]'] = $parent; $this->drupalPostForm(NULL, $edit, t('Save')); // Make sure the parent was flagged as having children. - $parent_node = \Drupal::entityManager()->getStorage('node')->loadUnchanged($parent); + $parent_node = \Drupal::entityTypeManager()->getStorage('node')->loadUnchanged($parent); $this->assertFalse(empty($parent_node->book['has_children']), 'Parent node is marked as having children'); } else { diff --git a/core/modules/book/tests/src/Functional/BookTest.php b/core/modules/book/tests/src/Functional/BookTest.php index 972c240ceb539cacff5554cd992125199f9c867e..92dfa00425a251e9f5c93f0381191c7dffd178c5 100644 --- a/core/modules/book/tests/src/Functional/BookTest.php +++ b/core/modules/book/tests/src/Functional/BookTest.php @@ -405,7 +405,7 @@ public function testBookOutline() { $edit = []; $edit['book[bid]'] = '1'; $this->drupalPostForm('node/' . $empty_book->id() . '/outline', $edit, t('Add to book outline')); - $node = \Drupal::entityManager()->getStorage('node')->load($empty_book->id()); + $node = \Drupal::entityTypeManager()->getStorage('node')->load($empty_book->id()); // Test the book array. $this->assertEqual($node->book['nid'], $empty_book->id()); $this->assertEqual($node->book['bid'], $empty_book->id()); @@ -428,7 +428,7 @@ public function testBookOutline() { $edit = []; $edit['book[bid]'] = $node->id(); $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save')); - $node = \Drupal::entityManager()->getStorage('node')->load($node->id()); + $node = \Drupal::entityTypeManager()->getStorage('node')->load($node->id()); // Test the book array. $this->assertEqual($node->book['nid'], $node->id()); @@ -519,7 +519,7 @@ public function testHookNodeLoadAccess() { $this->drupalLogin($this->bookAuthor); $this->book = $this->createBookNode('new'); // Reset any internal static caching. - $node_storage = \Drupal::entityManager()->getStorage('node'); + $node_storage = \Drupal::entityTypeManager()->getStorage('node'); $node_storage->resetCache(); // Log in as user without access to the book node, so no 'node test view' diff --git a/core/modules/book/tests/src/Functional/BookTestTrait.php b/core/modules/book/tests/src/Functional/BookTestTrait.php index edc6cbfe67e9f6424a0bd6347f95b6330df2417c..67520c4851fd0572ea31ae21e79f7e38a13a900c 100644 --- a/core/modules/book/tests/src/Functional/BookTestTrait.php +++ b/core/modules/book/tests/src/Functional/BookTestTrait.php @@ -198,7 +198,7 @@ public function createBookNode($book_nid, $parent = NULL, $edit = []) { $edit['book[pid]'] = $parent; $this->drupalPostForm(NULL, $edit, t('Save')); // Make sure the parent was flagged as having children. - $parent_node = \Drupal::entityManager()->getStorage('node')->loadUnchanged($parent); + $parent_node = \Drupal::entityTypeManager()->getStorage('node')->loadUnchanged($parent); $this->assertFalse(empty($parent_node->book['has_children']), 'Parent node is marked as having children'); } else { diff --git a/core/modules/book/tests/src/Functional/Views/BookRelationshipTest.php b/core/modules/book/tests/src/Functional/Views/BookRelationshipTest.php index 9ee79c78dc6110ec7a7573319f11719c047c5bc1..30b8a8445a12b011f88c73cc8b0ee21fa289b861 100644 --- a/core/modules/book/tests/src/Functional/Views/BookRelationshipTest.php +++ b/core/modules/book/tests/src/Functional/Views/BookRelationshipTest.php @@ -121,7 +121,7 @@ protected function createBookNode($book_nid, $parent = NULL) { $edit['book[pid]'] = $parent; $this->drupalPostForm(NULL, $edit, t('Save')); // Make sure the parent was flagged as having children. - $parent_node = \Drupal::entityManager()->getStorage('node')->loadUnchanged($parent); + $parent_node = \Drupal::entityTypeManager()->getStorage('node')->loadUnchanged($parent); $this->assertFalse(empty($parent_node->book['has_children']), 'Parent node is marked as having children'); } else { diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 357327281535fef0a5df69ba0ca9ef2021a0c4b3..051f335c809a8f298550f6aba0adda3e32832ca1 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 11abede944c1ebe90c3d9a220d120a0292a04b63..e5df31a1a05b3d2c3cd7c3faa3f87ffbcd734da4 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 7fb74217c4c58b9683f8d3316c80c169e71e82bf..956a33544b0ab7f00e5b4f962d1dd0bcf0d4e56d 100644 --- a/core/modules/comment/src/CommentViewsData.php +++ b/core/modules/comment/src/CommentViewsData.php @@ -193,7 +193,7 @@ public function getViewsData() { unset($data['comment_field_data']['thread']['filter']); unset($data['comment_field_data']['thread']['argument']); - $entities_types = \Drupal::entityManager()->getDefinitions(); + $entities_types = \Drupal::entityTypeManager()->getDefinitions(); // Provide a relationship for each entity type except comment. foreach ($entities_types as $type => $entity_type) { diff --git a/core/modules/comment/src/Plugin/views/field/NodeNewComments.php b/core/modules/comment/src/Plugin/views/field/NodeNewComments.php index 444033caf54393e7520c0603057f40641f5bf3aa..b1a3de16f41f54aaf30754bd244d6bb49b6ca982 100644 --- a/core/modules/comment/src/Plugin/views/field/NodeNewComments.php +++ b/core/modules/comment/src/Plugin/views/field/NodeNewComments.php @@ -4,6 +4,8 @@ use Drupal\Core\Database\Connection; use Drupal\comment\CommentInterface; +use Drupal\Core\Entity\EntityFieldManagerInterface; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\node\Entity\Node; use Drupal\views\Plugin\views\field\NumericField; @@ -35,6 +37,20 @@ public function usesGroupBy() { */ protected $database; + /** + * The entity type manager. + * + * @var \Drupal\Core\Entity\EntityTypeManagerInterface + */ + protected $entityTypeManager; + + /** + * The entity field manager. + * + * @var \Drupal\Core\Entity\EntityFieldManagerInterface + */ + protected $entityFieldManager; + /** * Constructs a \Drupal\comment\Plugin\views\field\NodeNewComments object. * @@ -46,18 +62,38 @@ public function usesGroupBy() { * The plugin implementation definition. * @param \Drupal\Core\Database\Connection $database * Database Service Object. + * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager + * The entity type manager service. + * @param \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager + * The entity field manager service. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, Connection $database) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, Connection $database, EntityTypeManagerInterface $entity_type_manager = NULL, EntityFieldManagerInterface $entity_field_manager = NULL) { parent::__construct($configuration, $plugin_id, $plugin_definition); - $this->database = $database; + if (!$entity_type_manager) { + @trigger_error("Not passing the entity type manager to the NodeNewComments constructor is deprecated in drupal:8.8.0 and will be required in drupal 9.0.0. @see https://www.drupal.org/node/3047897"); + $entity_type_manager = \Drupal::entityTypeManager(); + } + if (!$entity_field_manager) { + @trigger_error("Not passing the entity type manager to the NodeNewComments constructor is deprecated in drupal:8.8.0 and will be required in drupal 9.0.0. @see https://www.drupal.org/node/3047897"); + $entity_field_manager = \Drupal::service('entity_field.manager'); + } + $this->entityTypeManager = $entity_type_manager; + $this->entityFieldManager = $entity_field_manager; } /** * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { - return new static($configuration, $plugin_id, $plugin_definition, $container->get('database')); + return new static( + $configuration, + $plugin_id, + $plugin_definition, + $container->get('database'), + $container->get('entity_type.manager'), + $container->get('entity_field.manager') + ); } /** @@ -166,8 +202,7 @@ protected function renderLink($data, ResultRow $values) { // reference, we arbitrarily use the first such field name we find. // @todo Provide a means for selecting the comment field. // https://www.drupal.org/node/2594201 - $entity_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 @@ protected function renderLink($data, ResultRow $values) { } } } - $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 b3c3d990b156129f93695137852955fc1949b00a..4c239816047d2c6ea71adf7741b63efec64d22ea 100644 --- a/core/modules/comment/src/Tests/CommentTestBase.php +++ b/core/modules/comment/src/Tests/CommentTestBase.php @@ -176,7 +176,7 @@ public function postComment($entity, $comment, $subject = '', $contact = NULL, $ } if (isset($match[1])) { - \Drupal::entityManager()->getStorage('comment')->resetCache([$match[1]]); + \Drupal::entityTypeManager()->getStorage('comment')->resetCache([$match[1]]); return Comment::load($match[1]); } } diff --git a/core/modules/comment/tests/src/Functional/CommentPagerTest.php b/core/modules/comment/tests/src/Functional/CommentPagerTest.php index ff5f17cf455dcda802d89ddb06b88c4c01b1131c..3c4d46b1c11c3f90ebc69f461386c49d5ca1afca 100644 --- a/core/modules/comment/tests/src/Functional/CommentPagerTest.php +++ b/core/modules/comment/tests/src/Functional/CommentPagerTest.php @@ -283,7 +283,7 @@ public function testCommentNewPageIndicator() { $node = Node::load($node->id()); foreach ($expected_pages as $new_replies => $expected_page) { - $returned_page = \Drupal::entityManager()->getStorage('comment') + $returned_page = \Drupal::entityTypeManager()->getStorage('comment') ->getNewCommentPageNumber($node->get('comment')->comment_count, $new_replies, $node, 'comment'); $this->assertIdentical($expected_page, $returned_page, format_string('Flat mode, @new replies: expected page @expected, returned page @returned.', ['@new' => $new_replies, '@expected' => $expected_page, '@returned' => $returned_page])); } @@ -305,10 +305,10 @@ public function testCommentNewPageIndicator() { 6 => 0, ]; - \Drupal::entityManager()->getStorage('node')->resetCache([$node->id()]); + \Drupal::entityTypeManager()->getStorage('node')->resetCache([$node->id()]); $node = Node::load($node->id()); foreach ($expected_pages as $new_replies => $expected_page) { - $returned_page = \Drupal::entityManager()->getStorage('comment') + $returned_page = \Drupal::entityTypeManager()->getStorage('comment') ->getNewCommentPageNumber($node->get('comment')->comment_count, $new_replies, $node, 'comment'); $this->assertEqual($expected_page, $returned_page, format_string('Threaded mode, @new replies: expected page @expected, returned page @returned.', ['@new' => $new_replies, '@expected' => $expected_page, '@returned' => $returned_page])); } diff --git a/core/modules/comment/tests/src/Functional/CommentPreviewTest.php b/core/modules/comment/tests/src/Functional/CommentPreviewTest.php index cee08ae39c91ad440a0d4be2a841bb452a373c29..c64eeaa6db400e734bbe667fbc4a5259f84d38de 100644 --- a/core/modules/comment/tests/src/Functional/CommentPreviewTest.php +++ b/core/modules/comment/tests/src/Functional/CommentPreviewTest.php @@ -185,7 +185,7 @@ public function testCommentEditPreviewSave() { $this->drupalPostForm('comment/' . $comment->id() . '/edit', $displayed, t('Save')); // Check that the saved comment is still correct. - $comment_storage = \Drupal::entityManager()->getStorage('comment'); + $comment_storage = \Drupal::entityTypeManager()->getStorage('comment'); $comment_storage->resetCache([$comment->id()]); /** @var \Drupal\comment\CommentInterface $comment_loaded */ $comment_loaded = Comment::load($comment->id()); diff --git a/core/modules/comment/tests/src/Functional/CommentTestBase.php b/core/modules/comment/tests/src/Functional/CommentTestBase.php index 9574681872e023d945bea9ae6396538bcb1c5eef..e9907b3bea13970c63354bec9d6f87d52c1c19ee 100644 --- a/core/modules/comment/tests/src/Functional/CommentTestBase.php +++ b/core/modules/comment/tests/src/Functional/CommentTestBase.php @@ -171,7 +171,7 @@ public function postComment($entity, $comment, $subject = '', $contact = NULL, $ } if (isset($match[1])) { - \Drupal::entityManager()->getStorage('comment')->resetCache([$match[1]]); + \Drupal::entityTypeManager()->getStorage('comment')->resetCache([$match[1]]); return Comment::load($match[1]); } } diff --git a/core/modules/comment/tests/src/Functional/CommentTranslationUITest.php b/core/modules/comment/tests/src/Functional/CommentTranslationUITest.php index 68a60a479045f7010263ce99a611c3cfc67fb645..2d7787e7446b12bea007a80756b7b7ca88f4b15e 100644 --- a/core/modules/comment/tests/src/Functional/CommentTranslationUITest.php +++ b/core/modules/comment/tests/src/Functional/CommentTranslationUITest.php @@ -125,8 +125,8 @@ protected function getNewEntityValues($langcode) { * {@inheritdoc} */ protected function doTestPublishedStatus() { - $entity_manager = \Drupal::entityManager(); - $storage = $entity_manager->getStorage($this->entityTypeId); + $entity_type_manager = \Drupal::entityTypeManager(); + $storage = $entity_type_manager->getStorage($this->entityTypeId); $storage->resetCache(); $entity = $storage->load($this->entityId); diff --git a/core/modules/comment/tests/src/Functional/CommentTypeTest.php b/core/modules/comment/tests/src/Functional/CommentTypeTest.php index 04173c43cb91dd52eb1d2250f08e24975b80f6ec..c2eeb928cf84d6a4d21d23f9a599d77af9952511 100644 --- a/core/modules/comment/tests/src/Functional/CommentTypeTest.php +++ b/core/modules/comment/tests/src/Functional/CommentTypeTest.php @@ -84,7 +84,7 @@ public function testCommentTypeCreation() { // Save the form and ensure the entity-type value is preserved even though // the field isn't present. $this->drupalPostForm(NULL, [], t('Save')); - \Drupal::entityManager()->getStorage('comment_type')->resetCache(['foo']); + \Drupal::entityTypeManager()->getStorage('comment_type')->resetCache(['foo']); $comment_type = CommentType::load('foo'); $this->assertEqual($comment_type->getTargetEntityTypeId(), 'node'); } diff --git a/core/modules/comment/tests/src/Kernel/CommentDefaultFormatterCacheTagsTest.php b/core/modules/comment/tests/src/Kernel/CommentDefaultFormatterCacheTagsTest.php index bdea71df15fa1a1692b0079cf0247ddf326bccc8..e681a4d9ad62c81f5fc670b7a777246b7eb6abc0 100644 --- a/core/modules/comment/tests/src/Kernel/CommentDefaultFormatterCacheTagsTest.php +++ b/core/modules/comment/tests/src/Kernel/CommentDefaultFormatterCacheTagsTest.php @@ -74,7 +74,7 @@ public function testCacheTags() { $commented_entity->save(); // Verify cache tags on the rendered entity before it has comments. - $build = \Drupal::entityManager() + $build = \Drupal::entityTypeManager() ->getViewBuilder('entity_test') ->view($commented_entity); $renderer->renderRoot($build); @@ -117,7 +117,7 @@ public function testCacheTags() { $commented_entity = $storage->load($commented_entity->id()); // Verify cache tags on the rendered entity when it has comments. - $build = \Drupal::entityManager() + $build = \Drupal::entityTypeManager() ->getViewBuilder('entity_test') ->view($commented_entity); $renderer->renderRoot($build); @@ -142,7 +142,7 @@ public function testCacheTags() { // builder elements bubble up outside of the entity and we can check that // it got the correct cache max age. $build = ['#type' => 'container']; - $build['entity'] = \Drupal::entityManager() + $build['entity'] = \Drupal::entityTypeManager() ->getViewBuilder('entity_test') ->view($commented_entity); $renderer->renderRoot($build); diff --git a/core/modules/comment/tests/src/Kernel/CommentValidationTest.php b/core/modules/comment/tests/src/Kernel/CommentValidationTest.php index 67bbda8fb612e27aa6627560902ee8c3be23ae94..411ad5460849a1315a6fbea0eb54fcd42dc50566 100644 --- a/core/modules/comment/tests/src/Kernel/CommentValidationTest.php +++ b/core/modules/comment/tests/src/Kernel/CommentValidationTest.php @@ -138,7 +138,7 @@ public function testValidation() { $field->setSetting('anonymous', CommentInterface::ANONYMOUS_MUST_CONTACT); $field->save(); // Reset the node entity. - \Drupal::entityManager()->getStorage('node')->resetCache([$node->id()]); + \Drupal::entityTypeManager()->getStorage('node')->resetCache([$node->id()]); $node = Node::load($node->id()); // Create a new comment with the new field. $comment = $this->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 3b0674222cd13efb6a3adc7941f76c868ec985a7..fdb415e46ee7f5a95a6e82b5fd1923727b186895 100644 --- a/core/modules/comment/tests/src/Kernel/Migrate/MigrateCommentStubTest.php +++ b/core/modules/comment/tests/src/Kernel/Migrate/MigrateCommentStubTest.php @@ -31,7 +31,7 @@ protected function setUp() { $this->installSchema('system', ['sequences']); // Make sure uid 0 is created (default uid for comments is 0). - $storage = \Drupal::entityManager()->getStorage('user'); + $storage = \Drupal::entityTypeManager()->getStorage('user'); // Insert a row for the anonymous user. $storage ->create([ diff --git a/core/modules/comment/tests/src/Kernel/Views/CommentUserNameTest.php b/core/modules/comment/tests/src/Kernel/Views/CommentUserNameTest.php index 30a8a64ffa21ee47523da35a0d08ddbbd4c4c9b9..1a8db39d4b3cca3a79a3936cd7d1f4d4d846b8c5 100644 --- a/core/modules/comment/tests/src/Kernel/Views/CommentUserNameTest.php +++ b/core/modules/comment/tests/src/Kernel/Views/CommentUserNameTest.php @@ -42,7 +42,7 @@ protected function setUp($import_test_views = TRUE) { $this->installConfig(['user']); // Create an anonymous user. - $storage = \Drupal::entityManager()->getStorage('user'); + $storage = \Drupal::entityTypeManager()->getStorage('user'); // Insert a row for the anonymous user. $storage ->create([ diff --git a/core/modules/config/tests/src/Functional/ConfigEntityListMultilingualTest.php b/core/modules/config/tests/src/Functional/ConfigEntityListMultilingualTest.php index 7c5fa1fac19fe29e4a19d9c35c4cbc51d9427d73..cf9ff99f221efbad4c217b8e35e1dcc954b761a1 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 b92629d1977d97a6d12f7bf092c9aaf034f20e87..16fcc89dd6428dc35416d6b8b3aac3e18bd3cf77 100644 --- a/core/modules/config/tests/src/Functional/ConfigEntityListTest.php +++ b/core/modules/config/tests/src/Functional/ConfigEntityListTest.php @@ -30,7 +30,7 @@ protected function setUp() { parent::setUp(); // Delete the override config_test entity since it is not required by this // test. - \Drupal::entityManager()->getStorage('config_test')->load('override')->delete(); + \Drupal::entityTypeManager()->getStorage('config_test')->load('override')->delete(); $this->drupalPlaceBlock('local_actions_block'); } @@ -38,7 +38,7 @@ protected function setUp() { * Tests entity list builder methods. */ public function testList() { - $controller = \Drupal::entityManager()->getListBuilder('config_test'); + $controller = \Drupal::entityTypeManager()->getListBuilder('config_test'); // Test getStorage() method. $this->assertTrue($controller->getStorage() instanceof EntityStorageInterface, 'EntityStorage instance in storage.'); @@ -252,7 +252,7 @@ public function testListUI() { public function testPager() { $this->drupalLogin($this->drupalCreateUser(['administer site configuration'])); - $storage = \Drupal::entityManager()->getListBuilder('config_test')->getStorage(); + $storage = \Drupal::service('entity_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 8615da5865b8e1130d4947b09f1d228226a46951..167d2a7e26e8fa340ce9dedad07ab2b01971d608 100644 --- a/core/modules/config/tests/src/Functional/ConfigInstallProfileOverrideTest.php +++ b/core/modules/config/tests/src/Functional/ConfigInstallProfileOverrideTest.php @@ -94,7 +94,7 @@ public function testInstallProfileConfigOverwrite() { // configuration in a modules config/install directory. $this->container->get('module_installer')->install(['config_test']); $this->rebuildContainer(); - $config_test_storage = \Drupal::entityManager()->getStorage('config_test'); + $config_test_storage = \Drupal::entityTypeManager()->getStorage('config_test'); $this->assertEqual($config_test_storage->load('dotted.default')->label(), 'Default install profile override', 'The config_test entity is overridden by the profile optional configuration.'); // Test that override of optional configuration does work. $this->assertEqual($config_test_storage->load('override')->label(), 'Override', 'The optional config_test entity is overridden by the profile optional configuration.'); @@ -115,7 +115,7 @@ public function testInstallProfileConfigOverwrite() { // that deleted profile configuration is not re-created. $this->container->get('module_installer')->install(['config_other_module_config_test']); $this->rebuildContainer(); - $config_test_storage = \Drupal::entityManager()->getStorage('config_test'); + $config_test_storage = \Drupal::entityTypeManager()->getStorage('config_test'); $this->assertNull($config_test_storage->load('completely_new')); } diff --git a/core/modules/config/tests/src/Functional/ConfigSingleImportExportTest.php b/core/modules/config/tests/src/Functional/ConfigSingleImportExportTest.php index 69a7ed74ea2e158c9c987af983677e2dce4c5708..65e76e05835f7f53a08ab6aa7355efdb5fd57688 100644 --- a/core/modules/config/tests/src/Functional/ConfigSingleImportExportTest.php +++ b/core/modules/config/tests/src/Functional/ConfigSingleImportExportTest.php @@ -36,7 +36,7 @@ protected function setUp() { * Tests importing a single configuration file. */ public function testImport() { - $storage = \Drupal::entityManager()->getStorage('config_test'); + $storage = \Drupal::entityTypeManager()->getStorage('config_test'); $uuid = \Drupal::service('uuid'); $this->drupalLogin($this->drupalCreateUser(['import configuration'])); @@ -254,7 +254,7 @@ public function testExport() { $this->drupalGet('admin/config/development/configuration/single/export/date_format/fallback'); $this->assertFieldByXPath('//select[@name="config_name"]//option[@selected="selected"]', t('Fallback date format (fallback)'), 'The fallback date format config entity is selected when specified in the URL.'); - $fallback_date = \Drupal::entityManager()->getStorage('date_format')->load('fallback'); + $fallback_date = \Drupal::entityTypeManager()->getStorage('date_format')->load('fallback'); $yaml_text = $this->xpath('//textarea[@name="export"]')[0]->getValue(); $this->assertEqual(Yaml::decode($yaml_text), $fallback_date->toArray(), 'The fallback date format config entity export code is displayed.'); } diff --git a/core/modules/config_translation/config_translation.api.php b/core/modules/config_translation/config_translation.api.php index f97e25997ad9a266f66cb4b8767e5086ae5a5fae..8e337309c02c2c11f080c0aff513ef7c5b11bcd5 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 e6818386e0a37287b99aa1839f72f1f158ad7b20..5ca9313f717c0e08016273d285bd6c7f42c9ebe3 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 9ccbb135d2f2804764d745bb3f768af4425fb5a5..e4aae1a6bced55a24360a77d3323c81befbc2b56 100644 --- a/core/modules/config_translation/tests/src/Functional/ConfigTranslationOverviewTest.php +++ b/core/modules/config_translation/tests/src/Functional/ConfigTranslationOverviewTest.php @@ -107,7 +107,7 @@ public function testMapperListPage() { $this->assertIdentical('Translate', $dropbutton->getText()); } - $entity_type = \Drupal::entityManager()->getDefinition($test_entity->getEntityTypeId()); + $entity_type = \Drupal::entityTypeManager()->getDefinition($test_entity->getEntityTypeId()); $this->drupalGet($base_url . '/translate'); $title = $test_entity->label() . ' ' . $entity_type->getLowercaseLabel(); diff --git a/core/modules/contact/tests/src/Kernel/MessageEntityTest.php b/core/modules/contact/tests/src/Kernel/MessageEntityTest.php index e7343b9166c64252afa186ccf870043515e70def..f3025e7b1ceda6a3a4498468a1ccbf5f8ad22641 100644 --- a/core/modules/contact/tests/src/Kernel/MessageEntityTest.php +++ b/core/modules/contact/tests/src/Kernel/MessageEntityTest.php @@ -62,8 +62,8 @@ public function testMessageMethods() { $access_user = $this->createUser(['uid' => 3], ['access site-wide contact form']); $admin = $this->createUser(['uid' => 4], ['administer contact forms']); - $this->assertFalse(\Drupal::entityManager()->getAccessControlHandler('contact_message')->createAccess(NULL, $no_access_user)); - $this->assertTrue(\Drupal::entityManager()->getAccessControlHandler('contact_message')->createAccess(NULL, $access_user)); + $this->assertFalse(\Drupal::entityTypeManager()->getAccessControlHandler('contact_message')->createAccess(NULL, $no_access_user)); + $this->assertTrue(\Drupal::entityTypeManager()->getAccessControlHandler('contact_message')->createAccess(NULL, $access_user)); $this->assertTrue($message->access('edit', $admin)); $this->assertFalse($message->access('edit', $access_user)); } diff --git a/core/modules/content_translation/content_translation.module b/core/modules/content_translation/content_translation.module index 8ebe702ed41ff3488b08c8022a67de0f47f8f3f1..10f546dfd52e56c5b592c2f6eb8efb31767752e5 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 2f4158bec2ada4d348b3d1341171587b93315025..d7f18c4c766b9808478a9567932e4085795f78da 100644 --- a/core/modules/content_translation/src/Tests/ContentTranslationTestBase.php +++ b/core/modules/content_translation/src/Tests/ContentTranslationTestBase.php @@ -127,7 +127,7 @@ protected function getTranslatorPermissions() { * Returns the translate permissions for the current entity and bundle. */ protected function getTranslatePermission() { - $entity_type = \Drupal::entityManager()->getDefinition($this->entityTypeId); + $entity_type = \Drupal::entityTypeManager()->getDefinition($this->entityTypeId); if ($permission_granularity = $entity_type->getPermissionGranularity()) { return $permission_granularity == 'bundle' ? "translate {$this->bundle} {$this->entityTypeId}" : "translate {$this->entityTypeId}"; } @@ -175,7 +175,7 @@ protected function enableTranslation() { // picked up. \Drupal::service('content_translation.manager')->setEnabled($this->entityTypeId, $this->bundle, TRUE); - \Drupal::entityManager()->clearCachedDefinitions(); + \Drupal::entityTypeManager()->clearCachedDefinitions(); \Drupal::service('router.builder')->rebuild(); } @@ -224,7 +224,7 @@ protected function setupTestFields() { protected function createEntity($values, $langcode, $bundle_name = NULL) { $entity_values = $values; $entity_values['langcode'] = $langcode; - $entity_type = \Drupal::entityManager()->getDefinition($this->entityTypeId); + $entity_type = \Drupal::entityTypeManager()->getDefinition($this->entityTypeId); if ($bundle_key = $entity_type->getKey('bundle')) { $entity_values[$bundle_key] = $bundle_name ?: $this->bundle; } diff --git a/core/modules/content_translation/tests/src/Functional/ContentTranslationOperationsTest.php b/core/modules/content_translation/tests/src/Functional/ContentTranslationOperationsTest.php index fc0f788a6a94e045bf8a83a3f6396e9ee9be893b..8486ac529ff016e18429de0d1a4a53fa97701824 100644 --- a/core/modules/content_translation/tests/src/Functional/ContentTranslationOperationsTest.php +++ b/core/modules/content_translation/tests/src/Functional/ContentTranslationOperationsTest.php @@ -126,7 +126,7 @@ public function testOperationTranslateLink() { * @see content_translation_translate_access() */ public function testContentTranslationOverviewAccess() { - $access_control_handler = \Drupal::entityManager()->getAccessControlHandler('node'); + $access_control_handler = \Drupal::entityTypeManager()->getAccessControlHandler('node'); $user = $this->createUser(['create content translations', 'access content']); $this->drupalLogin($user); diff --git a/core/modules/content_translation/tests/src/Functional/ContentTranslationTestBase.php b/core/modules/content_translation/tests/src/Functional/ContentTranslationTestBase.php index 5c9fc23ee6e2e1e9efb4bde6f9213ea26281eaa8..7451e17dbad06b43264a4260d066d69f29a2cfed 100644 --- a/core/modules/content_translation/tests/src/Functional/ContentTranslationTestBase.php +++ b/core/modules/content_translation/tests/src/Functional/ContentTranslationTestBase.php @@ -121,7 +121,7 @@ protected function getTranslatorPermissions() { * Returns the translate permissions for the current entity and bundle. */ protected function getTranslatePermission() { - $entity_type = \Drupal::entityManager()->getDefinition($this->entityTypeId); + $entity_type = \Drupal::entityTypeManager()->getDefinition($this->entityTypeId); if ($permission_granularity = $entity_type->getPermissionGranularity()) { return $permission_granularity == 'bundle' ? "translate {$this->bundle} {$this->entityTypeId}" : "translate {$this->entityTypeId}"; } @@ -218,7 +218,7 @@ protected function setupTestFields() { protected function createEntity($values, $langcode, $bundle_name = NULL) { $entity_values = $values; $entity_values['langcode'] = $langcode; - $entity_type = \Drupal::entityManager()->getDefinition($this->entityTypeId); + $entity_type = \Drupal::entityTypeManager()->getDefinition($this->entityTypeId); if ($bundle_key = $entity_type->getKey('bundle')) { $entity_values[$bundle_key] = $bundle_name ?: $this->bundle; } diff --git a/core/modules/editor/editor.module b/core/modules/editor/editor.module index 43cb782f35426278f3f04ff3c98622e1103ffb9f..619d01f9b798cb940ed5f2e00c191c864380b7d7 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 07c9d24aa871bdcbc12effc59ac3d5fc6146f29f..5d60313a42717e96ad01194004dffa1be7021c7a 100644 --- a/core/modules/editor/src/Entity/Editor.php +++ b/core/modules/editor/src/Entity/Editor.php @@ -127,7 +127,7 @@ public function hasAssociatedFilterFormat() { */ public function getFilterFormat() { if (!$this->filterFormat) { - $this->filterFormat = \Drupal::entityManager()->getStorage('filter_format')->load($this->format); + $this->filterFormat = \Drupal::entityTypeManager()->getStorage('filter_format')->load($this->format); } return $this->filterFormat; } diff --git a/core/modules/editor/tests/src/Kernel/EditorImageDialogTest.php b/core/modules/editor/tests/src/Kernel/EditorImageDialogTest.php index 6500d1adefd0c388b61ad3179b11626f98078c4a..0d0ecaaa605ef5f8a0197951f674dcdb9858f87e 100644 --- a/core/modules/editor/tests/src/Kernel/EditorImageDialogTest.php +++ b/core/modules/editor/tests/src/Kernel/EditorImageDialogTest.php @@ -108,7 +108,7 @@ public function testEditorImageDialog() { ->addBuildInfo('args', [$this->editor]); $form_builder = $this->container->get('form_builder'); - $form_object = new EditorImageDialog(\Drupal::entityManager()->getStorage('file')); + $form_object = new EditorImageDialog(\Drupal::entityTypeManager()->getStorage('file')); $form_id = $form_builder->getFormId($form_object, $form_state); $form = $form_builder->retrieveForm($form_id, $form_state); $form_builder->prepareForm($form_id, $form, $form_state); diff --git a/core/modules/field/field.module b/core/modules/field/field.module index 37b6517a52cc349ed1b2deca0cd35ef61af47aaf..987727a9b8d0e3e17940718457be09fa40de5e29 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 a2b2b929758c023d2039e889bbc3d6e3bb342c38..11b2ac11a635a6b725dd30512a439a60ab48ea2a 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 c38fc4b13631c9025abedf64cf3d375ff774b02b..22bf7c2058a912a0b552aa1419b7f1fce0080241 100644 --- a/core/modules/field/src/ConfigImporterFieldPurger.php +++ b/core/modules/field/src/ConfigImporterFieldPurger.php @@ -71,7 +71,7 @@ protected static function initializeSandbox(array &$context, ConfigImporter $con $context['sandbox']['field']['steps_to_delete'] = 0; $fields = static::getFieldStoragesToPurge($context['sandbox']['field']['extensions'], $config_importer->getUnprocessedConfiguration('delete')); foreach ($fields as $field) { - $row_count = \Drupal::entityManager()->getStorage($field->getTargetEntityTypeId()) + $row_count = \Drupal::entityTypeManager()->getStorage($field->getTargetEntityTypeId()) ->countFieldData($field); if ($row_count > 0) { // The number of steps to delete each field is determined by the @@ -117,7 +117,7 @@ public static function getFieldStoragesToPurge(array $extensions, array $deletes // where the module that provides the field type is also being uninstalled. $field_storage_ids = []; foreach ($deletes as $config_name) { - $field_storage_config_prefix = \Drupal::entityManager()->getDefinition('field_storage_config')->getConfigPrefix(); + $field_storage_config_prefix = \Drupal::entityTypeManager()->getDefinition('field_storage_config')->getConfigPrefix(); if (strpos($config_name, $field_storage_config_prefix . '.') === 0) { $field_storage_ids[] = ConfigEntityStorage::getIDFromConfigName($config_name, $field_storage_config_prefix); } diff --git a/core/modules/field/src/Entity/FieldConfig.php b/core/modules/field/src/Entity/FieldConfig.php index 411943b11c2dac81dd176cd23051381168b79772..2e06d2a4727633c5a94d0d17031481c374e61a9e 100644 --- a/core/modules/field/src/Entity/FieldConfig.php +++ b/core/modules/field/src/Entity/FieldConfig.php @@ -147,7 +147,6 @@ public function postCreate(EntityStorageInterface $storage) { * In case of failures at the configuration storage level. */ public function preSave(EntityStorageInterface $storage) { - $entity_manager = \Drupal::entityManager(); $field_type_manager = \Drupal::service('plugin.manager.field.field_type'); $storage_definition = $this->getFieldStorageDefinition(); @@ -248,7 +247,7 @@ public static function postDelete(EntityStorageInterface $storage, array $fields } } if ($storages_to_delete) { - \Drupal::entityManager()->getStorage('field_storage_config')->delete($storages_to_delete); + \Drupal::entityTypeManager()->getStorage('field_storage_config')->delete($storages_to_delete); } } @@ -274,7 +273,7 @@ protected function linkTemplates() { */ protected function urlRouteParameters($rel) { $parameters = parent::urlRouteParameters($rel); - $entity_type = \Drupal::entityManager()->getDefinition($this->entity_type); + $entity_type = \Drupal::entityTypeManager()->getDefinition($this->entity_type); $bundle_parameter_key = $entity_type->getBundleEntityType() ?: 'bundle'; $parameters[$bundle_parameter_key] = $this->bundle; return $parameters; @@ -372,7 +371,7 @@ public function getUniqueIdentifier() { * name, otherwise NULL. */ public static function loadByName($entity_type_id, $bundle, $field_name) { - return \Drupal::entityManager()->getStorage('field_config')->load($entity_type_id . '.' . $bundle . '.' . $field_name); + return \Drupal::entityTypeManager()->getStorage('field_config')->load($entity_type_id . '.' . $bundle . '.' . $field_name); } } diff --git a/core/modules/field/src/Entity/FieldStorageConfig.php b/core/modules/field/src/Entity/FieldStorageConfig.php index 3277c5416977779ad241662ddf931dd3f8b3621f..2c02eebf442df62eaa65cb551a9f8b67a20a0ec1 100644 --- a/core/modules/field/src/Entity/FieldStorageConfig.php +++ b/core/modules/field/src/Entity/FieldStorageConfig.php @@ -351,7 +351,7 @@ public function calculateDependencies() { $this->addDependencies($definition['class']::calculateStorageDependencies($this)); // Ensure the field is dependent on the provider of the entity type. - $entity_type = \Drupal::entityManager()->getDefinition($this->entity_type); + $entity_type = \Drupal::entityTypeManager()->getDefinition($this->entity_type); $this->addDependency('module', $entity_type->getProvider()); return $this; } @@ -389,10 +389,10 @@ protected function preSaveUpdated(EntityStorageInterface $storage) { public function postSave(EntityStorageInterface $storage, $update = TRUE) { if ($update) { // Invalidate the render cache for all affected entities. - $entity_manager = \Drupal::entityManager(); + $entity_type_manager = \Drupal::entityTypeManager(); $entity_type = $this->getTargetEntityTypeId(); - if ($entity_manager->hasHandler($entity_type, 'view_builder')) { - $entity_manager->getViewBuilder($entity_type)->resetCache(); + if ($entity_type_manager->hasHandler($entity_type, 'view_builder')) { + $entity_type_manager->getViewBuilder($entity_type)->resetCache(); } } } @@ -707,7 +707,7 @@ public function isQueryable() { * TRUE if the field has data for any entity; FALSE otherwise. */ public function hasData() { - return \Drupal::entityManager()->getStorage($this->entity_type)->countFieldData($this, TRUE); + return \Drupal::entityTypeManager()->getStorage($this->entity_type)->countFieldData($this, TRUE); } /** @@ -806,7 +806,7 @@ protected function getFieldItemClass() { * otherwise NULL. */ public static function loadByName($entity_type_id, $field_name) { - return \Drupal::entityManager()->getStorage('field_storage_config')->load($entity_type_id . '.' . $field_name); + return \Drupal::entityTypeManager()->getStorage('field_storage_config')->load($entity_type_id . '.' . $field_name); } /** diff --git a/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceIntegrationTest.php b/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceIntegrationTest.php index 40d0bfa4720af96fe7c979cd0d939e63926f862f..39dd1632db388c051ad569471b0527c88077b4a1 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 @@ public function testSupportedEntityTypesAndWidgets() { // default value deleted. $referenced_entities[0]->delete(); // Reload the field since deleting the default value can change the field. - \Drupal::entityManager()->getStorage($field->getEntityTypeId())->resetCache([$field->id()]); + \Drupal::entityTypeManager()->getStorage($field->getEntityTypeId())->resetCache([$field->id()]); $field = FieldConfig::loadByName($this->entityType, $this->bundle, $this->fieldName); $this->assertConfigEntityImport($field); diff --git a/core/modules/field/tests/src/FunctionalJavascript/EntityReference/EntityReferenceAdminTest.php b/core/modules/field/tests/src/FunctionalJavascript/EntityReference/EntityReferenceAdminTest.php index 20544419e6c9688bda3081410421bf9c29552aea..7b6fabe488c7aaf8660319359628bb40d36a60fb 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 @@ public function testFieldAdminHandler() { $this->assertFieldByName('settings[target_type]', 'node'); // Check that all entity types can be referenced. - $this->assertFieldSelectOptions('settings[target_type]', array_keys(\Drupal::entityManager()->getDefinitions())); + $this->assertFieldSelectOptions('settings[target_type]', array_keys(\Drupal::entityTypeManager()->getDefinitions())); // Second step: 'Field settings' form. $this->drupalPostForm(NULL, [], t('Save field settings')); diff --git a/core/modules/field/tests/src/Kernel/BulkDeleteTest.php b/core/modules/field/tests/src/Kernel/BulkDeleteTest.php index 1c5a4aea4b530bb2437b2b39bd7cd0e4511e48fd..fb0e87d0f004e45bd1978d87ee8a2aa5ff08892b 100644 --- a/core/modules/field/tests/src/Kernel/BulkDeleteTest.php +++ b/core/modules/field/tests/src/Kernel/BulkDeleteTest.php @@ -278,7 +278,7 @@ public function testPurgeWithDeletedAndActiveField() { } // Check that the two field storages have different tables. - $storage = \Drupal::entityManager()->getStorage($this->entityTypeId); + $storage = \Drupal::entityTypeManager()->getStorage($this->entityTypeId); /** @var \Drupal\Core\Entity\Sql\DefaultTableMapping $table_mapping */ $table_mapping = $storage->getTableMapping(); $deleted_table_name = $table_mapping->getDedicatedDataTableName($deleted_field_storage, TRUE); diff --git a/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceFormatterTest.php b/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceFormatterTest.php index 2b191e9c7923ff45c47fc8ede0519f9bd2d0ae91..b42d83c13db099946cdce2873ce92382ec7c371a 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 @@ public function testEntityFormatter() { '; $renderer->renderRoot($build[0]); $this->assertEqual($build[0]['#markup'], 'default | ' . $this->referencedEntity->label() . $expected_rendered_name_field_1 . $expected_rendered_body_field_1, sprintf('The markup returned by the %s formatter is correct for an item with a saved entity.', $formatter)); - $expected_cache_tags = Cache::mergeTags(\Drupal::entityManager()->getViewBuilder($this->entityType)->getCacheTags(), $this->referencedEntity->getCacheTags()); + $expected_cache_tags = Cache::mergeTags(\Drupal::entityTypeManager()->getViewBuilder($this->entityType)->getCacheTags(), $this->referencedEntity->getCacheTags()); $expected_cache_tags = Cache::mergeTags($expected_cache_tags, FilterFormat::load('full_html')->getCacheTags()); $this->assertEqual($build[0]['#cache']['tags'], $expected_cache_tags, format_string('The @formatter formatter has the expected cache tags.', ['@formatter' => $formatter])); diff --git a/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceItemTest.php b/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceItemTest.php index 5c8c667f5e51a55a6bba01898078e4f22809f4fc..f8f57dfe8b924bb699fe691099107190dee38dc0 100644 --- a/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceItemTest.php +++ b/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceItemTest.php @@ -242,7 +242,7 @@ public function testContentEntityReferenceItemWithStringId() { $entity = EntityTest::create(); $entity->field_test_entity_test_string_id->target_id = $this->entityStringId->id(); $entity->save(); - $storage = \Drupal::entityManager()->getStorage('entity_test'); + $storage = \Drupal::entityTypeManager()->getStorage('entity_test'); $storage->resetCache(); $this->assertEqual($this->entityStringId->id(), $storage->load($entity->id())->field_test_entity_test_string_id->target_id); // Verify that the label for the target ID property definition is correct. diff --git a/core/modules/field/tests/src/Kernel/FieldAttachOtherTest.php b/core/modules/field/tests/src/Kernel/FieldAttachOtherTest.php index c3b1f93054541c626d59a2890b25dc9d9409fb54..a8b087461d8974a13edc07c6d1b2166ee3e5d40a 100644 --- a/core/modules/field/tests/src/Kernel/FieldAttachOtherTest.php +++ b/core/modules/field/tests/src/Kernel/FieldAttachOtherTest.php @@ -343,7 +343,7 @@ public function testEntityFormDisplayExtractFormValues() { $values_2[1]['value'] = 0; // Pretend the form has been built. - $form_state->setFormObject(\Drupal::entityManager()->getFormObject($entity_type, 'default')); + $form_state->setFormObject(\Drupal::entityTypeManager()->getFormObject($entity_type, 'default')); \Drupal::formBuilder()->prepareForm('field_test_entity_form', $form, $form_state); \Drupal::formBuilder()->processForm('field_test_entity_form', $form, $form_state); $form_state->setValue($this->fieldTestData->field_name, $values); diff --git a/core/modules/field/tests/src/Kernel/FieldAttachStorageTest.php b/core/modules/field/tests/src/Kernel/FieldAttachStorageTest.php index 04d997d77d6fb5ffdc38d62087da372827c8f75d..7aa6359c7f7b02c949d034b545fde13850cdbdcc 100644 --- a/core/modules/field/tests/src/Kernel/FieldAttachStorageTest.php +++ b/core/modules/field/tests/src/Kernel/FieldAttachStorageTest.php @@ -127,7 +127,7 @@ public function testFieldAttachLoadMultiple() { } // Check that a single load correctly loads field values for both entities. - $controller = \Drupal::entityManager()->getStorage($entity->getEntityTypeId()); + $controller = \Drupal::entityTypeManager()->getStorage($entity->getEntityTypeId()); $controller->resetCache(); $entities = $controller->loadMultiple(); foreach ($entities as $index => $entity) { diff --git a/core/modules/field/tests/src/Kernel/FieldDataCountTest.php b/core/modules/field/tests/src/Kernel/FieldDataCountTest.php index 82ef6d09f0aa0b2453cb56109dc59352d8215d2e..3224763293f01938f894a3aa71850ac8e86df200 100644 --- a/core/modules/field/tests/src/Kernel/FieldDataCountTest.php +++ b/core/modules/field/tests/src/Kernel/FieldDataCountTest.php @@ -39,9 +39,9 @@ class FieldDataCountTest extends FieldKernelTestBase { protected function setUp() { parent::setUp(); $this->installEntitySchema('entity_test_rev'); - $this->storage = \Drupal::entityManager()->getStorage('entity_test'); - $this->storageRev = \Drupal::entityManager()->getStorage('entity_test_rev'); - $this->storageUser = \Drupal::entityManager()->getStorage('user'); + $this->storage = \Drupal::entityTypeManager()->getStorage('entity_test'); + $this->storageRev = \Drupal::entityTypeManager()->getStorage('entity_test_rev'); + $this->storageUser = \Drupal::entityTypeManager()->getStorage('user'); } /** @@ -83,7 +83,7 @@ public function testEntityCountAndHasData() { $entity->save(); } - $storage = \Drupal::entityManager()->getStorage('entity_test'); + $storage = \Drupal::entityTypeManager()->getStorage('entity_test'); if ($storage instanceof SqlContentEntityStorage) { // Count the actual number of rows in the field table. $table_mapping = $storage->getTableMapping(); diff --git a/core/modules/field/tests/src/Kernel/FieldImportDeleteTest.php b/core/modules/field/tests/src/Kernel/FieldImportDeleteTest.php index b4180a0170cae42187e0921520bfd2d64d64c8ae..cfede1e386153cf8e80c5f6660a91d5219413f27 100644 --- a/core/modules/field/tests/src/Kernel/FieldImportDeleteTest.php +++ b/core/modules/field/tests/src/Kernel/FieldImportDeleteTest.php @@ -82,19 +82,19 @@ public function testImportDelete() { $this->configImporter()->import(); // Check that the field storages and fields are gone. - \Drupal::entityManager()->getStorage('field_storage_config')->resetCache([$field_storage_id]); + \Drupal::entityTypeManager()->getStorage('field_storage_config')->resetCache([$field_storage_id]); $field_storage = FieldStorageConfig::load($field_storage_id); $this->assertFalse($field_storage, 'The field storage was deleted.'); - \Drupal::entityManager()->getStorage('field_storage_config')->resetCache([$field_storage_id_2]); + \Drupal::entityTypeManager()->getStorage('field_storage_config')->resetCache([$field_storage_id_2]); $field_storage_2 = FieldStorageConfig::load($field_storage_id_2); $this->assertFalse($field_storage_2, 'The second field storage was deleted.'); - \Drupal::entityManager()->getStorage('field_config')->resetCache([$field_id]); + \Drupal::entityTypeManager()->getStorage('field_config')->resetCache([$field_id]); $field = FieldConfig::load($field_id); $this->assertFalse($field, 'The field was deleted.'); - \Drupal::entityManager()->getStorage('field_config')->resetCache([$field_id_2a]); + \Drupal::entityTypeManager()->getStorage('field_config')->resetCache([$field_id_2a]); $field_2a = FieldConfig::load($field_id_2a); $this->assertFalse($field_2a, 'The second field on test bundle was deleted.'); - \Drupal::entityManager()->getStorage('field_config')->resetCache([$field_id_2b]); + \Drupal::entityTypeManager()->getStorage('field_config')->resetCache([$field_id_2b]); $field_2b = FieldConfig::load($field_id_2b); $this->assertFalse($field_2b, 'The second field on test bundle 2 was deleted.'); diff --git a/core/modules/field/tests/src/Kernel/FieldKernelTestBase.php b/core/modules/field/tests/src/Kernel/FieldKernelTestBase.php index 65dcd9aa5af9d07c0c6e1b7b318c982c64c0e2c8..92dd7d7a31db8bc8042b19bb59d036897bcb40fa 100644 --- a/core/modules/field/tests/src/Kernel/FieldKernelTestBase.php +++ b/core/modules/field/tests/src/Kernel/FieldKernelTestBase.php @@ -52,7 +52,7 @@ protected function setUp() { $this->installConfig(['field', 'system']); // Create user 1. - $storage = \Drupal::entityManager()->getStorage('user'); + $storage = \Drupal::entityTypeManager()->getStorage('user'); $storage ->create([ 'uid' => 1, diff --git a/core/modules/field/tests/src/Kernel/Timestamp/TimestampFormatterTest.php b/core/modules/field/tests/src/Kernel/Timestamp/TimestampFormatterTest.php index 1734a7213b967211b68a1e4fc972bbcce8f2b170..d7a771729d51432da872f59ef35e56c01c8718ec 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 @@ public function testTimestampFormatter() { $data = []; // Test standard formats. - $date_formats = array_keys(\Drupal::entityManager()->getStorage('date_format')->loadMultiple()); + $date_formats = array_keys(\Drupal::entityTypeManager()->getStorage('date_format')->loadMultiple()); foreach ($date_formats as $date_format) { $data[] = ['date_format' => $date_format, 'custom_date_format' => '', 'timezone' => '']; diff --git a/core/modules/field/tests/src/Kernel/TranslationTest.php b/core/modules/field/tests/src/Kernel/TranslationTest.php index 31ee4b41fdefb8a44b1c78adf1060751dbc7dd3c..605c5574b4aa9bb11f898f5ccad3d6955adc99b9 100644 --- a/core/modules/field/tests/src/Kernel/TranslationTest.php +++ b/core/modules/field/tests/src/Kernel/TranslationTest.php @@ -109,7 +109,7 @@ protected function setUp() { public function testTranslatableFieldSaveLoad() { // Enable field translations for nodes. field_test_entity_info_translatable('node', TRUE); - $entity_type = \Drupal::entityManager()->getDefinition('node'); + $entity_type = \Drupal::entityTypeManager()->getDefinition('node'); $this->assertTrue($entity_type->isTranslatable(), 'Nodes are translatable.'); // Prepare the field translations. @@ -203,7 +203,7 @@ public function testTranslatableFieldSaveLoad() { * @see https://www.drupal.org/node/2404739 */ public function testFieldAccess() { - $access_control_handler = \Drupal::entityManager()->getAccessControlHandler($this->entityType); + $access_control_handler = \Drupal::entityTypeManager()->getAccessControlHandler($this->entityType); $this->assertTrue($access_control_handler->fieldAccess('view', $this->field)); } diff --git a/core/modules/field_ui/field_ui.module b/core/modules/field_ui/field_ui.module index a73f15327166f4707e2d6d9638939a658aedf6a3..488be766b20ca7f0182aafc3e384887c05466cb3 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 b9351a4b77ffd3479fb1f5c43c0d414c6eeb7397..0d5d7771dc303f9732f413afd7ac4489806acd63 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 b3df37181854d8efc1e605ca0f8de7d9c157a61d..93b277f3e4c2c109b2bdcceb5a8810813fad0e68 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 8e45101bd84ab3be5e74acc68a8929647fe63b54..f2c2482f5646cfebe7fab8960539ed5fafc736f1 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 c7cf0f04e48c67fe82035275b90259c13abb5151..ab936177bb3879da320c3bb8b47a334f62135808 100644 --- a/core/modules/file/src/Plugin/Field/FieldType/FileFieldItemList.php +++ b/core/modules/file/src/Plugin/Field/FieldType/FileFieldItemList.php @@ -60,7 +60,7 @@ public function postSave($update) { // Decrement file usage by 1 for files that were removed from the field. $removed_ids = array_filter(array_diff($original_ids, $ids)); - $removed_files = \Drupal::entityManager()->getStorage('file')->loadMultiple($removed_ids); + $removed_files = \Drupal::entityTypeManager()->getStorage('file')->loadMultiple($removed_ids); foreach ($removed_files as $file) { \Drupal::service('file.usage')->delete($file, 'file', $entity->getEntityTypeId(), $entity->id()); } diff --git a/core/modules/file/tests/src/Functional/FileManagedFileElementTest.php b/core/modules/file/tests/src/Functional/FileManagedFileElementTest.php index 7feaa507dab8464c1a80d86887608fe6db9325e8..2b448ba7dbfb9424e26ce4778496e497767bf738 100644 --- a/core/modules/file/tests/src/Functional/FileManagedFileElementTest.php +++ b/core/modules/file/tests/src/Functional/FileManagedFileElementTest.php @@ -142,7 +142,7 @@ public function testManagedFileRemoved() { $this->drupalPostForm(NULL, $edit, t('Upload')); $fid = $this->getLastFileId(); - $file = \Drupal::entityManager()->getStorage('file')->load($fid); + $file = \Drupal::entityTypeManager()->getStorage('file')->load($fid); $file->delete(); $this->drupalPostForm(NULL, $edit, t('Upload')); diff --git a/core/modules/file/tests/src/Functional/FilePrivateTest.php b/core/modules/file/tests/src/Functional/FilePrivateTest.php index 2e5b0a1dac50c6c1e94ecf1a6bbe887b6815fa2c..7a6824b1323e52e78f6892b53ae5881700b77ead 100644 --- a/core/modules/file/tests/src/Functional/FilePrivateTest.php +++ b/core/modules/file/tests/src/Functional/FilePrivateTest.php @@ -46,7 +46,7 @@ public function testPrivateFile() { $test_file = $this->getTestFile('text'); $nid = $this->uploadNodeFile($test_file, $field_name, $type_name, TRUE, ['private' => TRUE]); - \Drupal::entityManager()->getStorage('node')->resetCache([$nid]); + \Drupal::entityTypeManager()->getStorage('node')->resetCache([$nid]); /* @var \Drupal\node\NodeInterface $node */ $node = $node_storage->load($nid); $node_file = File::load($node->{$field_name}->target_id); @@ -67,7 +67,7 @@ public function testPrivateFile() { // Test with the field that should deny access through field access. $this->drupalLogin($this->adminUser); $nid = $this->uploadNodeFile($test_file, $no_access_field_name, $type_name, TRUE, ['private' => TRUE]); - \Drupal::entityManager()->getStorage('node')->resetCache([$nid]); + \Drupal::entityTypeManager()->getStorage('node')->resetCache([$nid]); $node = $node_storage->load($nid); $node_file = File::load($node->{$no_access_field_name}->target_id); diff --git a/core/modules/file/tests/src/Functional/PrivateFileOnTranslatedEntityTest.php b/core/modules/file/tests/src/Functional/PrivateFileOnTranslatedEntityTest.php index ab31eb757f3aff7b78e0641c58ca17e0c4428242..44b2ee10c9c70ac77329ac206b8312c6240a37ed 100644 --- a/core/modules/file/tests/src/Functional/PrivateFileOnTranslatedEntityTest.php +++ b/core/modules/file/tests/src/Functional/PrivateFileOnTranslatedEntityTest.php @@ -87,7 +87,7 @@ public function testPrivateLanguageFile() { $this->rebuildContainer(); // Ensure the file can be downloaded. - \Drupal::entityManager()->getStorage('node')->resetCache([$default_language_node->id()]); + \Drupal::entityTypeManager()->getStorage('node')->resetCache([$default_language_node->id()]); $node = Node::load($default_language_node->id()); $node_file = File::load($node->{$this->fieldName}->target_id); $this->drupalGet(file_create_url($node_file->getFileUri())); @@ -109,7 +109,7 @@ public function testPrivateLanguageFile() { $last_fid = $this->getLastFileId(); // Verify the translation was created. - \Drupal::entityManager()->getStorage('node')->resetCache([$default_language_node->id()]); + \Drupal::entityTypeManager()->getStorage('node')->resetCache([$default_language_node->id()]); $default_language_node = Node::load($default_language_node->id()); $this->assertTrue($default_language_node->hasTranslation('fr'), 'Node found in database.'); $this->assertTrue($last_fid > $last_fid_prior, 'New file got saved.'); diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module index 3246f10db811714f0223aa42e243c2bbb3aeb8c2..4d72ff1625aefe6063a189d0dd05d8fff28821ed 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 8ce4fa910897c8a94032e67329f281e88409c7ec..ed6bff8668dd2ce1243e0b24aba3aac81ffbf2ec 100644 --- a/core/modules/filter/tests/src/Kernel/FilterAPITest.php +++ b/core/modules/filter/tests/src/Kernel/FilterAPITest.php @@ -487,7 +487,7 @@ public function testDependencyRemoval() { $this->assertTrue(isset($filters['filter_test_restrict_tags_and_attributes']), 'The filter plugin filter_test_restrict_tags_and_attributes is configured by the filtered_html filter format.'); drupal_static_reset('filter_formats'); - \Drupal::entityManager()->getStorage('filter_format')->resetCache(); + \Drupal::entityTypeManager()->getStorage('filter_format')->resetCache(); $module_data = \Drupal::service('extension.list.module')->reset()->getList(); $this->assertFalse(isset($module_data['filter_test']->info['required']), 'The filter_test module is required.'); @@ -500,7 +500,7 @@ public function testDependencyRemoval() { // Verify the filter format still exists but the dependency and filter is // gone. - \Drupal::entityManager()->getStorage('filter_format')->resetCache(); + \Drupal::entityTypeManager()->getStorage('filter_format')->resetCache(); $filter_format = FilterFormat::load('filtered_html'); $this->assertEqual([], $filter_format->getDependencies()); // Use the get method since the FilterFormat::filters() method only returns diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module index 108ee648e2e703410ef5de5979504a7a066cedc0..f75a810b13f38e91b3d3ee6cec9f03f9034c0004 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<span class="visually-hidden"> in topic %title</span>', '@count new posts<span class="visually-hidden"> in topic %title</span>', ['%title' => $variables['topics'][$id]->label()]); diff --git a/core/modules/image/image.views.inc b/core/modules/image/image.views.inc index cca0e3d904de6be0ac674b2b1d83650d773cd8e4..483f989faf9f15fd72172cf59846ea211b1c3268 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 ba4677d7ea0b849785bea403a8d1803068ef8522..3880a689615feb9d288daf94f5bcb61024fb5f90 100644 --- a/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php +++ b/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php @@ -481,7 +481,7 @@ public static function validateDefaultImageForm(array &$element, FormStateInterf if (isset($element['fids']['#value'][0])) { $value = $element['fids']['#value'][0]; // Convert the file ID to a uuid. - if ($file = \Drupal::entityManager()->getStorage('file')->load($value)) { + if ($file = \Drupal::entityTypeManager()->getStorage('file')->load($value)) { $value = $file->uuid(); } } diff --git a/core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php b/core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php index 2dde5527886a347336df1c4890bec69010e45aa2..47aa51fa15c7a40dbbf45d2097a42d1805649f1f 100644 --- a/core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php +++ b/core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php @@ -326,7 +326,7 @@ public function onDependencyRemoval(array $dependencies) { if ($style_id && $style = ImageStyle::load($style_id)) { if (!empty($dependencies[$style->getConfigDependencyKey()][$style->getConfigDependencyName()])) { /** @var \Drupal\image\ImageStyleStorageInterface $storage */ - $storage = \Drupal::entityManager()->getStorage($style->getEntityTypeId()); + $storage = \Drupal::entityTypeManager()->getStorage($style->getEntityTypeId()); $replacement_id = $storage->getReplacementId($style_id); // If a valid replacement has been provided in the storage, replace the // preview image style with the replacement. diff --git a/core/modules/jsonapi/tests/src/Functional/JsonApiFunctionalTest.php b/core/modules/jsonapi/tests/src/Functional/JsonApiFunctionalTest.php index b2d6f1033ff596acdb4bde2828d66a022875c32e..bea8773efbcfe5d0e9ab43121451327440484c35 100644 --- a/core/modules/jsonapi/tests/src/Functional/JsonApiFunctionalTest.php +++ b/core/modules/jsonapi/tests/src/Functional/JsonApiFunctionalTest.php @@ -748,7 +748,7 @@ public function testWrite() { $this->assertEquals("The current user is not allowed to PATCH the selected field (status). The 'administer nodes' permission is required.", $updated_response['errors'][0]['detail']); - $node = \Drupal::entityManager()->loadEntityByUuid('node', $uuid); + $node = \Drupal::service('entity.repository')->loadEntityByUuid('node', $uuid); $this->assertEquals(1, $node->get('status')->value, 'Node status was not changed.'); // 9. Successful POST to related endpoint. $body = [ diff --git a/core/modules/language/language.module b/core/modules/language/language.module index 0df467dc14352d45ece93b826ab6dbeeacb5b10d..368248c75b61db3978e391865af4b9e4c238c801 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 59803defe1a9c7448c9bf860b483017cdacb4c17..509dbaf3c7110f56d50bdeb9f9300001ebf59445 100644 --- a/core/modules/language/src/Entity/ContentLanguageSettings.php +++ b/core/modules/language/src/Entity/ContentLanguageSettings.php @@ -190,7 +190,7 @@ public static function loadByEntityTypeBundle($entity_type_id, $bundle) { if ($entity_type_id == NULL || $bundle == NULL) { return NULL; } - $config = \Drupal::entityManager()->getStorage('language_content_settings')->load($entity_type_id . '.' . $bundle); + $config = \Drupal::entityTypeManager()->getStorage('language_content_settings')->load($entity_type_id . '.' . $bundle); if ($config == NULL) { $config = ContentLanguageSettings::create(['target_entity_type_id' => $entity_type_id, 'target_bundle' => $bundle]); } @@ -204,7 +204,7 @@ public function calculateDependencies() { parent::calculateDependencies(); // Create dependency on the bundle. - $entity_type = \Drupal::entityManager()->getDefinition($this->target_entity_type_id); + $entity_type = \Drupal::entityTypeManager()->getDefinition($this->target_entity_type_id); $bundle_config_dependency = $entity_type->getBundleConfigDependency($this->target_bundle); $this->addDependency($bundle_config_dependency['type'], $bundle_config_dependency['name']); diff --git a/core/modules/language/tests/src/Functional/LanguageConfigurationElementTest.php b/core/modules/language/tests/src/Functional/LanguageConfigurationElementTest.php index 9e71064c0bd999b4b71991e82e11e490675294ac..7d400cab4cbaf344287ff8512c7d069393c8fd61 100644 --- a/core/modules/language/tests/src/Functional/LanguageConfigurationElementTest.php +++ b/core/modules/language/tests/src/Functional/LanguageConfigurationElementTest.php @@ -203,15 +203,15 @@ public function testNodeTypeDelete() { $this->drupalPostForm('admin/structure/types/manage/article', $edit, t('Save content type')); // Check the language default configuration for articles is present. - $configuration = \Drupal::entityManager()->getStorage('language_content_settings')->load('node.article'); + $configuration = \Drupal::entityTypeManager()->getStorage('language_content_settings')->load('node.article'); $this->assertTrue($configuration, 'The language configuration is present.'); // Delete 'article' bundle. $this->drupalPostForm('admin/structure/types/manage/article/delete', [], t('Delete')); // Check that the language configuration has been deleted. - \Drupal::entityManager()->getStorage('language_content_settings')->resetCache(); - $configuration = \Drupal::entityManager()->getStorage('language_content_settings')->load('node.article'); + \Drupal::entityTypeManager()->getStorage('language_content_settings')->resetCache(); + $configuration = \Drupal::entityTypeManager()->getStorage('language_content_settings')->load('node.article'); $this->assertFalse($configuration, 'The language configuration was deleted after bundle was deleted.'); } diff --git a/core/modules/menu_link_content/menu_link_content.module b/core/modules/menu_link_content/menu_link_content.module index a0ea8da55bffb0942cd4dc2e35d994d9fbb5941b..559405dfbe9a38c307fc0f1da2c2da2fc7144d71 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 a8b9862223dff93feaa4fb9bda1f3945eff76a17..136b246b1c35f8f5c653eb2c52e3d55e54e1cd73 100644 --- a/core/modules/menu_ui/src/Tests/MenuWebTestBase.php +++ b/core/modules/menu_ui/src/Tests/MenuWebTestBase.php @@ -37,7 +37,7 @@ public function assertMenuLink($menu_plugin_id, array $expected_item) { $menu_link_manager = \Drupal::service('plugin.manager.menu.link'); $menu_link_manager->resetDefinitions(); // Reset the static load cache. - \Drupal::entityManager()->getStorage('menu_link_content')->resetCache(); + \Drupal::entityTypeManager()->getStorage('menu_link_content')->resetCache(); $definition = $menu_link_manager->getDefinition($menu_plugin_id); $entity = NULL; @@ -46,7 +46,7 @@ public function assertMenuLink($menu_plugin_id, array $expected_item) { if (strpos($menu_plugin_id, 'menu_link_content') === 0) { list(, $uuid) = explode(':', $menu_plugin_id, 2); /** @var \Drupal\menu_link_content\Entity\MenuLinkContent $entity */ - $entity = \Drupal::entityManager()->loadEntityByUuid('menu_link_content', $uuid); + $entity = \Drupal::service('entity.repository')->loadEntityByUuid('menu_link_content', $uuid); } if (isset($expected_item['children'])) { diff --git a/core/modules/menu_ui/tests/src/Functional/MenuUninstallTest.php b/core/modules/menu_ui/tests/src/Functional/MenuUninstallTest.php index a0320f44b0ff67cd6736819c6263961c6557772d..b2d64cece5c801316726037f67cf3eb0f6d6879a 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 b0f2fa8a1a1d6c80c573d725a3e0ce8e6bb49874..c3a0506419d5236cff14e781792d5d26152491a0 100644 --- a/core/modules/migrate/src/MigrateExecutable.php +++ b/core/modules/migrate/src/MigrateExecutable.php @@ -546,9 +546,9 @@ protected function attemptMemoryReclaim() { drupal_static_reset(); // Entity storage can blow up with caches so clear them out. - $manager = \Drupal::entityManager(); - foreach ($manager->getDefinitions() as $id => $definition) { - $manager->getStorage($id)->resetCache(); + $entity_type_manager = \Drupal::entityTypeManager(); + foreach ($entity_type_manager->getDefinitions() as $id => $definition) { + $entity_type_manager->getStorage($id)->resetCache(); } // @TODO: explore resetting the container. diff --git a/core/modules/migrate_drupal/src/Tests/StubTestTrait.php b/core/modules/migrate_drupal/src/Tests/StubTestTrait.php index 3bf00281a0378aa22e0e77f64de4ac37cb5b79c3..5a5fa043325f7d48997992e81d278ad09eff8f33 100644 --- a/core/modules/migrate_drupal/src/Tests/StubTestTrait.php +++ b/core/modules/migrate_drupal/src/Tests/StubTestTrait.php @@ -65,7 +65,7 @@ protected function createStub($entity_type_id) { * List of constraint violations identified. */ protected function validateStub($entity_type_id, $entity_id) { - $controller = \Drupal::entityManager()->getStorage($entity_type_id); + $controller = \Drupal::entityTypeManager()->getStorage($entity_type_id); /** @var \Drupal\Core\Entity\ContentEntityInterface $stub_entity */ $stub_entity = $controller->load($entity_id); return $stub_entity->validate(); diff --git a/core/modules/node/node.install b/core/modules/node/node.install index 1380d63ae8ee719fefb5c2184e296f0261c12359..e05c841128f88dafa9b90bbba61889be98b66b73 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 dfe5370faf2e56488c784edb1a21c46bb1973def..4560a7c66e85bcb273af3c8b5f2eeea0d865cfd0 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 b3d19d4e89ee647d7098b7729425b40cff79b536..88bac5aadd5e7c20395fea48e28fb5a9bd6c8eed 100644 --- a/core/modules/node/src/Entity/Node.php +++ b/core/modules/node/src/Entity/Node.php @@ -144,7 +144,7 @@ public function postSave(EntityStorageInterface $storage, $update = TRUE) { // is new. if ($this->isDefaultRevision()) { /** @var \Drupal\node\NodeAccessControlHandlerInterface $access_control_handler */ - $access_control_handler = \Drupal::entityManager()->getAccessControlHandler('node'); + $access_control_handler = \Drupal::entityTypeManager()->getAccessControlHandler('node'); $grants = $access_control_handler->acquireGrants($this); \Drupal::service('node.grant_storage')->write($this, $grants, NULL, $update); } diff --git a/core/modules/node/src/Tests/NodeTestBase.php b/core/modules/node/src/Tests/NodeTestBase.php index e520b3283e7e239bb7aa08b91fede16b51fe2962..08e33e6f22d468de3529bf0d3296603b6784d15d 100644 --- a/core/modules/node/src/Tests/NodeTestBase.php +++ b/core/modules/node/src/Tests/NodeTestBase.php @@ -47,7 +47,7 @@ protected function setUp() { ]); $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']); } - $this->accessHandler = \Drupal::entityManager()->getAccessControlHandler('node'); + $this->accessHandler = \Drupal::entityTypeManager()->getAccessControlHandler('node'); } /** diff --git a/core/modules/node/tests/src/Functional/NodeAccessPagerTest.php b/core/modules/node/tests/src/Functional/NodeAccessPagerTest.php index ad6cc549446d117f34f9b86435864f18beeef687..6e7e0f216a4d6279fa174895859c5b298ba66c81 100644 --- a/core/modules/node/tests/src/Functional/NodeAccessPagerTest.php +++ b/core/modules/node/tests/src/Functional/NodeAccessPagerTest.php @@ -74,7 +74,7 @@ public function testForumPager() { $this->assertTrue($vid, 'Forum navigation vocabulary ID is set.'); // Look up the general discussion term. - $tree = \Drupal::entityManager()->getStorage('taxonomy_term')->loadTree($vid, 0, 1); + $tree = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadTree($vid, 0, 1); $tid = reset($tree)->tid; $this->assertTrue($tid, 'General discussion term is found in the forum vocabulary.'); diff --git a/core/modules/node/tests/src/Functional/NodeCreationTest.php b/core/modules/node/tests/src/Functional/NodeCreationTest.php index f5b69208329362c4e804907cd40a90b4f78881dd..1ac6965fca51f7f83527094d0dfdebf093227fb8 100644 --- a/core/modules/node/tests/src/Functional/NodeCreationTest.php +++ b/core/modules/node/tests/src/Functional/NodeCreationTest.php @@ -34,7 +34,7 @@ protected function setUp() { * Creates a "Basic page" node and verifies its consistency in the database. */ public function testNodeCreation() { - $node_type_storage = \Drupal::entityManager()->getStorage('node_type'); + $node_type_storage = \Drupal::entityTypeManager()->getStorage('node_type'); // Test /node/add page with only one content type. $node_type_storage->load('article')->delete(); @@ -248,7 +248,7 @@ public function testNodeAddWithoutContentTypes() { $this->assertNoLinkByHref('/admin/structure/types/add'); // Test /node/add page without content types. - foreach (\Drupal::entityManager()->getStorage('node_type')->loadMultiple() as $entity) { + foreach (\Drupal::entityTypeManager()->getStorage('node_type')->loadMultiple() as $entity) { $entity->delete(); } diff --git a/core/modules/node/tests/src/Functional/NodeEditFormTest.php b/core/modules/node/tests/src/Functional/NodeEditFormTest.php index 89f891a64317ac7e3e8f8bfba4cc9bd8c41425fe..642fba31b828d680ea3260a03926c400bf80e291 100644 --- a/core/modules/node/tests/src/Functional/NodeEditFormTest.php +++ b/core/modules/node/tests/src/Functional/NodeEditFormTest.php @@ -167,7 +167,7 @@ public function testNodeEditAuthoredBy() { // Now test with the Autocomplete (Tags) field widget. /** @var \Drupal\Core\Entity\Display\EntityFormDisplayInterface $form_display */ - $form_display = \Drupal::entityManager()->getStorage('entity_form_display')->load('node.page.default'); + $form_display = \Drupal::entityTypeManager()->getStorage('entity_form_display')->load('node.page.default'); $widget = $form_display->getComponent('uid'); $widget['type'] = 'entity_reference_autocomplete_tags'; $widget['settings'] = [ diff --git a/core/modules/node/tests/src/Functional/NodeSaveTest.php b/core/modules/node/tests/src/Functional/NodeSaveTest.php index 6c508aee68ddd56ccedbd5f173f2181352181588..64b38610d60c91891c85be4150f8983b71e738c9 100644 --- a/core/modules/node/tests/src/Functional/NodeSaveTest.php +++ b/core/modules/node/tests/src/Functional/NodeSaveTest.php @@ -44,7 +44,7 @@ protected function setUp() { */ public function testImport() { // Node ID must be a number that is not in the database. - $nids = \Drupal::entityManager()->getStorage('node')->getQuery() + $nids = \Drupal::entityTypeManager()->getStorage('node')->getQuery() ->sort('nid', 'DESC') ->range(0, 1) ->execute(); diff --git a/core/modules/node/tests/src/Functional/NodeTemplateSuggestionsTest.php b/core/modules/node/tests/src/Functional/NodeTemplateSuggestionsTest.php index dcadf934ded18cb7b1e38f26a29150680b2e087a..371cf1c32d6d631164ceca359437d220971374cc 100644 --- a/core/modules/node/tests/src/Functional/NodeTemplateSuggestionsTest.php +++ b/core/modules/node/tests/src/Functional/NodeTemplateSuggestionsTest.php @@ -18,7 +18,7 @@ public function testNodeThemeHookSuggestions() { $view_mode = 'full'; // Simulate theming of the node. - $build = \Drupal::entityManager()->getViewBuilder('node')->view($node, $view_mode); + $build = \Drupal::entityTypeManager()->getViewBuilder('node')->view($node, $view_mode); $variables['elements'] = $build; $suggestions = \Drupal::moduleHandler()->invokeAll('theme_suggestions_node', [$variables]); @@ -27,7 +27,7 @@ public function testNodeThemeHookSuggestions() { // Change the view mode. $view_mode = 'node.my_custom_view_mode'; - $build = \Drupal::entityManager()->getViewBuilder('node')->view($node, $view_mode); + $build = \Drupal::entityTypeManager()->getViewBuilder('node')->view($node, $view_mode); $variables['elements'] = $build; $suggestions = \Drupal::moduleHandler()->invokeAll('theme_suggestions_node', [$variables]); diff --git a/core/modules/node/tests/src/Functional/NodeTestBase.php b/core/modules/node/tests/src/Functional/NodeTestBase.php index e52708632b9e2b3648debaf2d1018ddd6254bb35..264ac31535e2b1ee8dc3134ccb1fb6c6af8e404a 100644 --- a/core/modules/node/tests/src/Functional/NodeTestBase.php +++ b/core/modules/node/tests/src/Functional/NodeTestBase.php @@ -40,7 +40,7 @@ protected function setUp() { ]); $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']); } - $this->accessHandler = \Drupal::entityManager()->getAccessControlHandler('node'); + $this->accessHandler = \Drupal::entityTypeManager()->getAccessControlHandler('node'); } /** diff --git a/core/modules/node/tests/src/Functional/NodeTranslationUITest.php b/core/modules/node/tests/src/Functional/NodeTranslationUITest.php index 3348ad9d907bab028503378e2b8cac484e6e5b14..00722fdfff088efa3f1f4273ad2a16409c4ee6b2 100644 --- a/core/modules/node/tests/src/Functional/NodeTranslationUITest.php +++ b/core/modules/node/tests/src/Functional/NodeTranslationUITest.php @@ -279,7 +279,7 @@ public function testTranslationRendering() { $default_langcode = $this->langcodes[0]; $values[$default_langcode] = $this->getNewEntityValues($default_langcode); $this->entityId = $this->createEntity($values[$default_langcode], $default_langcode); - $node = \Drupal::entityManager()->getStorage($this->entityTypeId)->load($this->entityId); + $node = \Drupal::entityTypeManager()->getStorage($this->entityTypeId)->load($this->entityId); $node->setPromoted(TRUE); // Create translations. @@ -298,7 +298,7 @@ public function testTranslationRendering() { $this->doTestTranslations('node', $values); // Enable the translation language renderer. - $view = \Drupal::entityManager()->getStorage('view')->load('frontpage'); + $view = \Drupal::entityTypeManager()->getStorage('view')->load('frontpage'); $display = &$view->getDisplay('default'); $display['display_options']['rendering_language'] = '***LANGUAGE_entity_translation***'; $view->save(); diff --git a/core/modules/node/tests/src/Functional/Views/BulkFormAccessTest.php b/core/modules/node/tests/src/Functional/Views/BulkFormAccessTest.php index 19c409719d06db8931d7262972909116e845d9b6..a51fe21b7477675c2e9ce9ba78889724f02932cb 100644 --- a/core/modules/node/tests/src/Functional/Views/BulkFormAccessTest.php +++ b/core/modules/node/tests/src/Functional/Views/BulkFormAccessTest.php @@ -47,7 +47,7 @@ protected function setUp($import_test_views = TRUE) { // Create Article node type. $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']); - $this->accessHandler = \Drupal::entityManager()->getAccessControlHandler('node'); + $this->accessHandler = \Drupal::entityTypeManager()->getAccessControlHandler('node'); node_access_test_add_field(NodeType::load('article')); diff --git a/core/modules/node/tests/src/Functional/Views/NodeRevisionWizardTest.php b/core/modules/node/tests/src/Functional/Views/NodeRevisionWizardTest.php index 3a3c5723a68d36f0e89ff83521649488e8a01a15..2dc97b00c33cb5c6ad5eec6b72f857cfbb35ea39 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 47366b788a26d3aef3882633e45b93b0713b5d5b..131219a710abde2784b6ace4c537788e4ae0d8e6 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 @@ protected function setUp() { * Test node revisions migration from Drupal 6 to 8. */ public function testNodeRevision() { - $node = \Drupal::entityManager()->getStorage('node')->loadRevision(2001); + $node = \Drupal::entityTypeManager()->getStorage('node')->loadRevision(2001); /** @var \Drupal\node\NodeInterface $node */ $this->assertIdentical('1', $node->id()); $this->assertIdentical('2001', $node->getRevisionId()); @@ -38,7 +38,7 @@ public function testNodeRevision() { $this->assertIdentical('modified rev 2', $node->revision_log->value); $this->assertIdentical('1390095702', $node->getRevisionCreationTime()); - $node = \Drupal::entityManager()->getStorage('node')->loadRevision(5); + $node = \Drupal::entityTypeManager()->getStorage('node')->loadRevision(5); $this->assertIdentical('1', $node->id()); $this->assertIdentical('body test rev 3', $node->body->value); $this->assertIdentical('1', $node->getRevisionUser()->id()); diff --git a/core/modules/node/tests/src/Kernel/Migrate/d6/MigrateNodeTest.php b/core/modules/node/tests/src/Kernel/Migrate/d6/MigrateNodeTest.php index 997df83b52fc7575548ce12a0794d7c0873e2244..c390af2db4ed1eac52de533d2ed8580a156801c0 100644 --- a/core/modules/node/tests/src/Kernel/Migrate/d6/MigrateNodeTest.php +++ b/core/modules/node/tests/src/Kernel/Migrate/d6/MigrateNodeTest.php @@ -60,7 +60,7 @@ public function testNode() { $this->assertIdentical('1420861423', $node->getRevisionCreationTime()); /** @var \Drupal\node\NodeInterface $node_revision */ - $node_revision = \Drupal::entityManager()->getStorage('node')->loadRevision(1); + $node_revision = \Drupal::entityTypeManager()->getStorage('node')->loadRevision(1); $this->assertIdentical('Test title', $node_revision->getTitle()); $this->assertIdentical('1', $node_revision->getRevisionUser()->id(), 'Node revision has the correct user'); $this->assertSame('1', $node_revision->id(), 'Node 1 loaded.'); diff --git a/core/modules/node/tests/src/Kernel/Migrate/d7/MigrateNodeTest.php b/core/modules/node/tests/src/Kernel/Migrate/d7/MigrateNodeTest.php index 0e660060321586bceede88aa48ba61540ccfa81a..7caeb72427836433732b83fb3be3a0b50f6a5c60 100644 --- a/core/modules/node/tests/src/Kernel/Migrate/d7/MigrateNodeTest.php +++ b/core/modules/node/tests/src/Kernel/Migrate/d7/MigrateNodeTest.php @@ -131,7 +131,7 @@ protected function assertEntity($id, $type, $langcode, $title, $uid, $status, $c * The revision's time stamp. */ protected function assertRevision($id, $title, $uid, $log, $timestamp) { - $revision = \Drupal::entityManager()->getStorage('node')->loadRevision($id); + $revision = \Drupal::entityTypeManager()->getStorage('node')->loadRevision($id); $this->assertInstanceOf(NodeInterface::class, $revision); $this->assertEquals($title, $revision->getTitle()); $this->assertEquals($uid, $revision->getRevisionUser()->id()); diff --git a/core/modules/node/tests/src/Kernel/NodeAccessLanguageTest.php b/core/modules/node/tests/src/Kernel/NodeAccessLanguageTest.php index 1b8699198e6bb99162987a912e8891cddd2fae34..06709021c628c2a5c2c0283c7a61ebd46ddf8e1a 100644 --- a/core/modules/node/tests/src/Kernel/NodeAccessLanguageTest.php +++ b/core/modules/node/tests/src/Kernel/NodeAccessLanguageTest.php @@ -73,7 +73,7 @@ public function testNodeAccess() { $this->assertNodeAccess($expected_node_access, $node_public_no_language, $web_user); // Reset the node access cache and turn on our test node access code. - \Drupal::entityManager()->getAccessControlHandler('node')->resetCache(); + \Drupal::entityTypeManager()->getAccessControlHandler('node')->resetCache(); \Drupal::state()->set('node_access_test_secret_catalan', 1); $node_public_ca = $this->drupalCreateNode(['body' => [[]], 'langcode' => 'ca', 'private' => FALSE]); $this->assertTrue($node_public_ca->language()->getId() == 'ca', 'Node created as Catalan.'); @@ -97,7 +97,7 @@ public function testNodeAccess() { $this->assertNodeAccess($expected_node_access_no_access, $node_public_ca, $web_user); $this->assertNodeAccess($expected_node_access_no_access, $node_public_ca->getTranslation('ca'), $web_user); - \Drupal::entityManager()->getAccessControlHandler('node')->resetCache(); + \Drupal::entityTypeManager()->getAccessControlHandler('node')->resetCache(); // Tests that access is granted if requested with no language. $this->assertNodeAccess($expected_node_access, $node_public_no_language, $web_user); @@ -142,7 +142,7 @@ public function testNodeAccessPrivate() { $this->assertNodeAccess($expected_node_access_no_access, $node_private_no_language, $web_user); // Reset the node access cache and turn on our test node access code. - \Drupal::entityManager()->getAccessControlHandler('node')->resetCache(); + \Drupal::entityTypeManager()->getAccessControlHandler('node')->resetCache(); \Drupal::state()->set('node_access_test_secret_catalan', 1); // Tests that access is not granted if requested with no language. @@ -160,7 +160,7 @@ public function testNodeAccessPrivate() { $this->assertNodeAccess($expected_node_access_no_access, $node_private_ca, $private_ca_user); $this->assertNodeAccess($expected_node_access_no_access, $node_private_ca->getTranslation('ca'), $private_ca_user); - \Drupal::entityManager()->getAccessControlHandler('node')->resetCache(); + \Drupal::entityTypeManager()->getAccessControlHandler('node')->resetCache(); \Drupal::state()->set('node_access_test_secret_catalan', 0); // Tests that Catalan is still not accessible for a user with no access to diff --git a/core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditLoadingTest.php b/core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditLoadingTest.php index 3699995dc504a1b7f1a773ac82811011c6a6f0cd..2424374570bd6468553b2ccc6879dbf5fcfeba4d 100644 --- a/core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditLoadingTest.php +++ b/core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditLoadingTest.php @@ -138,7 +138,7 @@ public function testUserPermissions() { $nid = $this->testNode->id(); // There should be only one revision so far. $node = Node::load($nid); - $vids = \Drupal::entityManager()->getStorage('node')->revisionIds($node); + $vids = \Drupal::entityTypeManager()->getStorage('node')->revisionIds($node); $this->assertCount(1, $vids, 'The node has only one revision.'); $original_log = $node->revision_log->value; @@ -164,7 +164,7 @@ public function testUserPermissions() { $assert->assertWaitOnAjaxRequest(); $node = Node::load($nid); - $vids = \Drupal::entityManager()->getStorage('node')->revisionIds($node); + $vids = \Drupal::entityTypeManager()->getStorage('node')->revisionIds($node); $this->assertCount(1, $vids, 'The node has only one revision.'); $this->assertSame($original_log, $node->revision_log->value, 'The revision log message is unchanged.'); diff --git a/core/modules/rdf/src/Entity/RdfMapping.php b/core/modules/rdf/src/Entity/RdfMapping.php index a4f268f8120ce1d6802f60af48ef0f41cd770132..e33f24a59a50f8b5c41f4de470c239b1e452953a 100644 --- a/core/modules/rdf/src/Entity/RdfMapping.php +++ b/core/modules/rdf/src/Entity/RdfMapping.php @@ -145,7 +145,7 @@ public function calculateDependencies() { parent::calculateDependencies(); // Create dependency on the bundle. - $entity_type = \Drupal::entityManager()->getDefinition($this->targetEntityType); + $entity_type = \Drupal::entityTypeManager()->getDefinition($this->targetEntityType); $this->addDependency('module', $entity_type->getProvider()); $bundle_config_dependency = $entity_type->getBundleConfigDependency($this->bundle); $this->addDependency($bundle_config_dependency['type'], $bundle_config_dependency['name']); @@ -159,8 +159,8 @@ public function calculateDependencies() { public function postSave(EntityStorageInterface $storage, $update = TRUE) { parent::postSave($storage, $update); - if (\Drupal::entityManager()->hasHandler($this->targetEntityType, 'view_builder')) { - \Drupal::entityManager()->getViewBuilder($this->targetEntityType)->resetCache(); + if (\Drupal::entityTypeManager()->hasHandler($this->targetEntityType, 'view_builder')) { + \Drupal::entityTypeManager()->getViewBuilder($this->targetEntityType)->resetCache(); } } diff --git a/core/modules/search/tests/src/Functional/SearchConfigSettingsFormTest.php b/core/modules/search/tests/src/Functional/SearchConfigSettingsFormTest.php index 8dccf3e26ab473350ec60cd3645c23c36861beb0..40aa3e9994fb297ba0f404ea62c0ea615aaafadc 100644 --- a/core/modules/search/tests/src/Functional/SearchConfigSettingsFormTest.php +++ b/core/modules/search/tests/src/Functional/SearchConfigSettingsFormTest.php @@ -228,7 +228,7 @@ public function testDefaultSearchPageOrdering() { */ public function testMultipleSearchPages() { $this->assertDefaultSearch('node_search', 'The default page is set to the installer default.'); - $search_storage = \Drupal::entityManager()->getStorage('search_page'); + $search_storage = \Drupal::entityTypeManager()->getStorage('search_page'); $entities = $search_storage->loadMultiple(); $search_storage->delete($entities); $this->assertDefaultSearch(FALSE); diff --git a/core/modules/serialization/tests/src/Kernel/EntitySerializationTest.php b/core/modules/serialization/tests/src/Kernel/EntitySerializationTest.php index eff749805a514d8c40c0e9ebe65ed50f14747247..5cd9fa8f7d2af4e58d6e48165ac2e0f3b01aa04a 100644 --- a/core/modules/serialization/tests/src/Kernel/EntitySerializationTest.php +++ b/core/modules/serialization/tests/src/Kernel/EntitySerializationTest.php @@ -88,7 +88,7 @@ protected function setUp() { ])->save(); // Create a test user to use as the entity owner. - $this->user = \Drupal::entityManager()->getStorage('user')->create([ + $this->user = \Drupal::entityTypeManager()->getStorage('user')->create([ 'name' => 'serialization_test_user', 'mail' => 'foo@example.com', 'pass' => '123456', diff --git a/core/modules/shortcut/shortcut.api.php b/core/modules/shortcut/shortcut.api.php index c60e4567310e593e2bd3f9bc5e290b7aa74fa5ff..c5c609c38f54f8221c77e839c92426541eda869a 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 3941eb3621da13ddd4bb68f1389544a1fb7760e2..1b281b2b02b15f2849bea65b64879dd96d86828c 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 819f6475dd533ca67dc7300f85560213c2f32e7f..fba28ac41e1c25f33630a81fcdd5c471602de9fd 100644 --- a/core/modules/shortcut/src/Entity/ShortcutSet.php +++ b/core/modules/shortcut/src/Entity/ShortcutSet.php @@ -100,7 +100,7 @@ public static function preDelete(EntityStorageInterface $storage, array $entitie ->condition('shortcut_set', $entity->id(), '=') ->execute(); - $controller = \Drupal::entityManager()->getStorage('shortcut'); + $controller = \Drupal::entityTypeManager()->getStorage('shortcut'); $entities = $controller->loadMultiple($shortcut_ids); $controller->delete($entities); } @@ -123,7 +123,7 @@ public function resetLinkWeights() { * {@inheritdoc} */ public function getShortcuts() { - $shortcuts = \Drupal::entityManager()->getStorage('shortcut')->loadByProperties(['shortcut_set' => $this->id()]); + $shortcuts = \Drupal::entityTypeManager()->getStorage('shortcut')->loadByProperties(['shortcut_set' => $this->id()]); uasort($shortcuts, ['\Drupal\shortcut\Entity\Shortcut', 'sort']); return $shortcuts; } diff --git a/core/modules/shortcut/src/Tests/ShortcutTestBase.php b/core/modules/shortcut/src/Tests/ShortcutTestBase.php index 584a6154c309210df43ace42bbe65524fa52aa5a..6f89201937e9c9aae580a6ab9f7511e815f09fa9 100644 --- a/core/modules/shortcut/src/Tests/ShortcutTestBase.php +++ b/core/modules/shortcut/src/Tests/ShortcutTestBase.php @@ -94,7 +94,7 @@ protected function setUp() { // Log in as admin and grab the default shortcut set. $this->drupalLogin($this->adminUser); $this->set = ShortcutSet::load('default'); - \Drupal::entityManager()->getStorage('shortcut_set')->assignUser($this->set, $this->adminUser); + \Drupal::entityTypeManager()->getStorage('shortcut_set')->assignUser($this->set, $this->adminUser); } /** @@ -125,7 +125,7 @@ public function generateShortcutSet($label = '', $id = NULL) { */ public function getShortcutInformation(ShortcutSetInterface $set, $key) { $info = []; - \Drupal::entityManager()->getStorage('shortcut')->resetCache(); + \Drupal::entityTypeManager()->getStorage('shortcut')->resetCache(); foreach ($set->getShortcuts() as $shortcut) { if ($key == 'link') { $info[] = $shortcut->link->uri; diff --git a/core/modules/shortcut/tests/src/Functional/ShortcutSetsTest.php b/core/modules/shortcut/tests/src/Functional/ShortcutSetsTest.php index b897df752db892d8d3d269b5ecea24594388b23a..636813cc8f57f973ebc3b510e0ccbb551bd77f17 100644 --- a/core/modules/shortcut/tests/src/Functional/ShortcutSetsTest.php +++ b/core/modules/shortcut/tests/src/Functional/ShortcutSetsTest.php @@ -91,7 +91,7 @@ public function testShortcutSetEdit() { $this->drupalPostForm(NULL, $edit, t('Save')); $this->assertRaw(t('The shortcut set has been updated.')); - \Drupal::entityManager()->getStorage('shortcut')->resetCache(); + \Drupal::entityTypeManager()->getStorage('shortcut')->resetCache(); // Check to ensure that the shortcut weights have changed and that // ShortcutSet::.getShortcuts() returns shortcuts in the new order. $this->assertIdentical(array_reverse(array_keys($shortcuts)), array_keys($set->getShortcuts())); @@ -117,7 +117,7 @@ public function testShortcutSetSwitchOwn() { public function testShortcutSetAssign() { $new_set = $this->generateShortcutSet($this->randomMachineName()); - \Drupal::entityManager()->getStorage('shortcut_set')->assignUser($new_set, $this->shortcutUser); + \Drupal::entityTypeManager()->getStorage('shortcut_set')->assignUser($new_set, $this->shortcutUser); $current_set = shortcut_current_displayed_set($this->shortcutUser); $this->assertTrue($new_set->id() == $current_set->id(), "Successfully switched another user's shortcut set."); } @@ -169,7 +169,7 @@ public function testShortcutSetRename() { public function testShortcutSetUnassign() { $new_set = $this->generateShortcutSet($this->randomMachineName()); - $shortcut_set_storage = \Drupal::entityManager()->getStorage('shortcut_set'); + $shortcut_set_storage = \Drupal::entityTypeManager()->getStorage('shortcut_set'); $shortcut_set_storage->assignUser($new_set, $this->shortcutUser); $shortcut_set_storage->unassignUser($this->shortcutUser); $current_set = shortcut_current_displayed_set($this->shortcutUser); diff --git a/core/modules/shortcut/tests/src/Functional/ShortcutTestBase.php b/core/modules/shortcut/tests/src/Functional/ShortcutTestBase.php index 3f9cc87be3840659957157088f43828cd53ee364..c11c418ae9a33d19737bdc898ac2335b1583f545 100644 --- a/core/modules/shortcut/tests/src/Functional/ShortcutTestBase.php +++ b/core/modules/shortcut/tests/src/Functional/ShortcutTestBase.php @@ -87,7 +87,7 @@ protected function setUp() { // Log in as admin and grab the default shortcut set. $this->drupalLogin($this->adminUser); $this->set = ShortcutSet::load('default'); - \Drupal::entityManager()->getStorage('shortcut_set')->assignUser($this->set, $this->adminUser); + \Drupal::entityTypeManager()->getStorage('shortcut_set')->assignUser($this->set, $this->adminUser); } /** @@ -118,7 +118,7 @@ public function generateShortcutSet($label = '', $id = NULL) { */ public function getShortcutInformation(ShortcutSetInterface $set, $key) { $info = []; - \Drupal::entityManager()->getStorage('shortcut')->resetCache(); + \Drupal::entityTypeManager()->getStorage('shortcut')->resetCache(); foreach ($set->getShortcuts() as $shortcut) { if ($key == 'link') { $info[] = $shortcut->link->uri; diff --git a/core/modules/simpletest/src/Tests/KernelTestBaseTest.php b/core/modules/simpletest/src/Tests/KernelTestBaseTest.php index c92381fab8dc1a5aab279616272fb8db0acb848f..d34ff91e6e16e9c51c2404fe76ed5b81790c3599 100644 --- a/core/modules/simpletest/src/Tests/KernelTestBaseTest.php +++ b/core/modules/simpletest/src/Tests/KernelTestBaseTest.php @@ -240,7 +240,7 @@ public function testInstallConfig() { public function testEnableModulesFixedList() { // Install system module. $this->container->get('module_installer')->install(['system', 'user', 'menu_link_content']); - $entity_manager = \Drupal::entityManager(); + $entity_manager = \Drupal::entityTypeManager(); // entity_test is loaded via $modules; its entity type should exist. $this->assertEqual($this->container->get('module_handler')->moduleExists('entity_test'), TRUE); diff --git a/core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php b/core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php index 6b3e3c4ab1253c54747c207f710d53a2958498d8..2aa64e86940ba1ae87a3d33572336839fa2aabc9 100644 --- a/core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php +++ b/core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php @@ -210,7 +210,7 @@ protected function getAdditionalCacheTagsForEntityListing() { * chooses 'default'. */ protected function selectViewMode($entity_type) { - $view_modes = \Drupal::entityManager() + $view_modes = \Drupal::entityTypeManager() ->getStorage('entity_view_mode') ->loadByProperties(['targetEntityType' => $entity_type]); @@ -295,7 +295,7 @@ protected function createReferenceTestEntities($referenced_entity) { } // Create an entity that does reference the entity being tested. - $label_key = \Drupal::entityManager()->getDefinition($entity_type)->getKey('label'); + $label_key = \Drupal::entityTypeManager()->getDefinition($entity_type)->getKey('label'); $referencing_entity = $this->container->get('entity_type.manager') ->getStorage($entity_type) ->create([ @@ -362,7 +362,7 @@ public function testReferencedEntity() { $view_cache_tag = []; if ($this->entity->getEntityType()->hasHandlerClass('view_builder')) { - $view_cache_tag = \Drupal::entityManager()->getViewBuilder($entity_type) + $view_cache_tag = \Drupal::entityTypeManager()->getViewBuilder($entity_type) ->getCacheTags(); } @@ -370,7 +370,7 @@ public function testReferencedEntity() { $cache_context_tags = $context_metadata->getCacheTags(); // Generate the cache tags for the (non) referencing entities. - $referencing_entity_cache_tags = Cache::mergeTags($this->referencingEntity->getCacheTags(), \Drupal::entityManager()->getViewBuilder('entity_test')->getCacheTags()); + $referencing_entity_cache_tags = Cache::mergeTags($this->referencingEntity->getCacheTags(), \Drupal::entityTypeManager()->getViewBuilder('entity_test')->getCacheTags()); // Includes the main entity's cache tags, since this entity references it. $referencing_entity_cache_tags = Cache::mergeTags($referencing_entity_cache_tags, $this->entity->getCacheTags()); $referencing_entity_cache_tags = Cache::mergeTags($referencing_entity_cache_tags, $this->getAdditionalCacheTagsForEntity($this->entity)); @@ -378,7 +378,7 @@ public function testReferencedEntity() { $referencing_entity_cache_tags = Cache::mergeTags($referencing_entity_cache_tags, $cache_context_tags); $referencing_entity_cache_tags = Cache::mergeTags($referencing_entity_cache_tags, ['rendered']); - $non_referencing_entity_cache_tags = Cache::mergeTags($this->nonReferencingEntity->getCacheTags(), \Drupal::entityManager()->getViewBuilder('entity_test')->getCacheTags()); + $non_referencing_entity_cache_tags = Cache::mergeTags($this->nonReferencingEntity->getCacheTags(), \Drupal::entityTypeManager()->getViewBuilder('entity_test')->getCacheTags()); $non_referencing_entity_cache_tags = Cache::mergeTags($non_referencing_entity_cache_tags, ['rendered']); // Generate the cache tags for all two possible entity listing paths. @@ -640,7 +640,7 @@ public function testReferencedEntity() { $this->verifyPageCache($non_referencing_entity_url, 'HIT'); // Verify cache hits. - $referencing_entity_cache_tags = Cache::mergeTags($this->referencingEntity->getCacheTags(), \Drupal::entityManager()->getViewBuilder('entity_test')->getCacheTags()); + $referencing_entity_cache_tags = Cache::mergeTags($this->referencingEntity->getCacheTags(), \Drupal::entityTypeManager()->getViewBuilder('entity_test')->getCacheTags()); $referencing_entity_cache_tags = Cache::mergeTags($referencing_entity_cache_tags, ['http_response', 'rendered']); $nonempty_entity_listing_cache_tags = Cache::mergeTags($this->entity->getEntityType()->getListCacheTags(), $this->getAdditionalCacheTagsForEntityListing()); diff --git a/core/modules/system/src/Tests/Entity/EntityWithUriCacheTagsTestBase.php b/core/modules/system/src/Tests/Entity/EntityWithUriCacheTagsTestBase.php index a3006b498b4f5bc39aa23bebad84598ec3cbeace..1e2fb6145dbaeac66f0ff4783bbb4e0bffb81665 100644 --- a/core/modules/system/src/Tests/Entity/EntityWithUriCacheTagsTestBase.php +++ b/core/modules/system/src/Tests/Entity/EntityWithUriCacheTagsTestBase.php @@ -38,7 +38,7 @@ public function testEntityUri() { // Generate the standardized entity cache tags. $cache_tag = $this->entity->getCacheTags(); - $view_cache_tag = \Drupal::entityManager()->getViewBuilder($entity_type)->getCacheTags(); + $view_cache_tag = \Drupal::entityTypeManager()->getViewBuilder($entity_type)->getCacheTags(); $render_cache_tag = 'rendered'; $this->pass("Test entity.", 'Debug'); @@ -49,7 +49,7 @@ public function testEntityUri() { // Also verify the existence of an entity render cache entry, if this entity // type supports render caching. - if (\Drupal::entityManager()->getDefinition($entity_type)->isRenderCacheable()) { + if (\Drupal::entityTypeManager()->getDefinition($entity_type)->isRenderCacheable()) { $cache_keys = ['entity_view', $entity_type, $this->entity->id(), $view_mode]; $cid = $this->createCacheId($cache_keys, $entity_cache_contexts); $redirected_cid = NULL; diff --git a/core/modules/system/system.install b/core/modules/system/system.install index ceff294c9cebed22ad2960787ba68e8e08dde3a6..b7f99d9bf983b41b2522950b4dd05afc39983723 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 0ee7e35b871be31391346f84ae7eb5281b1b93a1..9a080bfa3b6c3602c93914f4dfe7ce4b6c579944 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 488fa6ef42ebcbbf538f1285c3840e07223ab064..6843e54f753711cd7bb9e7c3237f379dd55e642e 100644 --- a/core/modules/system/tests/src/Functional/Datetime/DrupalDateTimeTest.php +++ b/core/modules/system/tests/src/Functional/Datetime/DrupalDateTimeTest.php @@ -88,7 +88,7 @@ public function testDateTimezone() { $this->drupalPostForm('user/' . $test_user->id() . '/edit', $edit, t('Save')); // Reload the user and reset the timezone in AccountProxy::setAccount(). - \Drupal::entityManager()->getStorage('user')->resetCache(); + \Drupal::entityTypeManager()->getStorage('user')->resetCache(); $this->container->get('current_user')->setAccount(User::load($test_user->id())); // Create a date object with an unspecified timezone, which should diff --git a/core/modules/system/tests/src/Functional/Entity/EntityCacheTagsTestBase.php b/core/modules/system/tests/src/Functional/Entity/EntityCacheTagsTestBase.php index 453af58fd598c76df67895f80ef2e0a8f1923954..e92b64700167c2a33420a11a73e9a3cda3ca5bcc 100644 --- a/core/modules/system/tests/src/Functional/Entity/EntityCacheTagsTestBase.php +++ b/core/modules/system/tests/src/Functional/Entity/EntityCacheTagsTestBase.php @@ -203,7 +203,7 @@ protected function getAdditionalCacheTagsForEntityListing() { * chooses 'default'. */ protected function selectViewMode($entity_type) { - $view_modes = \Drupal::entityManager() + $view_modes = \Drupal::entityTypeManager() ->getStorage('entity_view_mode') ->loadByProperties(['targetEntityType' => $entity_type]); @@ -287,7 +287,7 @@ protected function createReferenceTestEntities($referenced_entity) { } // Create an entity that does reference the entity being tested. - $label_key = \Drupal::entityManager()->getDefinition($entity_type)->getKey('label'); + $label_key = \Drupal::entityTypeManager()->getDefinition($entity_type)->getKey('label'); $referencing_entity = $this->container->get('entity_type.manager') ->getStorage($entity_type) ->create([ @@ -354,7 +354,7 @@ public function testReferencedEntity() { $view_cache_tag = []; if ($this->entity->getEntityType()->hasHandlerClass('view_builder')) { - $view_cache_tag = \Drupal::entityManager()->getViewBuilder($entity_type) + $view_cache_tag = \Drupal::entityTypeManager()->getViewBuilder($entity_type) ->getCacheTags(); } @@ -362,7 +362,7 @@ public function testReferencedEntity() { $cache_context_tags = $context_metadata->getCacheTags(); // Generate the cache tags for the (non) referencing entities. - $referencing_entity_cache_tags = Cache::mergeTags($this->referencingEntity->getCacheTags(), \Drupal::entityManager()->getViewBuilder('entity_test')->getCacheTags()); + $referencing_entity_cache_tags = Cache::mergeTags($this->referencingEntity->getCacheTags(), \Drupal::entityTypeManager()->getViewBuilder('entity_test')->getCacheTags()); // Includes the main entity's cache tags, since this entity references it. $referencing_entity_cache_tags = Cache::mergeTags($referencing_entity_cache_tags, $this->entity->getCacheTags()); $referencing_entity_cache_tags = Cache::mergeTags($referencing_entity_cache_tags, $this->getAdditionalCacheTagsForEntity($this->entity)); @@ -370,7 +370,7 @@ public function testReferencedEntity() { $referencing_entity_cache_tags = Cache::mergeTags($referencing_entity_cache_tags, $cache_context_tags); $referencing_entity_cache_tags = Cache::mergeTags($referencing_entity_cache_tags, ['rendered']); - $non_referencing_entity_cache_tags = Cache::mergeTags($this->nonReferencingEntity->getCacheTags(), \Drupal::entityManager()->getViewBuilder('entity_test')->getCacheTags()); + $non_referencing_entity_cache_tags = Cache::mergeTags($this->nonReferencingEntity->getCacheTags(), \Drupal::entityTypeManager()->getViewBuilder('entity_test')->getCacheTags()); $non_referencing_entity_cache_tags = Cache::mergeTags($non_referencing_entity_cache_tags, ['rendered']); // Generate the cache tags for all two possible entity listing paths. @@ -633,7 +633,7 @@ public function testReferencedEntity() { $this->verifyPageCache($non_referencing_entity_url, 'HIT'); // Verify cache hits. - $referencing_entity_cache_tags = Cache::mergeTags($this->referencingEntity->getCacheTags(), \Drupal::entityManager()->getViewBuilder('entity_test')->getCacheTags()); + $referencing_entity_cache_tags = Cache::mergeTags($this->referencingEntity->getCacheTags(), \Drupal::entityTypeManager()->getViewBuilder('entity_test')->getCacheTags()); $referencing_entity_cache_tags = Cache::mergeTags($referencing_entity_cache_tags, ['http_response', 'rendered']); $nonempty_entity_listing_cache_tags = Cache::mergeTags($this->entity->getEntityType()->getListCacheTags(), $this->getAdditionalCacheTagsForEntityListing()); diff --git a/core/modules/system/tests/src/Functional/Entity/EntityWithUriCacheTagsTestBase.php b/core/modules/system/tests/src/Functional/Entity/EntityWithUriCacheTagsTestBase.php index a102e6f7940a63467136d62b185cb7d07d866a54..e62d343ced936858fd22fe2084966cc99f817cff 100644 --- a/core/modules/system/tests/src/Functional/Entity/EntityWithUriCacheTagsTestBase.php +++ b/core/modules/system/tests/src/Functional/Entity/EntityWithUriCacheTagsTestBase.php @@ -31,7 +31,7 @@ public function testEntityUri() { // Generate the standardized entity cache tags. $cache_tag = $this->entity->getCacheTags(); - $view_cache_tag = \Drupal::entityManager()->getViewBuilder($entity_type)->getCacheTags(); + $view_cache_tag = \Drupal::entityTypeManager()->getViewBuilder($entity_type)->getCacheTags(); $render_cache_tag = 'rendered'; $this->pass("Test entity.", 'Debug'); @@ -42,7 +42,7 @@ public function testEntityUri() { // Also verify the existence of an entity render cache entry, if this entity // type supports render caching. - if (\Drupal::entityManager()->getDefinition($entity_type)->isRenderCacheable()) { + if (\Drupal::entityTypeManager()->getDefinition($entity_type)->isRenderCacheable()) { $cache_keys = ['entity_view', $entity_type, $this->entity->id(), $view_mode]; $cid = $this->createCacheId($cache_keys, $entity_cache_contexts); $redirected_cid = NULL; diff --git a/core/modules/system/tests/src/Functional/Entity/Update/SqlContentEntityStorageSchemaConverterTestBase.php b/core/modules/system/tests/src/Functional/Entity/Update/SqlContentEntityStorageSchemaConverterTestBase.php index 05876bff62f0b5646ec36fcd38de89300d659a41..33f2ca5cd18765b576005d9111dc92ab1443d275 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 1a49336777ed8f82939303781a21b86d5404d2a2..fc6e8c1ac09d4072591c48e8dbb9f808b35463e4 100644 --- a/core/modules/system/tests/src/Functional/Menu/LocalTasksTest.php +++ b/core/modules/system/tests/src/Functional/Menu/LocalTasksTest.php @@ -176,7 +176,7 @@ public function testPluginLocalTask() { // Test that we we correctly apply the active class to tabs where one of the // request attributes is upcast to an entity object. - $entity = \Drupal::entityManager()->getStorage('entity_test')->create(['bundle' => 'test']); + $entity = \Drupal::entityTypeManager()->getStorage('entity_test')->create(['bundle' => 'test']); $entity->save(); $this->drupalGet(Url::fromRoute('menu_test.local_task_test_upcasting_sub1', ['entity_test' => '1'])); diff --git a/core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php b/core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php index d1f6be457f0dc98a9a56a767ceac5aef390893b8..bcdf8ea33df97d58b8797a81b2d8b796248d1a44 100644 --- a/core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php +++ b/core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php @@ -352,7 +352,7 @@ protected function preUninstallForum() { $query = \Drupal::entityQuery('taxonomy_term'); $query->condition('vid', 'forums'); $ids = $query->execute(); - $storage = \Drupal::entityManager()->getStorage('taxonomy_term'); + $storage = \Drupal::entityTypeManager()->getStorage('taxonomy_term'); $terms = $storage->loadMultiple($ids); $storage->delete($terms); } diff --git a/core/modules/system/tests/src/Functional/Module/UninstallTest.php b/core/modules/system/tests/src/Functional/Module/UninstallTest.php index 98b96ee91ef1421deffc542364de7ae5c3cb457b..d061646f7e9a91c5e592a68dbb97d926bb7b043f 100644 --- a/core/modules/system/tests/src/Functional/Module/UninstallTest.php +++ b/core/modules/system/tests/src/Functional/Module/UninstallTest.php @@ -104,7 +104,7 @@ public function testUninstallPage() { } $entity_types = array_unique($entity_types); foreach ($entity_types as $entity_type_id) { - $entity_type = \Drupal::entityManager()->getDefinition($entity_type_id); + $entity_type = \Drupal::entityTypeManager()->getDefinition($entity_type_id); // Add h3's since the entity type label is often repeated in the entity // labels. $this->assertRaw('<h3>' . $entity_type->getLabel() . '</h3>'); diff --git a/core/modules/system/tests/src/Functional/System/DateTimeTest.php b/core/modules/system/tests/src/Functional/System/DateTimeTest.php index 15f3608885bb50cc6282b905ecf0a341f084ec36..0a365a7a7dab75195c5bb34018b0f347c552473b 100644 --- a/core/modules/system/tests/src/Functional/System/DateTimeTest.php +++ b/core/modules/system/tests/src/Functional/System/DateTimeTest.php @@ -64,7 +64,7 @@ public function testTimeZoneHandling() { // Set time zone to Los Angeles time. $config->set('timezone.default', 'America/Los_Angeles')->save(); - \Drupal::entityManager()->getViewBuilder('node')->resetCache([$node1, $node2]); + \Drupal::entityTypeManager()->getViewBuilder('node')->resetCache([$node1, $node2]); // Confirm date format and time zone. $this->drupalGet('node/' . $node1->id()); diff --git a/core/modules/system/tests/src/Functional/Update/LocalActionsAndTasksConvertedIntoBlocksUpdateTest.php b/core/modules/system/tests/src/Functional/Update/LocalActionsAndTasksConvertedIntoBlocksUpdateTest.php index cfa8221040849ff31970d66cddb69bdd93ba6ebf..ff4075e9e6939bf2745c96311840f95c7ff56557 100644 --- a/core/modules/system/tests/src/Functional/Update/LocalActionsAndTasksConvertedIntoBlocksUpdateTest.php +++ b/core/modules/system/tests/src/Functional/Update/LocalActionsAndTasksConvertedIntoBlocksUpdateTest.php @@ -42,7 +42,7 @@ public function testUpdateHookN() { $this->runUpdates(); /** @var \Drupal\block\BlockInterface $block_storage */ - $block_storage = \Drupal::entityManager()->getStorage('block'); + $block_storage = \Drupal::entityTypeManager()->getStorage('block'); /* @var \Drupal\block\BlockInterface[] $help_blocks */ $help_blocks = $block_storage->loadByProperties(['theme' => 'bartik', 'region' => 'help']); diff --git a/core/modules/system/tests/src/Functional/Update/PageTitleConvertedIntoBlockUpdateTest.php b/core/modules/system/tests/src/Functional/Update/PageTitleConvertedIntoBlockUpdateTest.php index c9c264c96b5c9ef0cf64a8e21fc4639d447dca05..6e17506220d06d99177ce9d52f515abfa2b7589e 100644 --- a/core/modules/system/tests/src/Functional/Update/PageTitleConvertedIntoBlockUpdateTest.php +++ b/core/modules/system/tests/src/Functional/Update/PageTitleConvertedIntoBlockUpdateTest.php @@ -43,7 +43,7 @@ public function testUpdateHookN() { $this->runUpdates(); /** @var \Drupal\block\BlockInterface $block_storage */ - $block_storage = \Drupal::entityManager()->getStorage('block'); + $block_storage = \Drupal::entityTypeManager()->getStorage('block'); $this->assertRaw('Because your site has custom theme(s) installed, we have placed the page title block in the content region. Please manually review the block configuration and remove the page title variables from your page templates.'); diff --git a/core/modules/system/tests/src/Functional/Update/SevenSecondaryLocalTasksConvertedIntoBlockUpdateTest.php b/core/modules/system/tests/src/Functional/Update/SevenSecondaryLocalTasksConvertedIntoBlockUpdateTest.php index 172897497d3f7066a0c4de5c2886ab1a5204e2bd..b0a58623a5461a1baa2c0c48205a2027807a7874 100644 --- a/core/modules/system/tests/src/Functional/Update/SevenSecondaryLocalTasksConvertedIntoBlockUpdateTest.php +++ b/core/modules/system/tests/src/Functional/Update/SevenSecondaryLocalTasksConvertedIntoBlockUpdateTest.php @@ -41,7 +41,7 @@ public function testUpdateHookN() { $this->runUpdates(); /** @var \Drupal\block\BlockInterface $block_storage */ - $block_storage = \Drupal::entityManager()->getStorage('block'); + $block_storage = \Drupal::entityTypeManager()->getStorage('block'); // Disable maintenance mode. // @todo Can be removed once maintenance mode is automatically turned off diff --git a/core/modules/system/tests/src/Functional/Update/SiteBrandingConvertedIntoBlockUpdateTest.php b/core/modules/system/tests/src/Functional/Update/SiteBrandingConvertedIntoBlockUpdateTest.php index 72f3a2782469d91c0e5c0ea6a20eca6d1cd8bbd8..56b988e956d218de2ca207c1e428248c3b03ba4a 100644 --- a/core/modules/system/tests/src/Functional/Update/SiteBrandingConvertedIntoBlockUpdateTest.php +++ b/core/modules/system/tests/src/Functional/Update/SiteBrandingConvertedIntoBlockUpdateTest.php @@ -39,7 +39,7 @@ public function testUpdateHookN() { $this->runUpdates(); /** @var \Drupal\block\BlockInterface $block_storage */ - $block_storage = \Drupal::entityManager()->getStorage('block'); + $block_storage = \Drupal::entityTypeManager()->getStorage('block'); $this->assertRaw('Because your site has custom theme(s) installed, we had to set the branding block into the content region. Please manually review the block configuration and remove the site name, slogan, and logo variables from your templates.'); diff --git a/core/modules/system/tests/src/Functional/Update/UpdatePathRC1TestBaseTest.php b/core/modules/system/tests/src/Functional/Update/UpdatePathRC1TestBaseTest.php index da53ba6e63082c8531c62b59ae869feb84de7561..af2552492aa4913d8b9beb5174b4942af434e626 100644 --- a/core/modules/system/tests/src/Functional/Update/UpdatePathRC1TestBaseTest.php +++ b/core/modules/system/tests/src/Functional/Update/UpdatePathRC1TestBaseTest.php @@ -62,7 +62,7 @@ public function testDatabaseLoaded() { $this->assertText('Site-Install'); $extensions = \Drupal::service('config.storage')->read('core.extension'); $this->assertTrue(isset($extensions['theme']['stable']), 'Stable is installed after updating.'); - $blocks = \Drupal::entityManager()->getStorage('block')->loadByProperties(['theme' => 'stable']); + $blocks = \Drupal::entityTypeManager()->getStorage('block')->loadByProperties(['theme' => 'stable']); $this->assertTrue(empty($blocks), 'No blocks have been placed for Stable.'); } diff --git a/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php b/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php index 976032e050698afc9b76f931b1b2eec24ead228d..63229a9139800daa1d3001d7cfb4b3d16d47b7b8 100644 --- a/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php +++ b/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php @@ -269,7 +269,7 @@ public function testUninstallContentDependency() { $this->assertTrue($this->moduleHandler()->moduleExists('module_test'), 'Test module is enabled.'); $this->installSchema('user', 'users_data'); - $entity_types = \Drupal::entityManager()->getDefinitions(); + $entity_types = \Drupal::entityTypeManager()->getDefinitions(); foreach ($entity_types as $entity_type) { if ('entity_test' == $entity_type->getProvider()) { $this->installEntitySchema($entity_type->id()); diff --git a/core/modules/taxonomy/src/Plugin/views/field/TaxonomyIndexTid.php b/core/modules/taxonomy/src/Plugin/views/field/TaxonomyIndexTid.php index 785629e1fe5a13feece5954d42f11ba90d33495c..7dda500d7c9ccc9c2f3af745021b82c7703d88b9 100644 --- a/core/modules/taxonomy/src/Plugin/views/field/TaxonomyIndexTid.php +++ b/core/modules/taxonomy/src/Plugin/views/field/TaxonomyIndexTid.php @@ -139,7 +139,7 @@ public function preRender(&$values) { if (empty($this->options['limit'])) { $vocabs = []; } - $result = \Drupal::entityManager()->getStorage('taxonomy_term')->getNodeTerms($nids, $vocabs); + $result = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->getNodeTerms($nids, $vocabs); foreach ($result as $node_nid => $data) { foreach ($data as $tid => $term) { diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module index 4ba6d195ad7816e6124afba7d85de87dd64ad863..160bcbe635c4ccafa29761440de1b56fc472dea9 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 b6931b7cbb08097e57c911eab489bc2ad85a07a7..39d7da5e14c80d46e1b69336028ee36fbccdf9a8 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 0e2c5aa399327105be868c1f4574657c7848990d..ab708d40481e3f5cae4636d61e3c3f7a03fe4a98 100644 --- a/core/modules/taxonomy/tests/src/Functional/TaxonomyQueryAlterTest.php +++ b/core/modules/taxonomy/tests/src/Functional/TaxonomyQueryAlterTest.php @@ -37,7 +37,7 @@ public function testTaxonomyQueryAlter() { $terms[2]->parent = $terms[1]->id(); $terms[2]->save(); - $term_storage = \Drupal::entityManager()->getStorage('taxonomy_term'); + $term_storage = \Drupal::entityTypeManager()->getStorage('taxonomy_term'); $this->setupQueryTagTestHooks(); $loaded_term = $term_storage->load($terms[0]->id()); diff --git a/core/modules/taxonomy/tests/src/Functional/TaxonomyTermIndentationTest.php b/core/modules/taxonomy/tests/src/Functional/TaxonomyTermIndentationTest.php index c701dfeebaf5e36b5c143783e313c8dbafa991e1..eb57142c87e2b8b14c3aed00dc753cf0f551c403 100644 --- a/core/modules/taxonomy/tests/src/Functional/TaxonomyTermIndentationTest.php +++ b/core/modules/taxonomy/tests/src/Functional/TaxonomyTermIndentationTest.php @@ -87,7 +87,7 @@ public function testTermIndentation() { $this->assertSession()->responseNotMatches('|<div class="js-indentation indentation"> </div>|'); // 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 20ecb6390346241c7f29b610c7b5e4aaf8d8f840..6eb3ed1ea45468505d5d22e811cb89967c5e6425 100644 --- a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTaxonomyTermTest.php +++ b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTaxonomyTermTest.php @@ -96,7 +96,7 @@ public function testTaxonomyTerms() { } else { $parents = []; - foreach (\Drupal::entityManager()->getStorage('taxonomy_term')->loadParents($tid) as $parent) { + foreach (\Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadParents($tid) as $parent) { $parents[] = (int) $parent->id(); } $this->assertSame($parents, $values['parent']); diff --git a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTermNodeRevisionTest.php b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTermNodeRevisionTest.php index 25544486ab2862e5f72f49f030b2928c6084ba33..3fd755440aa148548fee25617633876d0b20a71d 100644 --- a/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTermNodeRevisionTest.php +++ b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTermNodeRevisionTest.php @@ -31,7 +31,7 @@ protected function setUp() { * Tests the Drupal 6 term-node revision association to Drupal 8 migration. */ public function testTermRevisionNode() { - $node = \Drupal::entityManager()->getStorage('node')->loadRevision(2001); + $node = \Drupal::entityTypeManager()->getStorage('node')->loadRevision(2001); $this->assertSame(2, count($node->field_vocabulary_3_i_2_)); $this->assertSame('4', $node->field_vocabulary_3_i_2_[0]->target_id); $this->assertSame('5', $node->field_vocabulary_3_i_2_[1]->target_id); diff --git a/core/modules/taxonomy/tests/src/Kernel/Migrate/d7/MigrateTaxonomyTermTest.php b/core/modules/taxonomy/tests/src/Kernel/Migrate/d7/MigrateTaxonomyTermTest.php index d735232a6780395ead1b1c0cfd25406926c4ba25..b8b0169bbd0d085f16a8a227b19ccd7fc3379294 100644 --- a/core/modules/taxonomy/tests/src/Kernel/Migrate/d7/MigrateTaxonomyTermTest.php +++ b/core/modules/taxonomy/tests/src/Kernel/Migrate/d7/MigrateTaxonomyTermTest.php @@ -138,7 +138,7 @@ public function testTaxonomyTerms() { * List of parent term IDs. */ protected function getParentIDs($tid) { - return array_keys(\Drupal::entityManager()->getStorage('taxonomy_term')->loadParents($tid)); + return array_keys(\Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadParents($tid)); } /** diff --git a/core/modules/taxonomy/tests/src/Kernel/TermKernelTest.php b/core/modules/taxonomy/tests/src/Kernel/TermKernelTest.php index 4e1eaafa1e5b1ab485922784af7bac660da45c22..c2d9d667c976fb8d673eea849e0c1852b26216dc 100644 --- a/core/modules/taxonomy/tests/src/Kernel/TermKernelTest.php +++ b/core/modules/taxonomy/tests/src/Kernel/TermKernelTest.php @@ -127,7 +127,7 @@ public function testTaxonomyVocabularyTree() { $this->assertEqual(1, $depth_count[3], 'One element in taxonomy tree depth 3.'); /** @var \Drupal\taxonomy\TermStorageInterface $storage */ - $storage = \Drupal::entityManager()->getStorage('taxonomy_term'); + $storage = \Drupal::entityTypeManager()->getStorage('taxonomy_term'); // Count parents of $term[2]. $parents = $storage->loadParents($term[2]->id()); $this->assertEqual(2, count($parents), 'The term has two parents.'); diff --git a/core/modules/tracker/tracker.pages.inc b/core/modules/tracker/tracker.pages.inc index 507f14b64efd2269561cf61222a83a3fb459bcd2..575c31bae069eb899f25e1903dcde7bbdab1e0a4 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 ebb11341282f7f1731a5ecce07f274122a1691bb..8ed8dfdac8c0d58dc7e51d0779cd80d01fe1e435 100644 --- a/core/modules/user/src/Entity/User.php +++ b/core/modules/user/src/Entity/User.php @@ -420,8 +420,8 @@ public static function getAnonymousUser() { // @todo Use the entity factory once available, see // https://www.drupal.org/node/1867228. - $entity_manager = \Drupal::entityManager(); - $entity_type = $entity_manager->getDefinition('user'); + $entity_type_manager = \Drupal::entityTypeManager(); + $entity_type = $entity_type_manager->getDefinition('user'); $class = $entity_type->getClass(); static::$anonymousUser = new $class([ @@ -557,7 +557,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { * The role storage object. */ protected function getRoleStorage() { - return \Drupal::entityManager()->getStorage('user_role'); + return \Drupal::entityTypeManager()->getStorage('user_role'); } /** diff --git a/core/modules/user/tests/src/Functional/UserCancelTest.php b/core/modules/user/tests/src/Functional/UserCancelTest.php index 968330c2a5e8ea8e5d3872ba50939101a71c5a00..631b35183a7b95e1b96cd84e0897c42d8c276d54 100644 --- a/core/modules/user/tests/src/Functional/UserCancelTest.php +++ b/core/modules/user/tests/src/Functional/UserCancelTest.php @@ -268,7 +268,7 @@ public function testUserBlockUnpublish() { $test_node = node_revision_load($node->getRevisionId()); $this->assertFalse($test_node->isPublished(), 'Node revision of the user has been unpublished.'); - $storage = \Drupal::entityManager()->getStorage('comment'); + $storage = \Drupal::entityTypeManager()->getStorage('comment'); $storage->resetCache([$comment->id()]); $comment = $storage->load($comment->id()); $this->assertFalse($comment->isPublished(), 'Comment of the user has been unpublished.'); @@ -345,7 +345,7 @@ public function testUserAnonymize() { $test_node = $node_storage->load($revision_node->id()); $this->assertTrue(($test_node->getOwnerId() != 0 && $test_node->isPublished()), "Current revision of the user's node was not attributed to anonymous user."); - $storage = \Drupal::entityManager()->getStorage('comment'); + $storage = \Drupal::entityTypeManager()->getStorage('comment'); $storage->resetCache([$comment->id()]); $test_comment = $storage->load($comment->id()); $this->assertTrue(($test_comment->getOwnerId() == 0 && $test_comment->isPublished()), 'Comment of the user has been attributed to anonymous user.'); @@ -467,7 +467,7 @@ public function testUserDelete() { $this->assertFalse(node_revision_load($revision), 'Node revision of the user has been deleted.'); $node_storage->resetCache([$revision_node->id()]); $this->assertTrue($node_storage->load($revision_node->id()), "Current revision of the user's node was not deleted."); - \Drupal::entityManager()->getStorage('comment')->resetCache([$comment->id()]); + \Drupal::entityTypeManager()->getStorage('comment')->resetCache([$comment->id()]); $this->assertFalse(Comment::load($comment->id()), 'Comment of the user has been deleted.'); // Confirm that the confirmation message made it through to the end user. diff --git a/core/modules/user/tests/src/Functional/UserPasswordResetTest.php b/core/modules/user/tests/src/Functional/UserPasswordResetTest.php index 9a660ef3eff373094fcc11caefe4e01e57081f98..866b2d324287db619b85947351ea98e8239a5f07 100644 --- a/core/modules/user/tests/src/Functional/UserPasswordResetTest.php +++ b/core/modules/user/tests/src/Functional/UserPasswordResetTest.php @@ -307,7 +307,7 @@ public function testResetImpersonation() { ->fields(['pass' => NULL]) ->condition('uid', [$user1->id(), $user2->id()], 'IN') ->execute(); - \Drupal::entityManager()->getStorage('user')->resetCache(); + \Drupal::entityTypeManager()->getStorage('user')->resetCache(); $user1 = User::load($user1->id()); $user2 = User::load($user2->id()); diff --git a/core/modules/user/tests/src/Functional/UserPermissionsTest.php b/core/modules/user/tests/src/Functional/UserPermissionsTest.php index baa848ae143eb13c785f3e342307cccd0d78fad4..30ff65648e8ce5b2afb1a036eafb6af11ea6a6f8 100644 --- a/core/modules/user/tests/src/Functional/UserPermissionsTest.php +++ b/core/modules/user/tests/src/Functional/UserPermissionsTest.php @@ -107,7 +107,7 @@ public function testAdministratorRole() { $edit['user_admin_role'] = $this->rid; $this->drupalPostForm('admin/config/people/accounts', $edit, t('Save configuration')); - \Drupal::entityManager()->getStorage('user_role')->resetCache(); + \Drupal::entityTypeManager()->getStorage('user_role')->resetCache(); $this->assertTrue(Role::load($this->rid)->isAdmin()); // Enable aggregator module and ensure the 'administer news feeds' @@ -121,7 +121,7 @@ public function testAdministratorRole() { $edit['user_admin_role'] = ''; $this->drupalPostForm('admin/config/people/accounts', $edit, t('Save configuration')); - \Drupal::entityManager()->getStorage('user_role')->resetCache(); + \Drupal::entityTypeManager()->getStorage('user_role')->resetCache(); \Drupal::configFactory()->reset(); $this->assertFalse(Role::load($this->rid)->isAdmin()); diff --git a/core/modules/user/tests/src/Functional/UserRegistrationTest.php b/core/modules/user/tests/src/Functional/UserRegistrationTest.php index c9a68328add8b5e4484b5d7fbaa101006c2434cf..ce1568d83873d9a371556601c4f8a835ea1473e4 100644 --- a/core/modules/user/tests/src/Functional/UserRegistrationTest.php +++ b/core/modules/user/tests/src/Functional/UserRegistrationTest.php @@ -208,7 +208,7 @@ public function testUuidFormState() { $this->drupalPostForm('user/register', $edit, t('Create new account')); $this->assertResponse(200); - $user_storage = \Drupal::entityManager()->getStorage('user'); + $user_storage = \Drupal::entityTypeManager()->getStorage('user'); $this->assertTrue($user_storage->loadByProperties(['name' => $edit['name']])); $this->drupalLogout(); diff --git a/core/modules/user/tests/src/Functional/UserRoleAdminTest.php b/core/modules/user/tests/src/Functional/UserRoleAdminTest.php index 739da5484034f52e9cef6c1285406e3eb167fca4..c7e52135d695538f8a892c5f50b6897fe1fe5b42 100644 --- a/core/modules/user/tests/src/Functional/UserRoleAdminTest.php +++ b/core/modules/user/tests/src/Functional/UserRoleAdminTest.php @@ -72,7 +72,7 @@ public function testRoleAdministration() { $edit = ['label' => $role_name]; $this->drupalPostForm("admin/people/roles/manage/{$role->id()}", $edit, t('Save')); $this->assertRaw(t('Role %label has been updated.', ['%label' => $role_name])); - \Drupal::entityManager()->getStorage('user_role')->resetCache([$role->id()]); + \Drupal::entityTypeManager()->getStorage('user_role')->resetCache([$role->id()]); $new_role = Role::load($role->id()); $this->assertEqual($new_role->label(), $role_name, 'The role name has been successfully changed.'); @@ -82,7 +82,7 @@ public function testRoleAdministration() { $this->drupalPostForm(NULL, [], t('Delete')); $this->assertRaw(t('The role %label has been deleted.', ['%label' => $role_name])); $this->assertNoLinkByHref("admin/people/roles/manage/{$role->id()}", 'Role edit link removed.'); - \Drupal::entityManager()->getStorage('user_role')->resetCache([$role->id()]); + \Drupal::entityTypeManager()->getStorage('user_role')->resetCache([$role->id()]); $this->assertFalse(Role::load($role->id()), 'A deleted role can no longer be loaded.'); // Make sure that the system-defined roles can be edited via the user diff --git a/core/modules/user/tests/src/Functional/UserTranslationUITest.php b/core/modules/user/tests/src/Functional/UserTranslationUITest.php index 12502680364caa664026ad61bb54d0fb9947c10b..d087d528d719ab8dc2eaecf75b9c1ee4f662de8f 100644 --- a/core/modules/user/tests/src/Functional/UserTranslationUITest.php +++ b/core/modules/user/tests/src/Functional/UserTranslationUITest.php @@ -31,7 +31,7 @@ protected function setUp() { $this->name = $this->randomMachineName(); parent::setUp(); - \Drupal::entityManager()->getStorage('user')->resetCache(); + \Drupal::entityTypeManager()->getStorage('user')->resetCache(); } /** diff --git a/core/modules/user/tests/src/Functional/Views/AccessRoleTest.php b/core/modules/user/tests/src/Functional/Views/AccessRoleTest.php index 7f847234aa2ddded69742e8e3fe892690cd55001..7f92860f8bb4e8db3e38834588470d380192e519 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 600c2ec265472b6f42502d4751ab6ff65ed32103..2540ac2cd34ea4afe2274223c871c205244afd40 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 772c4e23b9587e2f7e10f5eaba7eb5320db03f59..47771e2e61de922cb496ab5fda4be89421145e4d 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 280ccf4d1627a21e049d57aad5a79bdcc91ce753..14ac7994fdbcaabf0bbd3bddc9bca15c62326b33 100644 --- a/core/modules/views/src/Plugin/views/cache/CachePluginBase.php +++ b/core/modules/views/src/Plugin/views/cache/CachePluginBase.php @@ -241,7 +241,7 @@ public function getCacheTags() { if (!empty($entity_information)) { // Add the list cache tags for each entity type used by this view. foreach ($entity_information as $table => $metadata) { - $tags = Cache::mergeTags($tags, \Drupal::entityManager()->getDefinition($metadata['entity_type'])->getListCacheTags()); + $tags = Cache::mergeTags($tags, \Drupal::entityTypeManager()->getDefinition($metadata['entity_type'])->getListCacheTags()); } } diff --git a/core/modules/views/src/Plugin/views/query/QueryPluginBase.php b/core/modules/views/src/Plugin/views/query/QueryPluginBase.php index 83e0bcfa2403e04581f0937da4f9e462a0df7f7c..5d39b9cb1c672978bcc7f90f6460d04b7c1dcd36 100644 --- a/core/modules/views/src/Plugin/views/query/QueryPluginBase.php +++ b/core/modules/views/src/Plugin/views/query/QueryPluginBase.php @@ -316,7 +316,7 @@ public function getEntityTableInfo() { // Determine which of the tables are revision tables. foreach ($entity_tables as $table_alias => $table) { - $entity_type = \Drupal::entityManager()->getDefinition($table['entity_type']); + $entity_type = \Drupal::entityTypeManager()->getDefinition($table['entity_type']); if ($entity_type->getRevisionTable() == $table['base']) { $entity_tables[$table_alias]['revision'] = TRUE; } @@ -339,7 +339,7 @@ public function getCacheContexts() { $contexts = []; if (($views_data = Views::viewsData()->get($this->view->storage->get('base_table'))) && !empty($views_data['table']['entity type'])) { $entity_type_id = $views_data['table']['entity type']; - $entity_type = \Drupal::entityManager()->getDefinition($entity_type_id); + $entity_type = \Drupal::entityTypeManager()->getDefinition($entity_type_id); $contexts = $entity_type->getListCacheContexts(); } return $contexts; diff --git a/core/modules/views/src/Plugin/views/query/Sql.php b/core/modules/views/src/Plugin/views/query/Sql.php index 03749a329b3e9235655cb9a3ef141f036a4db41a..7503e1d8b1584c303fe3e117682457795918e244 100644 --- a/core/modules/views/src/Plugin/views/query/Sql.php +++ b/core/modules/views/src/Plugin/views/query/Sql.php @@ -1346,7 +1346,7 @@ public function query($get_count = FALSE) { } foreach ($entity_information as $entity_type_id => $info) { - $entity_type = \Drupal::entityManager()->getDefinition($info['entity_type']); + $entity_type = \Drupal::entityTypeManager()->getDefinition($info['entity_type']); $base_field = !$info['revision'] ? $entity_type->getKey('id') : $entity_type->getKey('revision'); $this->addField($info['alias'], $base_field, '', $params); } diff --git a/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php b/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php index 20ff84dad7ba2d0ee9ef51b258b7d166bc53fbcf..ea9cf95f98a93d05dab3bb700a0db3916349b777 100644 --- a/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php +++ b/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php @@ -139,7 +139,7 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition $this->bundleInfoService = $bundle_info_service; $this->base_table = $this->definition['base_table']; - $entity_types = \Drupal::entityManager()->getDefinitions(); + $entity_types = \Drupal::entityTypeManager()->getDefinitions(); foreach ($entity_types as $entity_type_id => $entity_type) { if (in_array($this->base_table, [$entity_type->getBaseTable(), $entity_type->getDataTable(), $entity_type->getRevisionTable(), $entity_type->getRevisionDataTable()], TRUE)) { $this->entityType = $entity_type; diff --git a/core/modules/views/src/Tests/ViewTestData.php b/core/modules/views/src/Tests/ViewTestData.php index f0c8cfce7d9f310380389f47de219b87396a7c3b..6033fcfd33f5917ee798af007d63c4de7dc4d9fe 100644 --- a/core/modules/views/src/Tests/ViewTestData.php +++ b/core/modules/views/src/Tests/ViewTestData.php @@ -31,7 +31,7 @@ public static function createTestViews($class, array $modules) { $class = get_parent_class($class); } if (!empty($views)) { - $storage = \Drupal::entityManager()->getStorage('view'); + $storage = \Drupal::entityTypeManager()->getStorage('view'); $module_handler = \Drupal::moduleHandler(); foreach ($modules as $module) { $config_dir = drupal_get_path('module', $module) . '/test_views'; diff --git a/core/modules/views/src/Views.php b/core/modules/views/src/Views.php index dd241f714b602507c356ee5fca23cf5872c229e7..32cf016fd4117e97acedbd2a01bc90e24277069a 100644 --- a/core/modules/views/src/Views.php +++ b/core/modules/views/src/Views.php @@ -242,7 +242,7 @@ public static function getApplicableViews($type) { * An array of loaded view entities. */ public static function getAllViews() { - return \Drupal::entityManager()->getStorage('view')->loadMultiple(); + return \Drupal::entityTypeManager()->getStorage('view')->loadMultiple(); } /** @@ -256,7 +256,7 @@ public static function getEnabledViews() { ->condition('status', TRUE) ->execute(); - return \Drupal::entityManager()->getStorage('view')->loadMultiple($query); + return \Drupal::entityTypeManager()->getStorage('view')->loadMultiple($query); } /** @@ -270,7 +270,7 @@ public static function getDisabledViews() { ->condition('status', FALSE) ->execute(); - return \Drupal::entityManager()->getStorage('view')->loadMultiple($query); + return \Drupal::entityTypeManager()->getStorage('view')->loadMultiple($query); } /** diff --git a/core/modules/views/tests/src/Functional/Handler/FieldEntityOperationsTest.php b/core/modules/views/tests/src/Functional/Handler/FieldEntityOperationsTest.php index 7ced4f7071e0ac7b553251c55c86975872b4258f..c8f962dbe8ef772b5022bc3521a919850324afa0 100644 --- a/core/modules/views/tests/src/Functional/Handler/FieldEntityOperationsTest.php +++ b/core/modules/views/tests/src/Functional/Handler/FieldEntityOperationsTest.php @@ -69,7 +69,7 @@ public function testEntityOperations() { /** @var \Drupal\Core\Language\LanguageInterface $language */ foreach ($entity->getTranslationLanguages() as $language) { $entity = $entity->getTranslation($language->getId()); - $operations = \Drupal::entityManager()->getListBuilder('node')->getOperations($entity); + $operations = \Drupal::service('entity_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 41870b6db904cb64dce45cdf546b65c64817339a..21bdf1709da66e6c62cb523577e07b0ee4e847e3 100644 --- a/core/modules/views/tests/src/Functional/Wizard/NodeWizardTest.php +++ b/core/modules/views/tests/src/Functional/Wizard/NodeWizardTest.php @@ -25,7 +25,7 @@ public function testViewAddWithNodeTitles() { $view['page[style][row_plugin]'] = 'titles'; $this->drupalPostForm('admin/structure/views/add', $view, t('Save and edit')); - $view_storage_controller = \Drupal::entityManager()->getStorage('view'); + $view_storage_controller = \Drupal::entityTypeManager()->getStorage('view'); /** @var \Drupal\views\Entity\View $view */ $view = $view_storage_controller->load($view['id']); diff --git a/core/modules/views/tests/src/Kernel/Entity/RowEntityRenderersTest.php b/core/modules/views/tests/src/Kernel/Entity/RowEntityRenderersTest.php index a110f002094932b6d8a946440e08840cadc0158e..83e0cb97f5b5cd7120f83bd376e7a49e4569e24b 100644 --- a/core/modules/views/tests/src/Kernel/Entity/RowEntityRenderersTest.php +++ b/core/modules/views/tests/src/Kernel/Entity/RowEntityRenderersTest.php @@ -94,7 +94,7 @@ protected function setUp($import_test_views = TRUE) { $this->values = []; $this->ids = []; - $controller = \Drupal::entityManager()->getStorage('node'); + $controller = \Drupal::entityTypeManager()->getStorage('node'); $langcode_index = 0; for ($i = 0; $i < count($this->langcodes); $i++) { diff --git a/core/modules/views/tests/src/Kernel/Handler/AreaEntityTest.php b/core/modules/views/tests/src/Kernel/Handler/AreaEntityTest.php index 2ccaac6f31e9d35beb7bd1f5be838fa34d2af9cd..0d3ce325d44da02cde3c372db3a071331730551f 100644 --- a/core/modules/views/tests/src/Kernel/Handler/AreaEntityTest.php +++ b/core/modules/views/tests/src/Kernel/Handler/AreaEntityTest.php @@ -149,7 +149,7 @@ public function doTestRender($entities) { $this->assertTrue(strpos(trim((string) $result[0]), 'full') !== FALSE, 'The rendered entity appeared in the right view mode.'); // Mark entity_test test view_mode as customizable. - $entity_view_mode = \Drupal::entityManager()->getStorage('entity_view_mode')->load('entity_test.test'); + $entity_view_mode = \Drupal::entityTypeManager()->getStorage('entity_view_mode')->load('entity_test.test'); $entity_view_mode->enable(); $entity_view_mode->save(); diff --git a/core/modules/views/tests/src/Kernel/Handler/FieldFieldAccessTestBase.php b/core/modules/views/tests/src/Kernel/Handler/FieldFieldAccessTestBase.php index 5ff77bc9f4dd129d0684088776ee6047b817992d..327bfc14814f8bc64fafffd4c5aee4552410e45d 100644 --- a/core/modules/views/tests/src/Kernel/Handler/FieldFieldAccessTestBase.php +++ b/core/modules/views/tests/src/Kernel/Handler/FieldFieldAccessTestBase.php @@ -83,7 +83,7 @@ protected function setUp($import_test_views = TRUE) { protected function assertFieldAccess($entity_type_id, $field_name, $field_content) { \Drupal::state()->set('views_field_access_test-field', $field_name); - $entity_type = \Drupal::entityManager()->getDefinition($entity_type_id); + $entity_type = \Drupal::entityTypeManager()->getDefinition($entity_type_id); $view_id = $this->randomMachineName(); $data_table = $entity_type->getDataTable(); // Use the data table as long as the field is not 'uuid'. This is the only diff --git a/core/modules/views/tests/src/Kernel/ViewStorageTest.php b/core/modules/views/tests/src/Kernel/ViewStorageTest.php index e6cce86f2eff9582295656627bfc3e35a1f55137..b60df267b34a9d35d983c7c31478f2679245c46a 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 bf0fd7014e047d23f2f0ea0cde6d7425ca35c9fe..9889c93e325db65786f173eb5c417a4cdc2c183b 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 4e06b7510c51b99b7ec0728dd0c13cf2606d3436..25349a33eeb4d45ef34585c7ffb3bab3fd22474e 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 30749fcba87d3a61749c8ee714237c997cc94393..8c10f65e4f0cf414d2a551556dd8422928d9afca 100644 --- a/core/modules/views/views.post_update.php +++ b/core/modules/views/views.post_update.php @@ -17,7 +17,7 @@ */ function views_post_update_update_cacheability_metadata() { // Load all views. - $views = \Drupal::entityManager()->getStorage('view')->loadMultiple(); + $views = \Drupal::entityTypeManager()->getStorage('view')->loadMultiple(); /* @var \Drupal\views\Entity\View[] $views */ foreach ($views as $view) { diff --git a/core/modules/views/views.views.inc b/core/modules/views/views.views.inc index 9c86a3a3479cb567d50f6f3eebe64387df7212bc..39a8f7239cf4046bff8f3754f4b1ccd228377ad1 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 619b1914654aac73c5353f1433fc67b3728b3fd8..65d45eee5c33ec3b74b928a2559b18b2d494783a 100644 --- a/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php +++ b/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php @@ -165,7 +165,7 @@ public function getForm(ViewEntityInterface $view, $display_id, $js) { // If this form was for view-wide changes, there's no need to regenerate // the display section of the form. if ($display_id !== '') { - \Drupal::entityManager()->getFormObject('view', 'edit')->rebuildCurrentTab($view, $response, $display_id); + \Drupal::entityTypeManager()->getFormObject('view', 'edit')->rebuildCurrentTab($view, $response, $display_id); } return $response; diff --git a/core/modules/views_ui/tests/src/Functional/DisplayPathTest.php b/core/modules/views_ui/tests/src/Functional/DisplayPathTest.php index 2f007f193c6814ec8f3e5d9834b0e5d68c0f08cf..5973a5d59bfc4bdb1b8e993fdd107ba37ec91344 100644 --- a/core/modules/views_ui/tests/src/Functional/DisplayPathTest.php +++ b/core/modules/views_ui/tests/src/Functional/DisplayPathTest.php @@ -212,7 +212,7 @@ public function testDefaultMenuTabRegression() { ]; $this->drupalPostForm('admin/structure/menu/manage/admin/add', $edit, t('Save')); - $menu_items = \Drupal::entityManager()->getStorage('menu_link_content')->getQuery() + $menu_items = \Drupal::entityTypeManager()->getStorage('menu_link_content')->getQuery() ->sort('id', 'DESC') ->pager(1) ->execute(); diff --git a/core/modules/views_ui/tests/src/Functional/ViewEditTest.php b/core/modules/views_ui/tests/src/Functional/ViewEditTest.php index 94f9da81444653f25a07a1e0f07452683c307d97..bfe5b05d071f5a9858df4d2cbb2650cd79185edc 100644 --- a/core/modules/views_ui/tests/src/Functional/ViewEditTest.php +++ b/core/modules/views_ui/tests/src/Functional/ViewEditTest.php @@ -58,7 +58,7 @@ public function testOtherOptions() { // Save the view, and test the new ID has been saved. $this->drupalPostForm(NULL, [], 'Save'); - $view = \Drupal::entityManager()->getStorage('view')->load('test_view'); + $view = \Drupal::entityTypeManager()->getStorage('view')->load('test_view'); $displays = $view->get('display'); $this->assertTrue(!empty($displays['test_1']), 'Display data found for new display ID key.'); $this->assertIdentical($displays['test_1']['id'], 'test_1', 'New display ID matches the display ID key.'); diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStaticCacheTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStaticCacheTest.php index 1cd9cb17537a809b06e101c7ea09bd886bd7d25c..aaeeb9d31eb8ecf6fc651a6e6c85957729a9d0f3 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStaticCacheTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStaticCacheTest.php @@ -86,7 +86,7 @@ public function testReset() { */ public function testConfigOverride() { /** @var \Drupal\Core\Config\Entity\ConfigEntityStorage $storage */ - $storage = \Drupal::entityManager()->getStorage($this->entityTypeId); + $storage = \Drupal::entityTypeManager()->getStorage($this->entityTypeId); // Prime the cache prior to adding a config override. $storage->load($this->entityId); diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityUnitTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityUnitTest.php index 1fce8a498dd7b3803294234701619f87d66c3d8a..fcc472f9e2c98677790349fa8a0921fe4224951e 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityUnitTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityUnitTest.php @@ -46,7 +46,7 @@ protected function setUp() { * Tests storage methods. */ public function testStorageMethods() { - $entity_type = \Drupal::entityManager()->getDefinition('config_test'); + $entity_type = \Drupal::entityTypeManager()->getDefinition('config_test'); // Test the static extractID() method. $expected_id = 'test_id'; diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php index 6489b06799e94f767a7a7d87893275dd66e325f0..70dbb874c96f90f3e9300342caaa80d04a11aa21 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php @@ -244,7 +244,7 @@ public function testSecondaryWritePrimaryFirst() { // Import. $this->configImporter->reset()->import(); - $entity_storage = \Drupal::entityManager()->getStorage('config_test'); + $entity_storage = \Drupal::entityTypeManager()->getStorage('config_test'); $primary = $entity_storage->load('primary'); $this->assertEqual($primary->id(), 'primary'); $this->assertEqual($primary->uuid(), $values_primary['uuid']); @@ -290,7 +290,7 @@ public function testSecondaryWriteSecondaryFirst() { // Import. $this->configImporter->reset()->import(); - $entity_storage = \Drupal::entityManager()->getStorage('config_test'); + $entity_storage = \Drupal::entityTypeManager()->getStorage('config_test'); $primary = $entity_storage->load('primary'); $this->assertEqual($primary->id(), 'primary'); $this->assertEqual($primary->uuid(), $values_primary['uuid']); @@ -367,7 +367,7 @@ public function testSecondaryUpdateDeletedDeleterFirst() { // Import. $this->configImporter->import(); - $entity_storage = \Drupal::entityManager()->getStorage('config_test'); + $entity_storage = \Drupal::entityTypeManager()->getStorage('config_test'); $deleter = $entity_storage->load('deleter'); $this->assertEqual($deleter->id(), 'deleter'); $this->assertEqual($deleter->uuid(), $values_deleter['uuid']); @@ -427,7 +427,7 @@ public function testSecondaryUpdateDeletedDeleteeFirst() { // Import. $this->configImporter->reset()->import(); - $entity_storage = \Drupal::entityManager()->getStorage('config_test'); + $entity_storage = \Drupal::entityTypeManager()->getStorage('config_test'); // Both entities are deleted. ConfigTest::postSave() causes updates of the // deleter entity to delete the deletee entity. Since the deleter depends on // the deletee, removing the deletee causes the deleter to be removed. @@ -469,7 +469,7 @@ public function testSecondaryDeletedDeleteeSecond() { // Import. $this->configImporter->reset()->import(); - $entity_storage = \Drupal::entityManager()->getStorage('config_test'); + $entity_storage = \Drupal::entityTypeManager()->getStorage('config_test'); $this->assertFalse($entity_storage->load('deleter')); $this->assertFalse($entity_storage->load('deletee')); // The deletee entity does not exist as the delete worked and although the diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigInstallTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigInstallTest.php index 5efd20bbb15dfdc5626ddb030471e6bafc022b51..89b284612c5bf225f22782a6098aaf28f999faab 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/ConfigInstallTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigInstallTest.php @@ -223,7 +223,7 @@ public function testDependencyChecking() { } $this->installModules(['config_other_module_config_test']); $this->installModules(['config_install_dependency_test']); - $entity = \Drupal::entityManager()->getStorage('config_test')->load('other_module_test_with_dependency'); + $entity = \Drupal::entityTypeManager()->getStorage('config_test')->load('other_module_test_with_dependency'); $this->assertTrue($entity, 'The config_test.dynamic.other_module_test_with_dependency configuration has been created during install.'); // Ensure that dependencies can be added during module installation by // hooks. diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityApiTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityApiTest.php index db556902955539e7cb92a96957f4ab04e2c1cd9a..3f253f6d182903913247343fb541f2e5a0597b04 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityApiTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityApiTest.php @@ -93,7 +93,7 @@ protected function assertCRUD($entity_type, UserInterface $user1) { $this->assertTrue(empty($all), format_string('%entity_type: Deleted all entities.', ['%entity_type' => $entity_type])); // Verify that all data got deleted. - $definition = \Drupal::entityManager()->getDefinition($entity_type); + $definition = \Drupal::entityTypeManager()->getDefinition($entity_type); $this->assertEqual(0, db_query('SELECT COUNT(*) FROM {' . $definition->getBaseTable() . '}')->fetchField(), 'Base table was emptied'); if ($data_table = $definition->getDataTable()) { $this->assertEqual(0, db_query('SELECT COUNT(*) FROM {' . $data_table . '}')->fetchField(), 'Data table was emptied'); @@ -113,7 +113,7 @@ protected function assertCRUD($entity_type, UserInterface $user1) { $entity = $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 @@ protected function assertCRUD($entity_type, UserInterface $user1) { $this->assertTrue(empty($all), format_string('%entity_type: Deleted all entities.', ['%entity_type' => $entity_type])); // Verify that all data got deleted from the tables. - $definition = \Drupal::entityManager()->getDefinition($entity_type); + $definition = \Drupal::entityTypeManager()->getDefinition($entity_type); $this->assertEqual(0, db_query('SELECT COUNT(*) FROM {' . $definition->getBaseTable() . '}')->fetchField(), 'Base table was emptied'); if ($data_table = $definition->getDataTable()) { $this->assertEqual(0, db_query('SELECT COUNT(*) FROM {' . $data_table . '}')->fetchField(), 'Data table was emptied'); diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntitySchemaTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntitySchemaTest.php index bb9645886b669b5fbae6e91ad9654dca06c8ee0b..f8be106cbc84a29b0171eef8b1723e54f3c1fa20 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntitySchemaTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntitySchemaTest.php @@ -323,7 +323,7 @@ public function testCleanUpStorageDefinition() { // Find all the entity types provided by the entity_test module and install // the schema for them. $entity_type_ids = []; - $entities = \Drupal::entityManager()->getDefinitions(); + $entities = \Drupal::entityTypeManager()->getDefinitions(); foreach ($entities as $entity_type_id => $definition) { if ($definition->getProvider() == 'entity_test') { $this->installEntitySchema($entity_type_id); diff --git a/core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php b/core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php index 40d9488c60d4ee7061560e6ae40174ebac08933f..76e7004d23c06bfd0e89ee859e79fe734760793c 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php @@ -93,7 +93,7 @@ protected function setUp() { $this->field->save(); /** @var \Drupal\Core\Entity\Sql\DefaultTableMapping $table_mapping */ - $table_mapping = \Drupal::entityManager()->getStorage($entity_type)->getTableMapping(); + $table_mapping = \Drupal::entityTypeManager()->getStorage($entity_type)->getTableMapping(); $this->tableMapping = $table_mapping; $this->table = $table_mapping->getDedicatedDataTableName($this->fieldStorage); $this->revisionTable = $table_mapping->getDedicatedRevisionTableName($this->fieldStorage); diff --git a/core/tests/Drupal/KernelTests/Core/Entity/FieldTranslationSqlStorageTest.php b/core/tests/Drupal/KernelTests/Core/Entity/FieldTranslationSqlStorageTest.php index 1edc386b202694cbe52b0da39cf77d7004701953..c1900c52a15adf835729d4e7e06b7e412d9197e6 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/FieldTranslationSqlStorageTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/FieldTranslationSqlStorageTest.php @@ -78,7 +78,7 @@ protected function assertFieldStorageLangcode(FieldableEntityInterface $entity, $langcode = $entity->getUntranslated()->language()->getId(); $fields = [$this->fieldName, $this->untranslatableFieldName]; /** @var \Drupal\Core\Entity\Sql\DefaultTableMapping $table_mapping */ - $table_mapping = \Drupal::entityManager()->getStorage($entity_type)->getTableMapping(); + $table_mapping = \Drupal::entityTypeManager()->getStorage($entity_type)->getTableMapping(); foreach ($fields as $field_name) { $field_storage = FieldStorageConfig::loadByName($entity_type, $field_name); diff --git a/core/tests/Drupal/KernelTests/Core/Entity/FieldWidgetConstraintValidatorTest.php b/core/tests/Drupal/KernelTests/Core/Entity/FieldWidgetConstraintValidatorTest.php index bcb68469a46a47a647cf5f3ea26edb0c562fa53d..2f5f85218cf18a43ed95ca8511e953ffcdd4226e 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/FieldWidgetConstraintValidatorTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/FieldWidgetConstraintValidatorTest.php @@ -45,7 +45,7 @@ public function testValidation() { $display->buildForm($entity, $form, $form_state); // Pretend the form has been built. - $form_state->setFormObject(\Drupal::entityManager()->getFormObject($entity_type, 'default')); + $form_state->setFormObject(\Drupal::entityTypeManager()->getFormObject($entity_type, 'default')); \Drupal::formBuilder()->prepareForm('field_test_entity_form', $form, $form_state); \Drupal::formBuilder()->processForm('field_test_entity_form', $form, $form_state); @@ -83,7 +83,7 @@ protected function getErrorsForEntity(EntityInterface $entity, $hidden_fields = $form_state = new FormState(); $display->buildForm($entity, $form, $form_state); - $form_state->setFormObject(\Drupal::entityManager()->getFormObject($entity_type_id, 'default')); + $form_state->setFormObject(\Drupal::entityTypeManager()->getFormObject($entity_type_id, 'default')); \Drupal::formBuilder()->prepareForm('field_test_entity_form', $form, $form_state); \Drupal::formBuilder()->processForm('field_test_entity_form', $form, $form_state); diff --git a/core/tests/Drupal/KernelTests/Core/Entity/RevisionableContentEntityBaseTest.php b/core/tests/Drupal/KernelTests/Core/Entity/RevisionableContentEntityBaseTest.php index 8a959c3c71d95991336df5dd8c856116b599dbee..aa2a042ddb7884a532aba297091fa56785354c3a 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/RevisionableContentEntityBaseTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/RevisionableContentEntityBaseTest.php @@ -42,7 +42,7 @@ protected function setUp() { */ public function testRevisionableContentEntity() { $entity_type = 'entity_test_mul_revlog'; - $definition = \Drupal::entityManager()->getDefinition($entity_type); + $definition = \Drupal::entityTypeManager()->getDefinition($entity_type); $user = User::create(['name' => 'test name']); $user->save(); /** @var \Drupal\entity_test_mul_revlog\Entity\EntityTestMulWithRevisionLog $entity */ diff --git a/core/tests/Drupal/KernelTests/Core/Menu/MenuLinkTreeTest.php b/core/tests/Drupal/KernelTests/Core/Menu/MenuLinkTreeTest.php index a998f0fea85d9fd34ebbffdd966bf8d914695aba..42d8110e19632d250563e9b47b978cfaa99537e1 100644 --- a/core/tests/Drupal/KernelTests/Core/Menu/MenuLinkTreeTest.php +++ b/core/tests/Drupal/KernelTests/Core/Menu/MenuLinkTreeTest.php @@ -61,12 +61,12 @@ protected function setUp() { * Tests deleting all the links in a menu. */ public function testDeleteLinksInMenu() { - \Drupal::entityManager()->getStorage('menu')->create(['id' => 'menu1'])->save(); - \Drupal::entityManager()->getStorage('menu')->create(['id' => 'menu2'])->save(); + \Drupal::entityTypeManager()->getStorage('menu')->create(['id' => 'menu1'])->save(); + \Drupal::entityTypeManager()->getStorage('menu')->create(['id' => 'menu2'])->save(); - \Drupal::entityManager()->getStorage('menu_link_content')->create(['link' => ['uri' => 'internal:/menu_name_test'], 'menu_name' => 'menu1', 'bundle' => 'menu_link_content', 'title' => 'Link test'])->save(); - \Drupal::entityManager()->getStorage('menu_link_content')->create(['link' => ['uri' => 'internal:/menu_name_test'], 'menu_name' => 'menu1', 'bundle' => 'menu_link_content', 'title' => 'Link test'])->save(); - \Drupal::entityManager()->getStorage('menu_link_content')->create(['link' => ['uri' => 'internal:/menu_name_test'], 'menu_name' => 'menu2', 'bundle' => 'menu_link_content', 'title' => 'Link test'])->save(); + \Drupal::entityTypeManager()->getStorage('menu_link_content')->create(['link' => ['uri' => 'internal:/menu_name_test'], 'menu_name' => 'menu1', 'bundle' => 'menu_link_content', 'title' => 'Link test'])->save(); + \Drupal::entityTypeManager()->getStorage('menu_link_content')->create(['link' => ['uri' => 'internal:/menu_name_test'], 'menu_name' => 'menu1', 'bundle' => 'menu_link_content', 'title' => 'Link test'])->save(); + \Drupal::entityTypeManager()->getStorage('menu_link_content')->create(['link' => ['uri' => 'internal:/menu_name_test'], 'menu_name' => 'menu2', 'bundle' => 'menu_link_content', 'title' => 'Link test'])->save(); $output = $this->linkTree->load('menu1', new MenuTreeParameters()); $this->assertEqual(count($output), 2); diff --git a/core/tests/Drupal/Tests/Core/DrupalTest.php b/core/tests/Drupal/Tests/Core/DrupalTest.php index dfb7d9d641c96de55549c2375394ba7e2bc0e254..3ed2b0d9dc29434e80a5ca447d6830b236450650 100644 --- a/core/tests/Drupal/Tests/Core/DrupalTest.php +++ b/core/tests/Drupal/Tests/Core/DrupalTest.php @@ -79,6 +79,8 @@ public function testCurrentUser() { * 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 4ae51829035788113e5f1370395470cb24dc12e5..aa5807f8f9c8c8e5d53050506aacf176a6530cc5 100644 --- a/core/tests/Drupal/Tests/Core/Session/UserSessionTest.php +++ b/core/tests/Drupal/Tests/Core/Session/UserSessionTest.php @@ -110,13 +110,13 @@ protected function setUp() { [['anonymous', 'role_one', 'role_two'], [$roles['role_one'], $roles['role_two']]], ])); - $entity_manager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface'); - $entity_manager->expects($this->any()) + $entity_type_manager = $this->getMock('Drupal\Core\Entity\EntityTypeManagerInterface'); + $entity_type_manager->expects($this->any()) ->method('getStorage') ->with($this->equalTo('user_role')) ->will($this->returnValue($role_storage)); $container = new ContainerBuilder(); - $container->set('entity.manager', $entity_manager); + $container->set('entity_type.manager', $entity_type_manager); \Drupal::setContainer($container); $this->users['user_one'] = $this->createUserSession(['role_one']);