diff --git a/core/modules/field/field.module b/core/modules/field/field.module index 053ab4a..7297894 100644 --- a/core/modules/field/field.module +++ b/core/modules/field/field.module @@ -170,7 +170,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') @@ -191,7 +191,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') @@ -212,7 +212,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 @@ -231,7 +231,7 @@ function field_entity_bundle_delete($entity_type_id, $bundle) { // config entity type so they are not part of the config dependencies. // Gather a list of all entity reference fields. - $map = \Drupal::entityManager()->getFieldMapByFieldType('entity_reference'); + $map = \Drupal::service('entity_field.manager')->getFieldMapByFieldType('entity_reference'); $ids = []; foreach ($map as $type => $info) { foreach ($info as $name => $data) { @@ -283,7 +283,7 @@ function field_entity_bundle_delete($entity_type_id, $bundle) { */ function _field_create_entity_from_ids($ids) { $id_properties = array(); - $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 bd9203c..0bc99dc 100644 --- a/core/modules/field/field.purge.inc +++ b/core/modules/field/field.purge.inc @@ -82,7 +82,7 @@ function field_purge_batch($batch_size, $field_storage_uuid = NULL) { } $fields = entity_load_multiple_by_properties('field_config', $properties); - $info = \Drupal::entityManager()->getDefinitions(); + $info = \Drupal::service('entity_type.manager')->getDefinitions(); foreach ($fields as $field) { $entity_type = $field->getTargetEntityTypeId(); @@ -93,7 +93,7 @@ function field_purge_batch($batch_size, $field_storage_uuid = 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); @@ -170,7 +170,7 @@ function field_purge_field_storage(FieldStorageConfigInterface $field_storage) { $state->set('field.storage.deleted', $deleted_storages); // 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', array($field_storage)); diff --git a/core/modules/field/src/ConfigImporterFieldPurger.php b/core/modules/field/src/ConfigImporterFieldPurger.php index 4137294..c7aadb3 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 = array(); 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 d7ccc30..c63cde3 100644 --- a/core/modules/field/src/Entity/FieldConfig.php +++ b/core/modules/field/src/Entity/FieldConfig.php @@ -141,7 +141,7 @@ public function postCreate(EntityStorageInterface $storage) { * In case of failures at the configuration storage level. */ public function preSave(EntityStorageInterface $storage) { - $entity_manager = \Drupal::entityManager(); + $entity_manager = \Drupal::service('field_definition.listener'); $field_type_manager = \Drupal::service('plugin.manager.field.field_type'); $storage_definition = $this->getFieldStorageDefinition(); @@ -210,12 +210,12 @@ public static function preDelete(EntityStorageInterface $storage, array $fields) */ public static function postDelete(EntityStorageInterface $storage, array $fields) { // Clear the cache upfront, to refresh the results of getBundles(). - \Drupal::entityManager()->clearCachedFieldDefinitions(); + \Drupal::service('entity_field.manager')->clearCachedFieldDefinitions(); // Notify the entity storage. foreach ($fields as $field) { if (!$field->deleted) { - \Drupal::entityManager()->onFieldDefinitionDelete($field); + \Drupal::service('field_definition.listener')->onFieldDefinitionDelete($field); } } @@ -237,7 +237,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); } } @@ -263,7 +263,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; @@ -338,7 +338,7 @@ public function isComputed() { * 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 00883d6..81def22 100644 --- a/core/modules/field/src/Entity/FieldStorageConfig.php +++ b/core/modules/field/src/Entity/FieldStorageConfig.php @@ -302,7 +302,8 @@ public function preSave(EntityStorageInterface $storage) { * If the field definition is invalid. */ protected function preSaveNew(EntityStorageInterface $storage) { - $entity_manager = \Drupal::entityManager(); + $entity_manager = \Drupal::service('entity_field.manager'); + $entity_type_manager = \Drupal::service('field_storage_definition.listener'); $field_type_manager = \Drupal::service('plugin.manager.field.field_type'); // Assign the ID. @@ -328,8 +329,8 @@ protected function preSaveNew(EntityStorageInterface $storage) { } $this->module = $field_type['provider']; - // Notify the entity manager. - $entity_manager->onFieldStorageDefinitionCreate($this); + // Notify the entity type manager. + $entity_type_manager->onFieldStorageDefinitionCreate($this); } /** @@ -345,7 +346,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; } @@ -358,7 +359,7 @@ public function calculateDependencies() { */ protected function preSaveUpdated(EntityStorageInterface $storage) { $module_handler = \Drupal::moduleHandler(); - $entity_manager = \Drupal::entityManager(); + $entity_manager = \Drupal::service('field_storage_definition.listener'); // Some updates are always disallowed. if ($this->getType() != $this->original->getType()) { @@ -384,7 +385,7 @@ 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_manager = \Drupal::entityTypeManager(); $entity_type = $this->getTargetEntityTypeId(); if ($entity_manager->hasHandler($entity_type, 'view_builder')) { $entity_manager->getViewBuilder($entity_type)->resetCache(); @@ -427,7 +428,7 @@ public static function postDelete(EntityStorageInterface $storage, array $fields // Notify the storage. foreach ($fields as $field) { if (!$field->deleted) { - \Drupal::entityManager()->onFieldStorageDefinitionDelete($field); + \Drupal::service('field_storage_definition.listener')->onFieldStorageDefinitionDelete($field); $field->deleted = TRUE; } } @@ -494,7 +495,7 @@ public function getColumns() { */ public function getBundles() { if (!$this->isDeleted()) { - $map = \Drupal::entityManager()->getFieldMap(); + $map = \Drupal::service('entity_field.manager')->getFieldMap(); if (isset($map[$this->getTargetEntityTypeId()][$this->getName()]['bundles'])) { return $map[$this->getTargetEntityTypeId()][$this->getName()]['bundles']; } @@ -697,7 +698,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); } /** @@ -796,7 +797,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/src/Tests/EntityReference/EntityReferenceAdminTest.php b/core/modules/field/src/Tests/EntityReference/EntityReferenceAdminTest.php index d781084..ee2485a 100644 --- a/core/modules/field/src/Tests/EntityReference/EntityReferenceAdminTest.php +++ b/core/modules/field/src/Tests/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::service('entity_type.manager')->getDefinitions())); // Second step: 'Field settings' form. $this->drupalPostForm(NULL, array(), t('Save field settings')); diff --git a/core/modules/field/src/Tests/EntityReference/EntityReferenceFieldDefaultValueTest.php b/core/modules/field/src/Tests/EntityReference/EntityReferenceFieldDefaultValueTest.php index 6433958..2c69bf8 100644 --- a/core/modules/field/src/Tests/EntityReference/EntityReferenceFieldDefaultValueTest.php +++ b/core/modules/field/src/Tests/EntityReference/EntityReferenceFieldDefaultValueTest.php @@ -91,7 +91,7 @@ function testEntityReferenceDefaultValue() { $this->assertEqual(array($referenced_node->getConfigDependencyName()), $config_entity['dependencies']['content']); // Clear field definitions cache in order to avoid stale cache values. - \Drupal::entityManager()->clearCachedFieldDefinitions(); + \Drupal::service('entity_field.manager')->clearCachedFieldDefinitions(); // Create a new node to check that UUID has been converted to numeric ID. $new_node = Node::create(['type' => 'reference_content']); diff --git a/core/modules/field/src/Tests/EntityReference/EntityReferenceFieldTranslatedReferenceViewTest.php b/core/modules/field/src/Tests/EntityReference/EntityReferenceFieldTranslatedReferenceViewTest.php index d93b2ac..fbc0ea3 100644 --- a/core/modules/field/src/Tests/EntityReference/EntityReferenceFieldTranslatedReferenceViewTest.php +++ b/core/modules/field/src/Tests/EntityReference/EntityReferenceFieldTranslatedReferenceViewTest.php @@ -194,7 +194,7 @@ protected function enableTranslation() { \Drupal::service('content_translation.manager')->setEnabled($this->testEntityTypeName, $this->referrerType->id(), TRUE); \Drupal::service('content_translation.manager')->setEnabled($this->testEntityTypeName, $this->referencedType->id(), TRUE); drupal_static_reset(); - \Drupal::entityManager()->clearCachedDefinitions(); + \Drupal::service('entity_type.manager')->clearCachedDefinitions(); \Drupal::service('router.builder')->rebuild(); \Drupal::service('entity.definition_update_manager')->applyUpdates(); } diff --git a/core/modules/field/src/Tests/EntityReference/EntityReferenceIntegrationTest.php b/core/modules/field/src/Tests/EntityReference/EntityReferenceIntegrationTest.php index bae3041..7115469 100644 --- a/core/modules/field/src/Tests/EntityReference/EntityReferenceIntegrationTest.php +++ b/core/modules/field/src/Tests/EntityReference/EntityReferenceIntegrationTest.php @@ -151,7 +151,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/src/Tests/FieldImportDeleteUninstallUiTest.php b/core/modules/field/src/Tests/FieldImportDeleteUninstallUiTest.php index bfc135e..672215e 100644 --- a/core/modules/field/src/Tests/FieldImportDeleteUninstallUiTest.php +++ b/core/modules/field/src/Tests/FieldImportDeleteUninstallUiTest.php @@ -108,7 +108,7 @@ public function testImportDeleteUninstall() { $this->assertNoText('Field data will be deleted by this synchronization.'); $this->rebuildContainer(); $this->assertFalse(\Drupal::moduleHandler()->moduleExists('telephone')); - $this->assertFalse(\Drupal::entityManager()->loadEntityByUuid('field_storage_config', $field_storage->uuid()), 'The telephone field has been deleted by the configuration synchronization'); + $this->assertFalse(\Drupal::service('entity.repository')->loadEntityByUuid('field_storage_config', $field_storage->uuid()), 'The telephone field has been deleted by the configuration synchronization'); $deleted_storages = \Drupal::state()->get('field.storage.deleted') ?: array(); $this->assertFalse(isset($deleted_storages[$field_storage->uuid()]), 'Telephone field has been completed removed from the system.'); $this->assertFalse(isset($deleted_storages[$field_storage->uuid()]), 'Text field has been completed removed from the system.'); diff --git a/core/modules/field/src/Tests/FieldTestBase.php b/core/modules/field/src/Tests/FieldTestBase.php index 18259f6..356692f 100644 --- a/core/modules/field/src/Tests/FieldTestBase.php +++ b/core/modules/field/src/Tests/FieldTestBase.php @@ -47,7 +47,7 @@ function _generateTestFieldValues($cardinality) { */ function assertFieldValues(EntityInterface $entity, $field_name, $expected_values, $langcode = LanguageInterface::LANGCODE_DEFAULT, $column = 'value') { // Re-load the entity to make sure we have the latest changes. - \Drupal::entityManager()->getStorage($entity->getEntityTypeId())->resetCache(array($entity->id())); + \Drupal::entityTypeManager()->getStorage($entity->getEntityTypeId())->resetCache(array($entity->id())); $e = entity_load($entity->getEntityTypeId(), $entity->id()); $field = $values = $e->getTranslation($langcode)->$field_name; // Filter out empty values so that they don't mess with the assertions. diff --git a/core/modules/field/src/Tests/FieldUnitTestBase.php b/core/modules/field/src/Tests/FieldUnitTestBase.php index 42f75d9..fc05d2e 100644 --- a/core/modules/field/src/Tests/FieldUnitTestBase.php +++ b/core/modules/field/src/Tests/FieldUnitTestBase.php @@ -56,7 +56,7 @@ protected function setUp() { $this->installConfig(array('field', 'system')); // Create user 1. - $storage = \Drupal::entityManager()->getStorage('user'); + $storage = \Drupal::entityTypeManager()->getStorage('user'); $storage ->create(array( 'uid' => 1, @@ -189,7 +189,7 @@ protected function _generateTestFieldValues($cardinality) { */ protected function assertFieldValues(EntityInterface $entity, $field_name, $expected_values, $langcode = LanguageInterface::LANGCODE_NOT_SPECIFIED, $column = 'value') { // Re-load the entity to make sure we have the latest changes. - \Drupal::entityManager()->getStorage($entity->getEntityTypeId())->resetCache(array($entity->id())); + \Drupal::entityTypeManager()->getStorage($entity->getEntityTypeId())->resetCache(array($entity->id())); $e = entity_load($entity->getEntityTypeId(), $entity->id()); $field = $values = $e->getTranslation($langcode)->$field_name; // Filter out empty values so that they don't mess with the assertions. diff --git a/core/modules/field/src/Tests/FormTest.php b/core/modules/field/src/Tests/FormTest.php index c2efc17..48aba10 100644 --- a/core/modules/field/src/Tests/FormTest.php +++ b/core/modules/field/src/Tests/FormTest.php @@ -627,7 +627,7 @@ function testHiddenField() { $edit = array("{$field_name}[0][value]" => $value); $this->drupalPostForm(NULL, $edit, t('Save')); $this->assertText(t('entity_test_rev @id has been updated.', array('@id' => $id)), 'Entity was updated'); - \Drupal::entityManager()->getStorage($entity_type)->resetCache(array($id)); + \Drupal::entityTypeManager()->getStorage($entity_type)->resetCache(array($id)); $entity = entity_load($entity_type, $id); $this->assertEqual($entity->{$field_name}->value, $value, 'Field value was updated'); @@ -641,7 +641,7 @@ function testHiddenField() { $this->drupalPostForm($entity_type . '/manage/' . $id . '/edit', $edit, t('Save')); // Check that the expected value has been carried over to the new revision. - \Drupal::entityManager()->getStorage($entity_type)->resetCache(array($id)); + \Drupal::entityTypeManager()->getStorage($entity_type)->resetCache(array($id)); $entity = entity_load($entity_type, $id); $this->assertEqual($entity->{$field_name}->value, $value, 'New revision has the expected value for the field with the Hidden widget'); } diff --git a/core/modules/field/tests/modules/field_test/field_test.entity.inc b/core/modules/field/tests/modules/field_test/field_test.entity.inc index d5614ac..be91337 100644 --- a/core/modules/field/tests/modules/field_test/field_test.entity.inc +++ b/core/modules/field/tests/modules/field_test/field_test.entity.inc @@ -21,13 +21,14 @@ function field_test_entity_type_alter(array &$entity_types) { function field_test_entity_info_translatable($entity_type_id = NULL, $translatable = NULL) { $stored_value = &drupal_static(__FUNCTION__, array()); if (isset($entity_type_id)) { - $entity_manager = \Drupal::entityManager(); + $entity_manager = \Drupal::entityTypeManager(); + $entity_type_update = \Drupal::service('entity_type.listener'); $original = $entity_manager->getDefinition($entity_type_id); $stored_value[$entity_type_id] = $translatable; if ($translatable != $original->isTranslatable()) { $entity_manager->clearCachedDefinitions(); $entity_type = $entity_manager->getDefinition($entity_type_id); - $entity_manager->onEntityTypeUpdate($entity_type, $original); + $entity_type_update->onEntityTypeUpdate($entity_type, $original); } } return $stored_value; diff --git a/core/modules/field/tests/src/Kernel/BulkDeleteTest.php b/core/modules/field/tests/src/Kernel/BulkDeleteTest.php index 41fedfc..a4ff0d1 100644 --- a/core/modules/field/tests/src/Kernel/BulkDeleteTest.php +++ b/core/modules/field/tests/src/Kernel/BulkDeleteTest.php @@ -180,7 +180,7 @@ function testDeleteField() { $this->assertEqual($field->getTargetBundle(), $bundle, 'The deleted field is for the correct bundle'); // Check that the actual stored content did not change during delete. - $storage = \Drupal::entityManager()->getStorage($this->entityTypeId); + $storage = \Drupal::entityTypeManager()->getStorage($this->entityTypeId); /** @var \Drupal\Core\Entity\Sql\DefaultTableMapping $table_mapping */ $table_mapping = $storage->getTableMapping(); $table = $table_mapping->getDedicatedDataTableName($field_storage); diff --git a/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceFormatterTest.php b/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceFormatterTest.php index 5441c2f..f111819 100644 --- a/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceFormatterTest.php +++ b/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceFormatterTest.php @@ -196,7 +196,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.', array('@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 edb3029..7aa818a 100644 --- a/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceItemTest.php +++ b/core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceItemTest.php @@ -191,7 +191,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. @@ -267,7 +267,7 @@ public function testEntityAutoCreate() { $entity = unserialize($entity); // And then the entity. $entity->save(); - $term = \Drupal::entityManager()->loadEntityByUuid($term->getEntityTypeId(), $term->uuid()); + $term = \Drupal::service('entity.repository')->loadEntityByUuid($term->getEntityTypeId(), $term->uuid()); $this->assertEqual($entity->field_test_taxonomy_term->entity->id(), $term->id()); } diff --git a/core/modules/field/tests/src/Kernel/FieldAttachOtherTest.php b/core/modules/field/tests/src/Kernel/FieldAttachOtherTest.php index ba96bc9..c23a023 100644 --- a/core/modules/field/tests/src/Kernel/FieldAttachOtherTest.php +++ b/core/modules/field/tests/src/Kernel/FieldAttachOtherTest.php @@ -333,7 +333,7 @@ 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::service('entity_type.manager')->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 8237ef4..7b28529 100644 --- a/core/modules/field/tests/src/Kernel/FieldAttachStorageTest.php +++ b/core/modules/field/tests/src/Kernel/FieldAttachStorageTest.php @@ -127,7 +127,7 @@ function testFieldAttachLoadMultiple() { } // Check that a single load correctly loads field values for both entities. - $controller = \Drupal::entityManager()->getStorage($entity->getEntityTypeId()); + $controller = \Drupal::entityTypeManager()->getStorage($entity->getEntityTypeId()); $controller->resetCache(); $entities = $controller->loadMultiple(); foreach ($entities as $index => $entity) { diff --git a/core/modules/field/tests/src/Kernel/FieldCrudTest.php b/core/modules/field/tests/src/Kernel/FieldCrudTest.php index a61d645..83cd53a 100644 --- a/core/modules/field/tests/src/Kernel/FieldCrudTest.php +++ b/core/modules/field/tests/src/Kernel/FieldCrudTest.php @@ -108,7 +108,7 @@ function testCreateField() { // Test FieldConfigBase::setPropertyConstraints(). \Drupal::state()->set('field_test_set_constraint', $this->fieldStorage->getName()); \Drupal::state()->set('field_test_add_constraint', FALSE); - \Drupal::entityManager()->clearCachedFieldDefinitions(); + \Drupal::service('entity_field.manager')->clearCachedFieldDefinitions(); $this->doFieldValidationTests(); // Guarantee that the field/bundle combination is unique. @@ -155,7 +155,7 @@ public function testCreateFieldCustomStorage() { ]); $field->save(); - \Drupal::entityManager()->clearCachedFieldDefinitions(); + \Drupal::service('entity_field.manager')->clearCachedFieldDefinitions(); // Check that no table has been created for the field. $this->assertFalse(\Drupal::database()->schema()->tableExists('entity_test__' . $field_storage->getName())); diff --git a/core/modules/field/tests/src/Kernel/FieldDataCountTest.php b/core/modules/field/tests/src/Kernel/FieldDataCountTest.php index e0ea683..0556bce 100644 --- a/core/modules/field/tests/src/Kernel/FieldDataCountTest.php +++ b/core/modules/field/tests/src/Kernel/FieldDataCountTest.php @@ -38,9 +38,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'); } /** @@ -82,7 +82,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 b536fe8..c1c74ed 100644 --- a/core/modules/field/tests/src/Kernel/FieldImportDeleteTest.php +++ b/core/modules/field/tests/src/Kernel/FieldImportDeleteTest.php @@ -73,19 +73,19 @@ public function testImportDelete() { $this->configImporter()->import(); // Check that the field storages and fields are gone. - \Drupal::entityManager()->getStorage('field_storage_config')->resetCache(array($field_storage_id)); + \Drupal::entityTypeManager()->getStorage('field_storage_config')->resetCache(array($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(array($field_storage_id_2)); + \Drupal::entityTypeManager()->getStorage('field_storage_config')->resetCache(array($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(array($field_id)); + \Drupal::entityTypeManager()->getStorage('field_config')->resetCache(array($field_id)); $field = FieldConfig::load($field_id); $this->assertFalse($field, 'The field was deleted.'); - \Drupal::entityManager()->getStorage('field_config')->resetCache(array($field_id_2a)); + \Drupal::entityTypeManager()->getStorage('field_config')->resetCache(array($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(array($field_id_2b)); + \Drupal::entityTypeManager()->getStorage('field_config')->resetCache(array($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/FieldImportDeleteUninstallTest.php b/core/modules/field/tests/src/Kernel/FieldImportDeleteUninstallTest.php index 3e7f6ce..003129c 100644 --- a/core/modules/field/tests/src/Kernel/FieldImportDeleteUninstallTest.php +++ b/core/modules/field/tests/src/Kernel/FieldImportDeleteUninstallTest.php @@ -100,7 +100,7 @@ public function testImportDeleteUninstall() { $this->configImporter()->import(); $this->assertFalse(\Drupal::moduleHandler()->moduleExists('telephone')); - $this->assertFalse(\Drupal::entityManager()->loadEntityByUuid('field_storage_config', $field_storage->uuid()), 'The test field has been deleted by the configuration synchronization'); + $this->assertFalse(\Drupal::service('entity.repository')->loadEntityByUuid('field_storage_config', $field_storage->uuid()), 'The test field has been deleted by the configuration synchronization'); $deleted_storages = \Drupal::state()->get('field.storage.deleted') ?: array(); $this->assertFalse(isset($deleted_storages[$field_storage->uuid()]), 'Telephone field has been completed removed from the system.'); $this->assertTrue(isset($deleted_storages[$unrelated_field_storage->uuid()]), 'Unrelated field not purged by configuration synchronization.'); diff --git a/core/modules/field/tests/src/Kernel/FieldKernelTestBase.php b/core/modules/field/tests/src/Kernel/FieldKernelTestBase.php index a780895..0a818d0 100644 --- a/core/modules/field/tests/src/Kernel/FieldKernelTestBase.php +++ b/core/modules/field/tests/src/Kernel/FieldKernelTestBase.php @@ -53,7 +53,7 @@ protected function setUp() { $this->installConfig(array('field', 'system')); // Create user 1. - $storage = \Drupal::entityManager()->getStorage('user'); + $storage = \Drupal::entityTypeManager()->getStorage('user'); $storage ->create(array( 'uid' => 1, @@ -186,7 +186,7 @@ protected function _generateTestFieldValues($cardinality) { */ protected function assertFieldValues(EntityInterface $entity, $field_name, $expected_values, $langcode = LanguageInterface::LANGCODE_NOT_SPECIFIED, $column = 'value') { // Re-load the entity to make sure we have the latest changes. - \Drupal::entityManager()->getStorage($entity->getEntityTypeId())->resetCache(array($entity->id())); + \Drupal::entityTypeManager()->getStorage($entity->getEntityTypeId())->resetCache(array($entity->id())); $e = entity_load($entity->getEntityTypeId(), $entity->id()); $field = $values = $e->getTranslation($langcode)->$field_name; // Filter out empty values so that they don't mess with the assertions. diff --git a/core/modules/field/tests/src/Kernel/String/StringFormatterTest.php b/core/modules/field/tests/src/Kernel/String/StringFormatterTest.php index b52a92f..90ae249 100644 --- a/core/modules/field/tests/src/Kernel/String/StringFormatterTest.php +++ b/core/modules/field/tests/src/Kernel/String/StringFormatterTest.php @@ -146,7 +146,7 @@ public function testStringFormatter() { $value2 = $this->randomMachineName(); $entity->{$this->fieldName}->value = $value2; $entity->save(); - $entity_new_revision = \Drupal::entityManager()->getStorage('entity_test_rev')->loadRevision($old_revision_id); + $entity_new_revision = \Drupal::entityTypeManager()->getStorage('entity_test_rev')->loadRevision($old_revision_id); $this->renderEntityFields($entity, $this->display); $this->assertLink($value2, 0); diff --git a/core/modules/field/tests/src/Kernel/Timestamp/TimestampFormatterTest.php b/core/modules/field/tests/src/Kernel/Timestamp/TimestampFormatterTest.php index ee97cab..18d7a5e 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 78172a3..95906a1 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() { function testTranslatableFieldSaveLoad() { // Enable field translations for nodes. field_test_entity_info_translatable('node', TRUE); - $entity_type = \Drupal::entityManager()->getDefinition('node'); + $entity_type = \Drupal::entityTypeManager()->getDefinition('node'); $this->assertTrue($entity_type->isTranslatable(), 'Nodes are translatable.'); // Prepare the field translations. @@ -202,7 +202,7 @@ 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)); }