diff --git a/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php b/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php index 22cf527..d3bca5f 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php @@ -11,7 +11,6 @@ use Drupal\Core\Entity\Query\QueryInterface; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Language\Language; -use Drupal\field\FieldInfo; use Drupal\field\FieldConfigUpdateForbiddenException; use Drupal\field\FieldConfigInterface; use Drupal\field\FieldInstanceConfigInterface; @@ -73,11 +72,11 @@ class ContentEntityDatabaseStorage extends ContentEntityStorageBase { protected $database; /** - * The field info object. + * The entity manager. * - * @var \Drupal\field\FieldInfo + * @var \Drupal\Core\Entity\EntityManagerInterface */ - protected $fieldInfo; + protected $entityManager; /** * {@inheritdoc} @@ -86,7 +85,7 @@ public static function createInstance(ContainerInterface $container, EntityTypeI return new static( $entity_type, $container->get('database'), - $container->get('field.info') + $container->get('entity.manager') ); } @@ -97,14 +96,14 @@ public static function createInstance(ContainerInterface $container, EntityTypeI * The entity type definition. * @param \Drupal\Core\Database\Connection $database * The database connection to be used. - * @param \Drupal\field\FieldInfo $field_info - * The field info service. + * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager + * The entity manager. */ - public function __construct(EntityTypeInterface $entity_type, Connection $database, FieldInfo $field_info) { + public function __construct(EntityTypeInterface $entity_type, Connection $database, EntityManagerInterface $entity_manager) { parent::__construct($entity_type); $this->database = $database; - $this->fieldInfo = $field_info; + $this->entityManager = $entity_manager; // Check if the entity type supports IDs. if ($this->entityType->hasKey('id')) { @@ -791,8 +790,10 @@ protected function doLoadFieldItems($entities, $age) { // Collect impacted fields. $fields = array(); foreach ($bundles as $bundle => $v) { - foreach ($this->fieldInfo->getBundleInstances($this->entityTypeId, $bundle) as $field_name => $instance) { - $fields[$field_name] = $instance->getField(); + foreach ($this->entityManager->getFieldDefinitions($this->entityTypeId, $bundle) as $field_name => $instance) { + if ($instance instanceof FieldInstanceConfigInterface) { + $fields[$field_name] = $instance->getField(); + } } } @@ -856,7 +857,10 @@ protected function doSaveFieldItems(EntityInterface $entity, $update) { $vid = $id; } - foreach ($this->fieldInfo->getBundleInstances($entity_type, $bundle) as $field_name => $instance) { + foreach ($this->entityManager->getFieldDefinitions($entity_type, $bundle) as $field_name => $instance) { + if (!($instance instanceof FieldInstanceConfigInterface)) { + continue; + } $field = $instance->getField(); $table_name = static::_fieldTableName($field); $revision_name = static::_fieldRevisionTableName($field); @@ -930,7 +934,10 @@ protected function doSaveFieldItems(EntityInterface $entity, $update) { * {@inheritdoc} */ protected function doDeleteFieldItems(EntityInterface $entity) { - foreach ($this->fieldInfo->getBundleInstances($entity->getEntityTypeId(), $entity->bundle()) as $instance) { + foreach ($this->entityManager->getFieldDefinitions($entity->getEntityTypeId(), $entity->bundle()) as $instance) { + if (!($instance instanceof FieldInstanceConfigInterface)) { + continue; + } $field = $instance->getField(); $table_name = static::_fieldTableName($field); $revision_name = static::_fieldRevisionTableName($field); @@ -949,7 +956,10 @@ protected function doDeleteFieldItems(EntityInterface $entity) { protected function doDeleteFieldItemsRevision(EntityInterface $entity) { $vid = $entity->getRevisionId(); if (isset($vid)) { - foreach ($this->fieldInfo->getBundleInstances($entity->getEntityTypeId(), $entity->bundle()) as $instance) { + foreach ($this->entityManager->getFieldDefinitions($entity->getEntityTypeId(), $entity->bundle()) as $instance) { + if (!($instance instanceof FieldInstanceConfigInterface)) { + continue; + } $revision_name = static::_fieldRevisionTableName($instance->getField()); $this->database->delete($revision_name) ->condition('entity_id', $entity->id()) diff --git a/core/lib/Drupal/Core/Entity/EntityDatabaseStorage.php b/core/lib/Drupal/Core/Entity/EntityDatabaseStorage.php index c25ff56..75fa16a 100644 --- a/core/lib/Drupal/Core/Entity/EntityDatabaseStorage.php +++ b/core/lib/Drupal/Core/Entity/EntityDatabaseStorage.php @@ -9,16 +9,7 @@ use Drupal\Component\Uuid\UuidInterface; use Drupal\Core\Database\Connection; -use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Entity\Query\QueryInterface; -use Drupal\Core\Language\Language; -use Drupal\Component\Utility\NestedArray; -use Drupal\Component\Uuid\Uuid; -use Drupal\field\FieldInfo; -use Drupal\field\FieldConfigUpdateForbiddenException; -use Drupal\field\FieldConfigInterface; -use Drupal\field\FieldInstanceConfigInterface; -use Drupal\field\Entity\FieldConfig; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -50,13 +41,6 @@ class EntityDatabaseStorage extends EntityStorageBase { protected $database; /** - * The field info object. - * - * @var \Drupal\field\FieldInfo - */ - protected $fieldInfo; - - /** * {@inheritdoc} */ public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) { diff --git a/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php b/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php index ee2bebc..9aafd97 100644 --- a/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php +++ b/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php @@ -8,12 +8,12 @@ namespace Drupal\Core\Entity\Query\Sql; use Drupal\Core\Database\Query\SelectInterface; +use Drupal\Core\Entity\ContentEntityTypeInterface; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\ContentEntityDatabaseStorage; -use Drupal\Core\Entity\Plugin\DataType\EntityReference; use Drupal\Core\Entity\Query\QueryException; use Drupal\field\Entity\FieldConfig; -use Drupal\field\Field as FieldInfo; +use Drupal\field\FieldConfigInterface; /** * Adds tables and fields to the SQL entity query. @@ -58,7 +58,6 @@ public function __construct(SelectInterface $sql_query) { public function addField($field, $type, $langcode) { $entity_type_id = $this->sqlQuery->getMetaData('entity_type'); $entity_manager = \Drupal::entityManager(); - $field_info = FieldInfo::fieldInfo(); $age = $this->sqlQuery->getMetaData('age'); // This variable ensures grouping works correctly. For example: // ->condition('tags', 2, '>') @@ -75,11 +74,12 @@ public function addField($field, $type, $langcode) { // system. $propertyDefinitions = array(); $entity_type = $entity_manager->getDefinition($entity_type_id); - // Use the lightweight and fast field map for checking whether a specifier - // is a field or not. While calling field_info_field() on every specifier - // delivers the same information, if no specifiers are using the field API - // it is much faster if field_info_field() is never called. - $field_map = $field_info->getFieldMap(); + + $storage_fields = array(); + // @todo Needed for menu links. + if ($entity_type instanceof ContentEntityTypeInterface) { + $storage_fields = $entity_manager->getFieldStorageDefinitions($entity_type_id); + } for ($key = 0; $key <= $count; $key ++) { // If there is revision support and only the current revision is being // queried then use the revision id. Otherwise, the entity id will do. @@ -95,25 +95,25 @@ public function addField($field, $type, $langcode) { $entity_id_field = $entity_type->getKey('id'); $field_id_field = 'entity_id'; } - // This can either be the name of an entity property (non-configurable - // field), a field API field (a configurable field). + // This can either be the name of an entity base field or a configurable + // field. $specifier = $specifiers[$key]; - // First, check for field API fields by trying to retrieve the field specified. // Normally it is a field name, but field_purge_batch() is passing in // id:$field_id so check that first. + /* @var \Drupal\Core\Field\FieldDefinitionInterface $field */ if (substr($specifier, 0, 3) == 'id:') { - $field = $field_info->getFieldById((substr($specifier, 3))); + $field = entity_load_by_uuid('field_config', substr($specifier, 3)); } - elseif (isset($field_map[$entity_type_id][$specifier])) { - $field = $field_info->getField($entity_type_id, $specifier); + elseif (isset($storage_fields[$specifier])) { + $field = $storage_fields[$specifier]; } else { $field = FALSE; } - // If we managed to retrieve the field, process it. - if ($field) { + // If we managed to retrieve a configurable field, process it. + if ($field instanceof FieldConfigInterface) { // Find the field column. - $column = FALSE; + $column = $field->getMainPropertyName(); if ($key < $count) { $next = $specifiers[$key + 1]; // Is this a field column? @@ -133,39 +133,16 @@ public function addField($field, $type, $langcode) { // also use the property definitions for column. if ($key < $count) { $relationship_specifier = $specifiers[$key + 1]; + $propertyDefinitions = $field->getPropertyDefinitions(); - // Get the field definitions form a mocked entity. - $values = array(); - $field_name = $field->getName(); - // If there are bundles, pick one. - if ($bundle_key = $entity_type->getKey('bundle')) { - $values[$bundle_key] = reset($field_map[$entity_type_id][$field_name]['bundles']); - } - $entity = $entity_manager - ->getStorage($entity_type_id) - ->create($values); - $propertyDefinitions = $entity->$field_name->getFieldDefinition()->getPropertyDefinitions(); - - // If the column is not yet known, ie. the - // $node->field_image->entity case then use first property as - // column, i.e. target_id or fid. - // Otherwise, the code executing the relationship will throw an - // exception anyways so no need to do it here. - if (!$column && isset($propertyDefinitions[$relationship_specifier]) && $entity->{$field->getName()}->first()->get('entity') instanceof EntityReference) { - $column = current(array_keys($propertyDefinitions)); - } // Prepare the next index prefix. $next_index_prefix = "$relationship_specifier.$column"; } } - else { - // If this is the last specifier, default to value. - $column = 'value'; - } $table = $this->ensureFieldTable($index_prefix, $field, $type, $langcode, $base_table, $entity_id_field, $field_id_field); $sql_column = ContentEntityDatabaseStorage::_fieldColumnName($field, $column); } - // This is an entity property (non-configurable field). + // This is an entity base field (non-configurable field). else { // ensureEntityTable() decides whether an entity property will be // queried from the data table or the base table based on where it @@ -182,31 +159,20 @@ public function addField($field, $type, $langcode) { $table = $this->ensureEntityTable($index_prefix, $specifier, $type, $langcode, $base_table, $entity_id_field, $entity_tables); } // If there are more specifiers to come, it's a relationship. - if ($key < $count) { + if ($field && $key < $count) { // Computed fields have prepared their property definition already, do // it for properties as well. if (!$propertyDefinitions) { - // Create a relevant entity to find the definition for this - // property. - $values = array(); - // If there are bundles, pick one. It does not matter which, - // properties exist on all bundles. - if ($bundle_key = $entity_type->getKey('bundle')) { - $bundles = entity_get_bundles($entity_type_id); - $values[$bundle_key] = key($bundles); - } - $entity = $entity_manager - ->getStorage($entity_type_id) - ->create($values); - $propertyDefinitions = $entity->$specifier->getFieldDefinition()->getPropertyDefinitions(); + $propertyDefinitions = $field->getPropertyDefinitions(); $relationship_specifier = $specifiers[$key + 1]; $next_index_prefix = $relationship_specifier; } // Check for a valid relationship. - if (isset($propertyDefinitions[$relationship_specifier]) && $entity->get($specifier)->first()->get('entity') instanceof EntityReference) { + if (isset($propertyDefinitions[$relationship_specifier]) && $field->getPropertyDefinition('entity')->getDataType() == 'entity_reference' ) { // If it is, use the entity type. $entity_type_id = $propertyDefinitions[$relationship_specifier]->getTargetDefinition()->getEntityTypeId(); $entity_type = $entity_manager->getDefinition($entity_type_id); + $storage_fields = $entity_manager->getFieldStorageDefinitions($entity_type_id); // Add the new entity base table using the table and sql column. $join_condition= '%alias.' . $entity_type->getKey('id') . " = $table.$sql_column"; $base_table = $this->sqlQuery->leftJoin($entity_type->getBaseTable(), NULL, $join_condition); diff --git a/core/modules/comment/lib/Drupal/comment/CommentFormController.php b/core/modules/comment/lib/Drupal/comment/CommentFormController.php index b08e787..dfc0691 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentFormController.php +++ b/core/modules/comment/lib/Drupal/comment/CommentFormController.php @@ -16,7 +16,6 @@ use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Language\Language; use Drupal\Core\Session\AccountInterface; -use Drupal\field\FieldInfo; use Symfony\Component\DependencyInjection\ContainerInterface; /** diff --git a/core/modules/comment/lib/Drupal/comment/CommentStorage.php b/core/modules/comment/lib/Drupal/comment/CommentStorage.php index d05b2c3..6343587 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentStorage.php +++ b/core/modules/comment/lib/Drupal/comment/CommentStorage.php @@ -9,9 +9,9 @@ use Drupal\Core\Database\Connection; use Drupal\Core\Entity\EntityInterface; +use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Entity\ContentEntityDatabaseStorage; -use Drupal\field\FieldInfo; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -36,13 +36,13 @@ class CommentStorage extends ContentEntityDatabaseStorage implements CommentStor * An array of entity info for the entity type. * @param \Drupal\Core\Database\Connection $database * The database connection to be used. - * @param \Drupal\field\FieldInfo $field_info - * The field info service. + * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager + * The entity manager. * @param \Drupal\comment\CommentStatisticsInterface $comment_statistics * The comment statistics service. */ - public function __construct(EntityTypeInterface $entity_info, Connection $database, FieldInfo $field_info, CommentStatisticsInterface $comment_statistics) { - parent::__construct($entity_info, $database, $field_info); + public function __construct(EntityTypeInterface $entity_info, Connection $database, EntityManagerInterface $entity_manager, CommentStatisticsInterface $comment_statistics) { + parent::__construct($entity_info, $database, $entity_manager); $this->statistics = $comment_statistics; } @@ -53,7 +53,7 @@ public static function createInstance(ContainerInterface $container, EntityTypeI return new static( $entity_info, $container->get('database'), - $container->get('field.info'), + $container->get('entity.manager'), $container->get('comment.statistics') ); } diff --git a/core/modules/comment/lib/Drupal/comment/CommentViewBuilder.php b/core/modules/comment/lib/Drupal/comment/CommentViewBuilder.php index b6b7bb3..ad6f522 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentViewBuilder.php +++ b/core/modules/comment/lib/Drupal/comment/CommentViewBuilder.php @@ -15,7 +15,6 @@ use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Entity\EntityViewBuilder; use Drupal\Core\Language\LanguageManagerInterface; -use Drupal\field\FieldInfo; use Symfony\Component\DependencyInjection\ContainerInterface; /** diff --git a/core/modules/comment/lib/Drupal/comment/Controller/AdminController.php b/core/modules/comment/lib/Drupal/comment/Controller/AdminController.php index d2196b8..b92b396 100644 --- a/core/modules/comment/lib/Drupal/comment/Controller/AdminController.php +++ b/core/modules/comment/lib/Drupal/comment/Controller/AdminController.php @@ -9,7 +9,6 @@ use Drupal\comment\CommentManagerInterface; use Drupal\field\FieldConfigInterface; -use Drupal\field\FieldInfo; use Drupal\Component\Utility\String; use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Form\FormBuilderInterface; diff --git a/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php b/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php index abd7cd1..78eb686 100644 --- a/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php +++ b/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php @@ -10,7 +10,6 @@ use Drupal\comment\CommentInterface; use Drupal\comment\CommentManagerInterface; use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; -use Drupal\field\FieldInfo; use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Entity\EntityInterface; use Symfony\Component\DependencyInjection\ContainerInterface; diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentFieldsTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentFieldsTest.php index 24a20a9..86172a1 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentFieldsTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentFieldsTest.php @@ -7,7 +7,6 @@ namespace Drupal\comment\Tests; -use Drupal\field\Field; use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; /** diff --git a/core/modules/config_translation/lib/Drupal/config_translation/Controller/ConfigTranslationFieldInstanceListBuilder.php b/core/modules/config_translation/lib/Drupal/config_translation/Controller/ConfigTranslationFieldInstanceListBuilder.php index 2033d88..ff569d3 100644 --- a/core/modules/config_translation/lib/Drupal/config_translation/Controller/ConfigTranslationFieldInstanceListBuilder.php +++ b/core/modules/config_translation/lib/Drupal/config_translation/Controller/ConfigTranslationFieldInstanceListBuilder.php @@ -13,7 +13,6 @@ use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityTypeInterface; -use Drupal\field\Field; use Symfony\Component\DependencyInjection\ContainerInterface; /** diff --git a/core/modules/content_translation/content_translation.admin.inc b/core/modules/content_translation/content_translation.admin.inc index 557f06e..eb03aea 100644 --- a/core/modules/content_translation/content_translation.admin.inc +++ b/core/modules/content_translation/content_translation.admin.inc @@ -9,7 +9,7 @@ use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Language\Language; use Drupal\Core\Render\Element; -use Drupal\field\Field as FieldService; +use Drupal\field\Entity\FieldConfig; use Drupal\field\FieldInstanceConfigInterface; /** @@ -348,7 +348,7 @@ function _content_translation_update_field_translatability($settings) { foreach ($bundle_settings['fields'] as $field_name => $translatable) { // If translatability changes for at least one field instance we need // to switch field translatability. - $field = FieldService::fieldInfo()->getField($entity_type, $field_name); + $field = FieldConfig::loadByName($entity_type, $field_name); if ($field && $field->isTranslatable() !== $translatable) { $fields[$field_name] = $translatable; } @@ -357,7 +357,7 @@ function _content_translation_update_field_translatability($settings) { } // Store updated fields. foreach ($fields as $field_name => $translatable) { - $field = FieldService::fieldInfo()->getField($entity_type, $field_name); + $field = FieldConfig::loadByName($entity_type, $field_name); $field->translatable = $translatable; $field->save(); } diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSettingsTest.php b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSettingsTest.php index 509fd0b..059cb79 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSettingsTest.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSettingsTest.php @@ -9,7 +9,6 @@ use Drupal\Core\Language\Language; use Drupal\field\Entity\FieldConfig; -use Drupal\field\Field as FieldService; use Drupal\simpletest\WebTestBase; /** @@ -135,7 +134,7 @@ function testSettingsUI() { // Test that configurable field translatability is correctly switched. $edit = array('settings[node][article][fields][body]' => $translatable); $this->assertSettings('node', 'article', TRUE, $edit); - $field = FieldService::fieldInfo()->getField('node', 'body'); + $field = FieldConfig::loadByName('node', 'body'); $definitions = \Drupal::entityManager()->getFieldDefinitions('node', 'article'); $this->assertEqual($definitions['body']->isTranslatable(), $translatable, 'Field translatability correctly switched.'); $this->assertEqual($field->isTranslatable(), $definitions['body']->isTranslatable(), 'Configurable field translatability correctly switched.'); @@ -146,7 +145,7 @@ function testSettingsUI() { $this->drupalPostForm('admin/structure/types/manage/article/fields/node.article.body/field', $edit, t('Save field settings')); field_info_cache_clear(); entity_info_cache_clear(); - $field = FieldService::fieldInfo()->getField('node', 'body'); + $field = FieldConfig::loadByName('node', 'body'); $definitions = \Drupal::entityManager()->getFieldDefinitions('node', 'article'); $this->assertEqual($definitions['body']->isTranslatable(), $translatable, 'Field translatability correctly switched.'); $this->assertEqual($field->isTranslatable(), $definitions['body']->isTranslatable(), 'Configurable field translatability correctly switched.'); diff --git a/core/modules/edit/lib/Drupal/edit/EditController.php b/core/modules/edit/lib/Drupal/edit/EditController.php index b129d97..50940e1 100644 --- a/core/modules/edit/lib/Drupal/edit/EditController.php +++ b/core/modules/edit/lib/Drupal/edit/EditController.php @@ -14,7 +14,6 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Drupal\Core\Ajax\AjaxResponse; use Drupal\Core\Entity\EntityInterface; -use Drupal\field\FieldInfo; use Drupal\edit\Ajax\FieldFormCommand; use Drupal\edit\Ajax\FieldFormSavedCommand; use Drupal\edit\Ajax\FieldFormValidationErrorsCommand; diff --git a/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php b/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php index a5a9b15..43370fe 100644 --- a/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php +++ b/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php @@ -12,7 +12,6 @@ use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Entity\Display\EntityDisplayInterface; use Drupal\field\Entity\FieldInstanceConfig; -use Drupal\field\Field; /** * Provides a common base class for entity view and form displays. diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceFieldTest.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceFieldTest.php index 9dd19fc..bde0b2c 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceFieldTest.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceFieldTest.php @@ -10,7 +10,6 @@ use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldInstanceConfig; use Drupal\system\Tests\Entity\EntityUnitTestBase; -use Drupal\field\Field; /** * Tests for the entity reference field. diff --git a/core/modules/field/field.module b/core/modules/field/field.module index 75473e2..5473182 100644 --- a/core/modules/field/field.module +++ b/core/modules/field/field.module @@ -8,7 +8,6 @@ use Drupal\Component\Utility\Xss; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Extension\Extension; -use Drupal\field\Field; /* * Load all public Field API functions. Drupal currently has no diff --git a/core/modules/field/lib/Drupal/field/Entity/FieldInstanceConfig.php b/core/modules/field/lib/Drupal/field/Entity/FieldInstanceConfig.php index d1c3f26..b249b68 100644 --- a/core/modules/field/lib/Drupal/field/Entity/FieldInstanceConfig.php +++ b/core/modules/field/lib/Drupal/field/Entity/FieldInstanceConfig.php @@ -12,7 +12,6 @@ use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Field\FieldDefinition; use Drupal\Core\Field\TypedData\FieldItemDataDefinition; -use Drupal\field\Field; use Drupal\field\FieldException; use Drupal\field\FieldInstanceConfigInterface; diff --git a/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php b/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php index 1428cfd..39389dd 100644 --- a/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php +++ b/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php @@ -13,7 +13,6 @@ use Drupal\Core\Field\FieldDefinition; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Render\Element; -use Drupal\field\Field as FieldHelper; use Drupal\Core\Entity\ContentEntityDatabaseStorage; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FormatterPluginManager; @@ -146,7 +145,8 @@ public static function create(ContainerInterface $container, array $configuratio public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) { parent::init($view, $display, $options); - $field_storage_definition = FieldHelper::fieldInfo()->getField($this->definition['entity_type'], $this->definition['field_name']); + + $field_storage_definition = \Drupal::entityManager()->getFieldStorageDefinitions($this->definition['entity_type'])[$this->definition['field_name']]; $this->field_info = FieldDefinition::createFromFieldStorageDefinition($field_storage_definition); $this->multiple = FALSE; $this->limit_values = FALSE; diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php index 24b3786..73a6488 100644 --- a/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php @@ -335,7 +335,7 @@ function testEntityCreateRenameBundle() { entity_test_rename_bundle($this->instance_definition['bundle'], $new_bundle, $entity_type); // Check that the instance definition has been updated. - $this->instance = FieldInstanceConfig::loadByName($entity_type, $bundle, $field->name); + $this->instance = FieldInstanceConfig::loadByName($entity_type, $new_bundle, $this->field_name); $this->assertIdentical($this->instance->bundle, $new_bundle, "Bundle name has been updated in the instance."); // Verify the field data is present on load. diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldImportCreateTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldImportCreateTest.php index e7faf06..7a1c4fb 100644 --- a/core/modules/field/lib/Drupal/field/Tests/FieldImportCreateTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/FieldImportCreateTest.php @@ -7,8 +7,6 @@ namespace Drupal\field\Tests; -use Drupal\field\Field; - /** * Tests creating fields and instances as part of config import. */ @@ -66,14 +64,14 @@ function testImportCreateDefault() { ->condition('bundle', 'entity_test') ->execute(); $this->assertEqual(count($ids), 2); - $this->assertTrue(in_array('field_test_import', $ids)); - $this->assertTrue(in_array('field_test_import_2', $ids)); + $this->assertTrue(isset($ids['entity_test.entity_test.field_test_import'])); + $this->assertTrue(isset($ids['entity_test.entity_test.field_test_import_2'])); $ids = \Drupal::entityQuery('field_instance_config') ->condition('entity_type', 'entity_test') - ->condition('bundle', 'entity_test') + ->condition('bundle', 'test_bundle') ->execute(); $this->assertEqual(count($ids), 1); - $this->assertTrue(in_array('field_test_import_2', $ids)); + $this->assertTrue(isset($ids['entity_test.test_bundle.field_test_import_2'])); } /** diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldEditForm.php b/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldEditForm.php index a5c6cc9..b526c02 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldEditForm.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldEditForm.php @@ -10,7 +10,6 @@ use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Form\FormBase; use Drupal\Core\TypedData\TypedDataManager; -use Drupal\field\FieldInfo; use Drupal\field\FieldInstanceConfigInterface; use Drupal\field_ui\FieldUI; use Symfony\Component\DependencyInjection\ContainerInterface; diff --git a/core/modules/file/lib/Drupal/file/Plugin/Field/FieldWidget/FileWidget.php b/core/modules/file/lib/Drupal/file/Plugin/Field/FieldWidget/FileWidget.php index 0c46256..6be495c 100644 --- a/core/modules/file/lib/Drupal/file/Plugin/Field/FieldWidget/FileWidget.php +++ b/core/modules/file/lib/Drupal/file/Plugin/Field/FieldWidget/FileWidget.php @@ -12,7 +12,6 @@ use Drupal\Core\Field\FieldItemListInterface; use Drupal\Component\Utility\NestedArray; use Drupal\Core\Render\Element; -use Drupal\field\Field; /** * Plugin implementation of the 'file_generic' widget. @@ -311,7 +310,7 @@ public static function validateMultipleCount($element, &$form_state, $form) { array_pop($parents); $current = count(Element::children(NestedArray::getValue($form, $parents))) - 1; - $field = \Drupal::entityManager()->getFieldStorageDefinitions($element['#element_type'])[$element['#field_name']]; + $field = \Drupal::entityManager()->getFieldStorageDefinitions($element['#entity_type'])[$element['#field_name']]; $uploaded = count($values['fids']); $count = $uploaded + $current; if ($count > $field->getCardinality()) { diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldValidateTest.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldValidateTest.php index 1eb9088..d35a491 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileFieldValidateTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldValidateTest.php @@ -9,7 +9,6 @@ use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\field\Entity\FieldInstanceConfig; -use Drupal\field\Field; /** * Tests various validations. diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module index 8f0c57d..ae2f9a8 100644 --- a/core/modules/forum/forum.module +++ b/core/modules/forum/forum.module @@ -10,7 +10,6 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Component\Utility\String; use Drupal\field\Entity\FieldConfig; -use Drupal\field\Field; /** * Implements hook_help(). diff --git a/core/modules/forum/lib/Drupal/forum/ForumManager.php b/core/modules/forum/lib/Drupal/forum/ForumManager.php index 64d0957..85692ab 100644 --- a/core/modules/forum/lib/Drupal/forum/ForumManager.php +++ b/core/modules/forum/lib/Drupal/forum/ForumManager.php @@ -14,7 +14,6 @@ use Drupal\Core\Session\AccountInterface; use Drupal\Core\StringTranslation\TranslationInterface; use Drupal\comment\CommentInterface; -use Drupal\field\FieldInfo; use Drupal\node\NodeInterface; /** diff --git a/core/modules/migrate/lib/Drupal/migrate/Plugin/MigrateEntityDestinationFieldInterface.php b/core/modules/migrate/lib/Drupal/migrate/Plugin/MigrateEntityDestinationFieldInterface.php index 0fe3b86..4cefa2f 100644 --- a/core/modules/migrate/lib/Drupal/migrate/Plugin/MigrateEntityDestinationFieldInterface.php +++ b/core/modules/migrate/lib/Drupal/migrate/Plugin/MigrateEntityDestinationFieldInterface.php @@ -6,7 +6,7 @@ namespace Drupal\migrate\Plugin; -use Drupal\field\Entity\FieldInstance; +use Drupal\Core\Field\FieldDefinitionInterface; /** * Handle the importing of a specific configurable field type. @@ -16,14 +16,15 @@ /** * Convert an array of values into an array structure fit for entity_create. * - * @param \Drupal\field\Entity\FieldInstance $instance - * The field instance. For example, this can be used to check for required. + * @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition + * The field definition. For example, this can be used to check for + * required values. * @param array $values * The array of values. * @return array|NULL * This will be set in the $values array passed to entity_create() as the * value of a configurable field of the type this class handles. */ - public function import(FieldInstance $instance, array $values = NULL); + public function import(FieldDefinitionInterface $field_definition, array $values = NULL); } diff --git a/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/destination/EntityComment.php b/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/destination/EntityComment.php index cd3b11e..885a6ea 100644 --- a/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/destination/EntityComment.php +++ b/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/destination/EntityComment.php @@ -9,7 +9,6 @@ use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\KeyValueStore\StateInterface; -use Drupal\field\FieldInfo; use Drupal\migrate\Entity\MigrationInterface; use Drupal\migrate\Plugin\MigratePluginManager; use Drupal\migrate\Row; @@ -46,13 +45,13 @@ class EntityComment extends EntityContentBase { * The list of bundles this entity type has. * @param \Drupal\migrate\Plugin\MigratePluginManager $plugin_manager * The migrate plugin manager. - * @param \Drupal\field\FieldInfo $field_info + * @param \Drupal\field\FieldInfo $entity_manager * The field and instance definitions service. - * @param \Drupal\Core\KeyValueStore\StateInterface $state - * The state storage object. + * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager + * The entity manager service. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, MigratePluginManager $plugin_manager, FieldInfo $field_info, StateInterface $state) { - parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $storage, $bundles, $plugin_manager, $field_info); + public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, MigratePluginManager $plugin_manager, FieldInfo $entity_manager, StateInterface $state) { + parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $storage, $bundles, $plugin_manager, $entity_manager); $this->state = $state; } @@ -69,7 +68,7 @@ public static function create(ContainerInterface $container, array $configuratio $container->get('entity.manager')->getStorage($entity_type), array_keys($container->get('entity.manager')->getBundleInfo($entity_type)), $container->get('plugin.manager.migrate.entity_field'), - $container->get('field.info'), + $container->get('entity.manager'), $container->get('state') ); } diff --git a/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/destination/EntityContentBase.php b/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/destination/EntityContentBase.php index 8692947..f73bf10 100644 --- a/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/destination/EntityContentBase.php +++ b/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/destination/EntityContentBase.php @@ -9,9 +9,9 @@ use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\EntityInterface; +use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\TypedData\TypedDataInterface; -use Drupal\field\FieldInfo; use Drupal\migrate\Entity\MigrationInterface; use Drupal\migrate\Plugin\MigratePluginManager; use Drupal\migrate\Row; @@ -23,9 +23,11 @@ class EntityContentBase extends Entity { /** - * @var \Drupal\field\FieldInfo + * Entity manager. + * + * @var \Drupal\Core\Entity\EntityManagerInterface */ - protected $fieldInfo; + protected $entityManager; /** * Constructs a content entity. @@ -44,13 +46,13 @@ class EntityContentBase extends Entity { * The list of bundles this entity type has. * @param \Drupal\migrate\Plugin\MigratePluginManager $plugin_manager * The plugin manager. - * @param \Drupal\Field\FieldInfo $field_info - * The field info. + * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager + * The entity manager service. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, MigratePluginManager $plugin_manager, FieldInfo $field_info) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, MigratePluginManager $plugin_manager, EntityManagerInterface $entity_manager) { parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $storage, $bundles); $this->migrateEntityFieldPluginManager = $plugin_manager; - $this->fieldInfo = $field_info; + $this->entityManager = $entity_manager; } /** @@ -66,7 +68,7 @@ public static function create(ContainerInterface $container, array $configuratio $container->get('entity.manager')->getStorage($entity_type), array_keys($container->get('entity.manager')->getBundleInfo($entity_type)), $container->get('plugin.manager.migrate.entity_field'), - $container->get('field.info') + $container->get('entity.manager') ); } @@ -74,23 +76,20 @@ public static function create(ContainerInterface $container, array $configuratio * {@inheritdoc} */ public function import(Row $row, array $old_destination_id_values = array()) { - if ($all_instances = $this->fieldInfo->getInstances($this->storage->getEntityTypeId())) { - /** @var \Drupal\Field\Entity\FieldInstanceConfig[] $instances */ - $instances = array(); - if ($bundle_key = $this->getKey('bundle')) { - $bundle = $row->getDestinationProperty($bundle_key); - if (isset($all_instances[$bundle])) { - $instances = $all_instances[$bundle]; - } - } - foreach ($instances as $field_name => $instance) { - $field_type = $instance->getType(); - if ($this->migrateEntityFieldPluginManager->getDefinition($field_type)) { - $destination_value = $this->migrateEntityFieldPluginManager->createInstance($field_type)->import($instance, $row->getDestinationProperty($field_name)); - // @TODO: check for NULL return? Add an unset to $row? Maybe needed in - // exception handling? Propagate exception? - $row->setDestinationProperty($field_name, $destination_value); - } + if ($bundle_key = $this->getKey('bundle')) { + $bundle = $row->getDestinationProperty($bundle_key); + } + else { + $bundle = $this->storage->getEntityTypeId(); + } + $field_definitions = $this->entityManager->getFieldDefinitions($this->storage->getEntityTypeId(), $bundle); + foreach ($field_definitions as $field_name => $field_definition) { + $field_type = $field_definition->getType(); + if ($this->migrateEntityFieldPluginManager->getDefinition($field_type)) { + $destination_value = $this->migrateEntityFieldPluginManager->createInstance($field_type)->import($field_definition, $row->getDestinationProperty($field_name)); + // @TODO: check for NULL return? Add an unset to $row? Maybe needed in + // exception handling? Propagate exception? + $row->setDestinationProperty($field_name, $destination_value); } } $entity = $this->getEntity($row, $old_destination_id_values); diff --git a/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/destination/EntityFile.php b/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/destination/EntityFile.php index 6ae4f30..6703f56 100644 --- a/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/destination/EntityFile.php +++ b/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/destination/EntityFile.php @@ -7,8 +7,8 @@ namespace Drupal\migrate\Plugin\migrate\destination; +use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityStorageInterface; -use Drupal\field\FieldInfo; use Drupal\migrate\Entity\MigrationInterface; use Drupal\migrate\Plugin\MigratePluginManager; use Drupal\migrate\Row; @@ -23,14 +23,14 @@ class EntityFile extends EntityContentBase { /** * {@inheritdoc} */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, MigratePluginManager $plugin_manager, FieldInfo $field_info) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, MigratePluginManager $plugin_manager, EntityManagerInterface $entity_manager) { $configuration += array( 'source_base_path' => '', 'source_path_property' => 'filepath', 'destination_path_property' => 'uri', 'move' => FALSE, ); - parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $storage, $bundles, $plugin_manager, $field_info); + parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $storage, $bundles, $plugin_manager, $entity_manager); } /** diff --git a/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/destination/EntityUser.php b/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/destination/EntityUser.php index f8495ba..5cdcfc6 100644 --- a/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/destination/EntityUser.php +++ b/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/destination/EntityUser.php @@ -7,9 +7,9 @@ namespace Drupal\migrate\Plugin\migrate\destination; +use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Password\PasswordInterface; -use Drupal\field\FieldInfo; use Drupal\migrate\Entity\MigrationInterface; use Drupal\migrate\MigrateException; use Drupal\migrate\MigratePassword; @@ -48,13 +48,13 @@ class EntityUser extends EntityContentBase { * The list of bundles this entity type has. * @param \Drupal\migrate\Plugin\MigratePluginManager $plugin_manager * The migrate plugin manager. - * @param \Drupal\field\FieldInfo $field_info - * The field and instance definitions service. + * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager + * The entity manager service. * @param \Drupal\Core\Password\PasswordInterface $password * The password service. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, MigratePluginManager $plugin_manager, FieldInfo $field_info, PasswordInterface $password) { - parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $storage, $bundles, $plugin_manager, $field_info); + public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, MigratePluginManager $plugin_manager, EntityManagerInterface $entity_manager, PasswordInterface $password) { + parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $storage, $bundles, $plugin_manager, $entity_manager); if (isset($configuration['md5_passwords'])) { $this->password = $password; } @@ -73,7 +73,7 @@ public static function create(ContainerInterface $container, array $configuratio $container->get('entity.manager')->getStorage($entity_type), array_keys($container->get('entity.manager')->getBundleInfo($entity_type)), $container->get('plugin.manager.migrate.entity_field'), - $container->get('field.info'), + $container->get('entity.manager'), $container->get('password') ); } diff --git a/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php b/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php index 80aaa09..1ffb010 100644 --- a/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php +++ b/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php @@ -8,7 +8,6 @@ namespace Drupal\path\Tests; use Drupal\field\Entity\FieldConfig; -use Drupal\field\Field; /** * Tests URL aliases for translated nodes. diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchCommentTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchCommentTest.php index 25c35b6..b18290d 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchCommentTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchCommentTest.php @@ -9,7 +9,6 @@ use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; use Drupal\field\Entity\FieldInstanceConfig; -use Drupal\field\Field; /** * Test integration searching comments. diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchLanguageTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchLanguageTest.php index 3e9c5f8..6897ba3 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchLanguageTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchLanguageTest.php @@ -9,7 +9,6 @@ use Drupal\Core\Language\Language; use Drupal\field\Entity\FieldConfig; -use Drupal\field\Field; /** * Test node search with multiple languages. diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchMultilingualEntityTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchMultilingualEntityTest.php index e597679..0629f7f 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchMultilingualEntityTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchMultilingualEntityTest.php @@ -9,7 +9,6 @@ use Drupal\Core\Language\Language; use Drupal\field\Entity\FieldConfig; -use Drupal\field\Field; /** * Tests entities with multilingual fields. diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityLanguageTestBase.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityLanguageTestBase.php index bd2ceb9..ada2fbd 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityLanguageTestBase.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityLanguageTestBase.php @@ -8,7 +8,7 @@ namespace Drupal\system\Tests\Entity; use Drupal\Core\Language\Language; -use Drupal\field\Field as FieldService; +use Drupal\field\Entity\FieldConfig; /** * Base class for language-aware entity tests. @@ -133,12 +133,11 @@ function setUp() { protected function toggleFieldTranslatability($entity_type) { $fields = array($this->field_name, $this->untranslatable_field_name); foreach ($fields as $field_name) { - $field = FieldService::fieldInfo()->getField($entity_type, $field_name); + $field = FieldConfig::loadByName($entity_type, $field_name); $translatable = !$field->isTranslatable(); $field->set('translatable', $translatable); $field->save(); - FieldService::fieldInfo()->flush(); - $field = FieldService::fieldInfo()->getField($entity_type, $field_name); + $field = FieldConfig::loadByName($entity_type, $field_name); $this->assertEqual($field->isTranslatable(), $translatable, 'Field translatability changed.'); } \Drupal::cache('entity')->deleteAll(); diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/FieldTranslationSqlStorageTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/FieldTranslationSqlStorageTest.php index 2e68569..b9d8cec 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/FieldTranslationSqlStorageTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/FieldTranslationSqlStorageTest.php @@ -10,7 +10,7 @@ use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\ContentEntityDatabaseStorage; use Drupal\Core\Language\Language; -use Drupal\field\Field as FieldService; +use Drupal\field\Entity\FieldConfig; /** * Tests entity translation. @@ -91,7 +91,7 @@ protected function assertFieldStorageLangcode(ContentEntityInterface $entity, $m $fields = array($this->field_name, $this->untranslatable_field_name); foreach ($fields as $field_name) { - $field = FieldService::fieldInfo()->getField($entity_type, $field_name); + $field = FieldConfig::loadByName($entity_type, $field_name); $tables = array( ContentEntityDatabaseStorage::_fieldTableName($field), ContentEntityDatabaseStorage::_fieldRevisionTableName($field), diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Controller/TermAutocompleteController.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Controller/TermAutocompleteController.php index 41a370c..d6534f8 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Controller/TermAutocompleteController.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Controller/TermAutocompleteController.php @@ -13,8 +13,6 @@ use Drupal\Core\DependencyInjection\ContainerInjectionInterface; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\Query\QueryInterface; -use Drupal\field\FieldInfo; -use Drupal\taxonomy\TermStorageInterface; use Drupal\taxonomy\VocabularyInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; @@ -59,7 +57,6 @@ public function __construct(QueryInterface $term_entity_query, EntityManagerInte public static function create(ContainerInterface $container) { return new static( $container->get('entity.query')->get('taxonomy_term'), - $container->get('field.info'), $container->get('entity.manager') ); } diff --git a/core/modules/user/lib/Drupal/user/UserStorage.php b/core/modules/user/lib/Drupal/user/UserStorage.php index d3f4990..78c48ff 100644 --- a/core/modules/user/lib/Drupal/user/UserStorage.php +++ b/core/modules/user/lib/Drupal/user/UserStorage.php @@ -9,11 +9,10 @@ use Drupal\Component\Uuid\UuidInterface; use Drupal\Core\Entity\EntityInterface; +use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Password\PasswordInterface; use Drupal\Core\Database\Connection; -use Drupal\field\FieldInfo; -use Drupal\user\UserDataInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Core\Entity\ContentEntityDatabaseStorage; @@ -46,8 +45,8 @@ class UserStorage extends ContentEntityDatabaseStorage implements UserStorageInt * The entity type definition. * @param \Drupal\Core\Database\Connection $database * The database connection to be used. - * @param \Drupal\field\FieldInfo $field_info - * The field info service. + * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager + * The entity manager. * @param \Drupal\Component\Uuid\UuidInterface $uuid_service * The UUID Service. * @param \Drupal\Core\Password\PasswordInterface $password @@ -55,8 +54,8 @@ class UserStorage extends ContentEntityDatabaseStorage implements UserStorageInt * @param \Drupal\user\UserDataInterface $user_data * The user data service. */ - public function __construct(EntityTypeInterface $entity_type, Connection $database, FieldInfo $field_info, UuidInterface $uuid_service, PasswordInterface $password, UserDataInterface $user_data) { - parent::__construct($entity_type, $database, $field_info, $uuid_service); + public function __construct(EntityTypeInterface $entity_type, Connection $database, EntityManagerInterface $entity_manager, UuidInterface $uuid_service, PasswordInterface $password, UserDataInterface $user_data) { + parent::__construct($entity_type, $database, $entity_manager, $uuid_service); $this->password = $password; $this->userData = $user_data; @@ -69,7 +68,7 @@ public static function createInstance(ContainerInterface $container, EntityTypeI return new static( $entity_type, $container->get('database'), - $container->get('field.info'), + $container->get('entity.manager'), $container->get('uuid'), $container->get('password'), $container->get('user.data') diff --git a/core/modules/user/user.install b/core/modules/user/user.install index 97515a2..0527cb4 100644 --- a/core/modules/user/user.install +++ b/core/modules/user/user.install @@ -5,9 +5,6 @@ * Install, update and uninstall functions for the user module. */ -use Drupal\Core\Language\Language; -use Drupal\field\Field; - /** * Implements hook_schema(). */