From a57630c83d508a0916f0429534b253a232e9c0fb Mon Sep 17 00:00:00 2001 From: Nathaniel Catchpole <catch@35733.no-reply.drupal.org> Date: Fri, 18 Jul 2014 19:56:27 +0100 Subject: [PATCH] Issue #2287727 by yched, swentel, alexpott: Rename Field[instance]Config classes and entity types (again). --- .../Config/Entity/ConfigEntityInterface.php | 12 +- .../Entity/ContentEntityDatabaseStorage.php | 4 +- .../Drupal/Core/Entity/Query/Sql/Tables.php | 28 +-- .../Core/Field/FieldDefinitionInterface.php | 16 +- .../Drupal/Core/Field/FieldItemInterface.php | 4 +- .../block_content/block_content.module | 12 +- .../src/Tests/BlockContentFieldTest.php | 18 +- core/modules/comment/comment.install | 6 +- core/modules/comment/comment.module | 14 +- core/modules/comment/src/CommentManager.php | 16 +- .../comment/src/CommentPostRenderCache.php | 6 +- core/modules/comment/src/Entity/Comment.php | 8 +- .../src/Form/CommentTypeDeleteForm.php | 8 +- .../comment/src/Tests/CommentFieldsTest.php | 20 +- .../comment/src/Tests/CommentLanguageTest.php | 10 +- .../src/Tests/CommentNodeChangesTest.php | 4 +- .../comment/src/Tests/CommentNonNodeTest.php | 6 +- .../src/Tests/CommentStringIdEntitiesTest.php | 4 +- .../src/Tests/CommentTranslationUITest.php | 8 +- .../comment/src/Tests/CommentTypeTest.php | 6 +- .../src/Tests/CommentUninstallTest.php | 20 +- .../src/Tests/CommentValidationTest.php | 2 +- .../src/Tests/ConfigExportImportUITest.php | 29 +-- .../config/src/Tests/ConfigImportAllTest.php | 4 +- .../src/Tests/Views/ContactFieldsTest.php | 14 +- .../content_translation.install | 4 +- .../content_translation.module | 2 +- .../Tests/ContentTranslationSettingsTest.php | 2 +- .../Tests/ContentTranslationSyncImageTest.php | 2 +- .../src/Tests/ContentTranslationTestBase.php | 2 +- .../datetime/src/Tests/DateTimeFieldTest.php | 60 ++--- .../datetime/src/Tests/DateTimeItemTest.php | 6 +- .../src/Tests/QuickEditIntegrationTest.php | 4 +- .../entity/src/Tests/EntityDisplayTest.php | 18 +- .../src/Tests/EntityFormDisplayTest.php | 18 +- .../entity_reference/entity_reference.module | 30 ++- .../entity_reference.views.inc | 24 +- .../src/ConfigurableEntityReferenceItem.php | 4 +- .../Tests/EntityReferenceAutoCreateTest.php | 2 +- .../EntityReferenceFieldDefaultValueTest.php | 18 +- .../src/Tests/EntityReferenceFieldTest.php | 20 +- .../Tests/EntityReferenceFormatterTest.php | 2 +- .../EntityReferenceSelectionAccessTest.php | 24 +- .../EntityReferenceSelectionSortTest.php | 10 +- .../Views/EntityReferenceRelationshipTest.php | 6 +- .../src/Tests/Views/SelectionTest.php | 8 +- .../field/config/schema/field.schema.yml | 2 +- core/modules/field/field.api.php | 40 ++-- core/modules/field/field.module | 22 +- core/modules/field/field.purge.inc | 61 ++--- core/modules/field/field.views.inc | 50 ++-- .../field/src/ConfigImporterFieldPurger.php | 64 ++--- .../field/src/Entity/FieldInstanceConfig.php | 93 ++++---- ...FieldConfig.php => FieldStorageConfig.php} | 52 ++--- .../field/src/FieldConfigInterface.php | 34 --- .../src/FieldInstanceConfigInterface.php | 4 +- .../field/src/FieldInstanceConfigStorage.php | 16 +- .../field/src/FieldStorageConfigInterface.php | 34 +++ ...rage.php => FieldStorageConfigStorage.php} | 40 ++-- ...dStorageConfigUpdateForbiddenException.php | 13 ++ .../src/Plugin/views/argument/FieldList.php | 4 +- .../src/Plugin/views/argument/ListString.php | 4 +- .../field/src/Plugin/views/field/Field.php | 34 +-- .../src/Plugin/views/filter/FieldList.php | 4 +- .../src/Tests/Boolean/BooleanFieldTest.php | 8 +- .../src/Tests/Boolean/BooleanItemTest.php | 2 +- .../field/src/Tests/BulkDeleteTest.php | 89 ++++--- core/modules/field/src/Tests/CrudTest.php | 220 +++++++++--------- .../field/src/Tests/DisplayApiTest.php | 4 +- .../field/src/Tests/Email/EmailFieldTest.php | 12 +- .../field/src/Tests/Email/EmailItemTest.php | 2 +- .../field/src/Tests/FieldAccessTest.php | 8 +- .../field/src/Tests/FieldAttachOtherTest.php | 36 +-- .../src/Tests/FieldAttachStorageTest.php | 18 +- .../field/src/Tests/FieldDataCountTest.php | 38 +-- .../field/src/Tests/FieldImportCreateTest.php | 28 +-- .../field/src/Tests/FieldImportDeleteTest.php | 50 ++-- .../Tests/FieldImportDeleteUninstallTest.php | 44 ++-- .../FieldImportDeleteUninstallUiTest.php | 26 +-- .../field/src/Tests/FieldInstanceCrudTest.php | 95 ++++---- .../field/src/Tests/FieldUnitTestBase.php | 12 +- .../field/src/Tests/FieldValidationTest.php | 4 +- core/modules/field/src/Tests/FormTest.php | 80 +++---- .../field/src/Tests/NestedFormTest.php | 8 +- .../src/Tests/Number/NumberFieldTest.php | 24 +- .../field/src/Tests/Number/NumberItemTest.php | 2 +- .../modules/field/src/Tests/ShapeItemTest.php | 10 +- core/modules/field/src/Tests/TestItemTest.php | 10 +- .../field/src/Tests/TranslationTest.php | 24 +- .../field/src/Tests/TranslationWebTest.php | 16 +- .../field/src/Tests/Views/ApiDataTest.php | 11 +- .../field/src/Tests/Views/FieldTestBase.php | 21 +- .../src/Tests/Views/HandlerFieldFieldTest.php | 32 +-- .../src/Tests/reEnableModuleFieldTest.php | 8 +- .../modules/field_test/field_test.field.inc | 10 +- .../modules/field_test/field_test.module | 14 +- .../src/Plugin/Field/FieldType/TestItem.php | 14 +- ...ity_test.entity_test.field_test_import.yml | 3 + ...y_test.entity_test.field_test_import_2.yml | 3 + ...y_test.test_bundle.field_test_import_2.yml | 3 + ...storage.entity_test.field_test_import.yml} | 0 ...orage.entity_test.field_test_import_2.yml} | 0 ....entity_test.field_test_import_staging.yml | 3 + ...est_bundle.field_test_import_staging_2.yml | 3 + ...t_bundle_2.field_test_import_staging_2.yml | 3 + ...entity_test.field_test_import_staging.yml} | 0 ...tity_test.field_test_import_staging_2.yml} | 0 .../src/FieldInstanceConfigEntityUnitTest.php | 27 ++- ...p => FieldStorageConfigEntityUnitTest.php} | 31 +-- core/modules/field_ui/field_ui.module | 2 +- core/modules/field_ui/field_ui.routing.yml | 2 +- .../src/FieldInstanceConfigListBuilder.php | 4 +- core/modules/field_ui/src/FieldOverview.php | 26 +-- ....php => FieldStorageConfigListBuilder.php} | 6 +- .../Form/FieldInstanceConfigDeleteForm.php | 4 +- .../src/Form/FieldInstanceEditForm.php | 8 +- ...dEditForm.php => FieldStorageEditForm.php} | 34 +-- .../Plugin/Derivative/FieldUiLocalTask.php | 2 +- .../field_ui/src/Routing/RouteSubscriber.php | 6 +- .../field_ui/src/Tests/FieldUiTestBase.php | 4 +- .../field_ui/src/Tests/ManageFieldsTest.php | 63 +++-- core/modules/file/file.module | 6 +- core/modules/file/file.views.inc | 18 +- .../Plugin/Field/FieldWidget/FileWidget.php | 8 +- .../file/src/Tests/FileFieldTestBase.php | 28 ++- .../file/src/Tests/FileFieldWidgetTest.php | 6 +- core/modules/file/src/Tests/FileItemTest.php | 2 +- .../file_module_test/file_module_test.module | 6 +- ...e.taxonomy_term.forums.forum_container.yml | 2 +- ...storage.taxonomy_term.forum_container.yml} | 0 core/modules/forum/forum.install | 22 +- .../forum/src/Tests/ForumUninstallTest.php | 24 +- .../hal/src/Tests/NormalizerTestBase.php | 6 +- core/modules/image/image.module | 51 ++-- core/modules/image/image.views.inc | 18 +- .../src/Tests/ImageFieldDefaultImagesTest.php | 67 +++--- .../image/src/Tests/ImageFieldDisplayTest.php | 22 +- .../image/src/Tests/ImageFieldTestBase.php | 12 +- .../modules/image/src/Tests/ImageItemTest.php | 2 +- .../src/Tests/ImageThemeFunctionTest.php | 2 +- core/modules/link/src/Tests/LinkFieldTest.php | 28 +-- core/modules/link/src/Tests/LinkItemTest.php | 2 +- ...onfig.php => EntityFieldStorageConfig.php} | 4 +- .../migrate.migration.d6_comment_field.yml | 2 +- .../install/migrate.migration.d6_field.yml | 2 +- .../migrate.migration.d6_upload_field.yml | 2 +- ...igrate.migration.d6_user_picture_field.yml | 2 +- ...igrate.migration.d6_user_profile_field.yml | 2 +- .../migrate.migration.d6_vocabulary_field.yml | 2 +- .../Tests/d6/MigrateCckFieldRevisionTest.php | 4 +- .../Tests/d6/MigrateCckFieldValuesTest.php | 6 +- .../d6/MigrateCommentVariableDisplayBase.php | 2 +- .../d6/MigrateCommentVariableFieldTest.php | 5 +- .../d6/MigrateCommentVariableInstanceTest.php | 4 +- .../src/Tests/d6/MigrateFieldInstanceTest.php | 2 +- .../src/Tests/d6/MigrateFieldTest.php | 42 ++-- .../src/Tests/d6/MigrateProfileValuesTest.php | 16 +- .../src/Tests/d6/MigrateTermNodeTestBase.php | 2 +- .../src/Tests/d6/MigrateUploadBase.php | 2 +- .../src/Tests/d6/MigrateUploadFieldTest.php | 4 +- .../Tests/d6/MigrateUploadInstanceTest.php | 2 +- .../Tests/d6/MigrateUserPictureFieldTest.php | 4 +- .../d6/MigrateUserPictureInstanceTest.php | 2 +- .../MigrateUserProfileEntityDisplayTest.php | 16 +- ...igrateUserProfileEntityFormDisplayTest.php | 16 +- .../MigrateUserProfileFieldInstanceTest.php | 2 +- .../Tests/d6/MigrateUserProfileFieldTest.php | 37 +-- .../src/Tests/d6/MigrateUserTest.php | 2 +- .../d6/MigrateVocabularyEntityDisplayTest.php | 2 +- ...MigrateVocabularyEntityFormDisplayTest.php | 2 +- .../d6/MigrateVocabularyFieldInstanceTest.php | 2 +- .../Tests/d6/MigrateVocabularyFieldTest.php | 8 +- core/modules/node/node.module | 12 +- .../MultiStepNodeFormBasicOptionsTest.php | 2 +- .../node/src/Tests/NodeAccessFieldTest.php | 2 +- ...NodeAccessLanguageAwareCombinationTest.php | 6 +- .../src/Tests/NodeAccessLanguageAwareTest.php | 6 +- .../src/Tests/NodeFieldMultilingualTest.php | 8 +- .../node/src/Tests/PagePreviewTest.php | 2 +- .../node_access_test/node_access_test.module | 6 +- core/modules/options/options.module | 27 ++- .../Tests/OptionsDynamicValuesTestBase.php | 2 +- .../options/src/Tests/OptionsFieldTest.php | 20 +- .../options/src/Tests/OptionsFieldUITest.php | 10 +- .../src/Tests/OptionsFieldUnitTestBase.php | 23 +- .../options/src/Tests/OptionsWidgetsTest.php | 24 +- .../path/src/Tests/PathLanguageTest.php | 2 - .../src/Tests/EditorSelectionTest.php | 12 +- .../Tests/QuickEditAutocompleteTermTest.php | 4 +- .../quickedit/src/Tests/QuickEditTestBase.php | 8 +- .../Access/EditEntityFieldAccessCheckTest.php | 26 +-- .../rdf/src/Tests/Field/FieldRdfaTestBase.php | 2 +- .../Field/TaxonomyTermReferenceRdfaTest.php | 2 +- .../Tests/TaxonomyTermFieldAttributesTest.php | 2 +- .../search/src/Tests/SearchLanguageTest.php | 8 +- .../Tests/SearchMultilingualEntityTest.php | 8 +- .../src/Tests/EntityResolverTest.php | 4 +- .../src/Tests/NormalizerTestBase.php | 2 +- .../src/Tests/KernelTestBaseTest.php | 8 +- core/modules/system/entity.api.php | 10 +- .../system/src/Tests/Ajax/MultiFormTest.php | 2 +- .../Tests/Entity/EntityCacheTagsTestBase.php | 8 +- .../Tests/Entity/EntityLanguageTestBase.php | 6 +- .../Tests/Entity/EntityQueryAggregateTest.php | 2 +- .../Entity/EntityQueryRelationshipTest.php | 2 +- .../src/Tests/Entity/EntityQueryTest.php | 16 +- .../Entity/EntityTranslationFormTest.php | 12 +- .../Entity/EntityWithUriCacheTagsTestBase.php | 5 +- .../src/Tests/Entity/FieldSqlStorageTest.php | 140 +++++------ .../Entity/FieldTranslationSqlStorageTest.php | 8 +- .../src/Tests/Form/ArbitraryRebuildTest.php | 2 +- .../system/src/Tests/Form/RebuildTest.php | 10 +- core/modules/system/system.api.php | 2 +- .../modules/entity_test/entity_test.install | 2 +- .../tests/upgrade/drupal-7.field.database.php | 4 +- .../Controller/TermAutocompleteController.php | 4 +- .../taxonomy/src/Entity/Vocabulary.php | 4 +- .../modules/taxonomy/src/Tests/LegacyTest.php | 2 +- core/modules/taxonomy/src/Tests/RssTest.php | 6 +- .../taxonomy/src/Tests/TaxonomyImageTest.php | 2 +- .../Tests/TaxonomyTermReferenceItemTest.php | 2 +- .../Tests/TermFieldMultipleVocabularyTest.php | 10 +- .../taxonomy/src/Tests/TermFieldTest.php | 26 ++- .../taxonomy/src/Tests/TermIndexTest.php | 4 +- core/modules/taxonomy/src/Tests/TermTest.php | 9 +- .../taxonomy/src/Tests/TokenReplaceTest.php | 2 +- .../src/Tests/Views/TaxonomyTestBase.php | 2 +- .../taxonomy/src/Tests/VocabularyCrudTest.php | 20 +- core/modules/taxonomy/taxonomy.views.inc | 18 +- .../src/Tests/TelephoneFieldTest.php | 2 +- .../telephone/src/Tests/TelephoneItemTest.php | 2 +- .../src/Tests/Formatter/TextFormatterTest.php | 4 +- .../src/Tests/Formatter/TextPlainUnitTest.php | 6 +- core/modules/text/src/Tests/TextFieldTest.php | 60 ++--- .../src/Tests/TextWithSummaryItemTest.php | 12 +- .../modules/user/src/Tests/UserCreateTest.php | 10 +- .../user/src/Tests/UserRegistrationTest.php | 11 +- .../views/src/Tests/DefaultViewsTest.php | 2 +- .../views/src/Tests/Wizard/TaggedWithTest.php | 13 +- .../views_test_data.views_execution.inc | 5 +- core/modules/views/views.api.php | 46 ++-- core/modules/views_ui/admin.inc | 4 +- ...ield.instance.node.article.field_image.yml | 2 +- ...field.instance.node.article.field_tags.yml | 2 +- .../field.instance.user.user.user_picture.yml | 2 +- ...yml => field.storage.node.field_image.yml} | 0 ....yml => field.storage.node.field_tags.yml} | 0 ...ml => field.storage.user.user_picture.yml} | 0 .../Tests/Core/Config/StorageComparerTest.php | 16 +- .../ContentEntityDatabaseStorageTest.php | 12 +- 250 files changed, 1816 insertions(+), 1840 deletions(-) rename core/modules/field/src/Entity/{FieldConfig.php => FieldStorageConfig.php} (90%) delete mode 100644 core/modules/field/src/FieldConfigInterface.php create mode 100644 core/modules/field/src/FieldStorageConfigInterface.php rename core/modules/field/src/{FieldConfigStorage.php => FieldStorageConfigStorage.php} (81%) create mode 100644 core/modules/field/src/FieldStorageConfigUpdateForbiddenException.php rename core/modules/field/tests/modules/field_test_config/config/install/{field.field.entity_test.field_test_import.yml => field.storage.entity_test.field_test_import.yml} (100%) rename core/modules/field/tests/modules/field_test_config/config/install/{field.field.entity_test.field_test_import_2.yml => field.storage.entity_test.field_test_import_2.yml} (100%) rename core/modules/field/tests/modules/field_test_config/staging/{field.field.entity_test.field_test_import_staging.yml => field.storage.entity_test.field_test_import_staging.yml} (100%) rename core/modules/field/tests/modules/field_test_config/staging/{field.field.entity_test.field_test_import_staging_2.yml => field.storage.entity_test.field_test_import_staging_2.yml} (100%) rename core/modules/field/tests/src/{FieldConfigEntityUnitTest.php => FieldStorageConfigEntityUnitTest.php} (73%) rename core/modules/field_ui/src/{FieldConfigListBuilder.php => FieldStorageConfigListBuilder.php} (94%) rename core/modules/field_ui/src/Form/{FieldEditForm.php => FieldStorageEditForm.php} (88%) rename core/modules/forum/config/install/{field.field.taxonomy_term.forum_container.yml => field.storage.taxonomy_term.forum_container.yml} (100%) rename core/modules/migrate/src/Plugin/migrate/destination/{EntityFieldConfig.php => EntityFieldStorageConfig.php} (78%) rename core/profiles/standard/config/install/{field.field.node.field_image.yml => field.storage.node.field_image.yml} (100%) rename core/profiles/standard/config/install/{field.field.node.field_tags.yml => field.storage.node.field_tags.yml} (100%) rename core/profiles/standard/config/install/{field.field.user.user_picture.yml => field.storage.user.user_picture.yml} (100%) diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityInterface.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityInterface.php index b355cb5ac9fa..e14b98911d17 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityInterface.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityInterface.php @@ -85,12 +85,12 @@ public function status(); * because imported entities were already given the body field when they were * originally created, and the imported configuration includes all of their * currently-configured fields. On the other hand, - * \Drupal\field\Entity\FieldConfig::preSave() and the methods it calls make - * sure that the storage tables are created or updated for the field - * configuration entity, which is not a configuration change, and it must be - * done whether due to an import or not. So, the first method should check - * $entity->isSyncing() and skip executing if it returns TRUE, and the second - * should not perform this check. + * \Drupal\field\Entity\FieldStorageConfig::preSave() and the methods it calls + * make sure that the storage tables are created or updated for the field + * storage configuration entity, which is not a configuration change, and it + * must be done whether due to an import or not. So, the first method should + * check $entity->isSyncing() and skip executing if it returns TRUE, and the + * second should not perform this check. * * @return bool * TRUE if the configuration entity is being created, updated, or deleted diff --git a/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php b/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php index 0b5382dd8ce3..c2a02141d363 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php @@ -19,7 +19,7 @@ use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Language\LanguageInterface; -use Drupal\field\Entity\FieldConfig; +use Drupal\field\Entity\FieldStorageConfig; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -1934,7 +1934,7 @@ public static function _fieldIndexName(FieldStorageDefinitionInterface $storage_ * unique among all other fields. */ public static function _fieldColumnName(FieldStorageDefinitionInterface $storage_definition, $column) { - return in_array($column, FieldConfig::getReservedColumns()) ? $column : $storage_definition->getName() . '_' . $column; + return in_array($column, FieldStorageConfig::getReservedColumns()) ? $column : $storage_definition->getName() . '_' . $column; } } diff --git a/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php b/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php index d5a6334419ee..facca393aa1d 100644 --- a/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php +++ b/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php @@ -13,8 +13,8 @@ use Drupal\Core\Entity\ContentEntityDatabaseStorage; use Drupal\Core\Entity\Query\QueryException; use Drupal\Core\Entity\Sql\SqlEntityStorageInterface; -use Drupal\field\Entity\FieldConfig; -use Drupal\field\FieldConfigInterface; +use Drupal\field\Entity\FieldStorageConfig; +use Drupal\field\FieldStorageConfigInterface; /** * Adds tables and fields to the SQL entity query. @@ -107,20 +107,20 @@ public function addField($field, $type, $langcode) { // field. $specifier = $specifiers[$key]; if (isset($field_storage_definitions[$specifier])) { - $field = $field_storage_definitions[$specifier]; + $field_storage = $field_storage_definitions[$specifier]; } else { - $field = FALSE; + $field_storage = FALSE; } // If we managed to retrieve a configurable field, process it. - if ($field instanceof FieldConfigInterface) { + if ($field_storage instanceof FieldStorageConfigInterface) { // Find the field column. - $column = $field->getMainPropertyName(); + $column = $field_storage->getMainPropertyName(); if ($key < $count) { $next = $specifiers[$key + 1]; // Is this a field column? - $columns = $field->getColumns(); - if (isset($columns[$next]) || in_array($next, FieldConfig::getReservedColumns())) { + $columns = $field_storage->getColumns(); + if (isset($columns[$next]) || in_array($next, FieldStorageConfig::getReservedColumns())) { // Use it. $column = $next; // Do not process it again. @@ -135,14 +135,14 @@ public function addField($field, $type, $langcode) { // also use the property definitions for column. if ($key < $count) { $relationship_specifier = $specifiers[$key + 1]; - $propertyDefinitions = $field->getPropertyDefinitions(); + $propertyDefinitions = $field_storage->getPropertyDefinitions(); // Prepare the next index prefix. $next_index_prefix = "$relationship_specifier.$column"; } } - $table = $this->ensureFieldTable($index_prefix, $field, $type, $langcode, $base_table, $entity_id_field, $field_id_field); - $sql_column = ContentEntityDatabaseStorage::_fieldColumnName($field, $column); + $table = $this->ensureFieldTable($index_prefix, $field_storage, $type, $langcode, $base_table, $entity_id_field, $field_id_field); + $sql_column = ContentEntityDatabaseStorage::_fieldColumnName($field_storage, $column); } // This is an entity base field (non-configurable field). else { @@ -161,16 +161,16 @@ 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 ($field && $key < $count) { + if ($field_storage && $key < $count) { // Computed fields have prepared their property definition already, do // it for properties as well. if (!$propertyDefinitions) { - $propertyDefinitions = $field->getPropertyDefinitions(); + $propertyDefinitions = $field_storage->getPropertyDefinitions(); $relationship_specifier = $specifiers[$key + 1]; $next_index_prefix = $relationship_specifier; } // Check for a valid relationship. - if (isset($propertyDefinitions[$relationship_specifier]) && $field->getPropertyDefinition('entity')->getDataType() == 'entity_reference' ) { + if (isset($propertyDefinitions[$relationship_specifier]) && $field_storage->getPropertyDefinition('entity')->getDataType() == 'entity_reference' ) { // If it is, use the entity type. $entity_type_id = $propertyDefinitions[$relationship_specifier]->getTargetDefinition()->getEntityTypeId(); $entity_type = $this->entityManager->getDefinition($entity_type_id); diff --git a/core/lib/Drupal/Core/Field/FieldDefinitionInterface.php b/core/lib/Drupal/Core/Field/FieldDefinitionInterface.php index be7f0fe044f3..cf6947b547f2 100644 --- a/core/lib/Drupal/Core/Field/FieldDefinitionInterface.php +++ b/core/lib/Drupal/Core/Field/FieldDefinitionInterface.php @@ -27,20 +27,20 @@ * It is up to the class implementing this interface to manage where the * information comes from. For example, field.module provides an implementation * based on two levels of configuration. It allows the site administrator to add - * custom fields to any entity type and bundle via the "field_config" and - * "field_instance_config" configuration entities. The former for storing + * custom fields to any entity type and bundle via the "field_storage_config" + * and "field_instance_config" configuration entities. The former for storing * configuration that is independent of which entity type and bundle the field * is added to, and the latter for storing configuration that is specific to the * entity type and bundle. The class that implements "field_instance_config" * configuration entities also implements this interface, returning information - * from either itself, or from the corresponding "field_config" configuration, - * as appropriate. + * from either itself, or from the corresponding "field_storage_config" + * configuration, as appropriate. * * However, entity base fields, such as $node->title, are not managed by - * field.module and its "field_config"/"field_instance_config" configuration - * entities. Therefore, their definitions are provided by different objects - * based on the class \Drupal\Core\Field\FieldDefinition, which implements this - * interface as well. + * field.module and its "field_storage_config"/"field_instance_config" + * configuration entities. Therefore, their definitions are provided by + * different objects based on the class \Drupal\Core\Field\FieldDefinition, + * which implements this interface as well. * * Field definitions may fully define a concrete data object (e.g., * $node_1->body), or may provide a best-guess definition for a data object that diff --git a/core/lib/Drupal/Core/Field/FieldItemInterface.php b/core/lib/Drupal/Core/Field/FieldItemInterface.php index ee2799625da2..64895416a02e 100644 --- a/core/lib/Drupal/Core/Field/FieldItemInterface.php +++ b/core/lib/Drupal/Core/Field/FieldItemInterface.php @@ -234,8 +234,8 @@ public static function defaultInstanceSettings(); /** * Returns a form for the field-level settings. * - * Invoked from \Drupal\field_ui\Form\FieldEditForm to allow administrators to - * configure field-level settings. + * Invoked from \Drupal\field_ui\Form\FieldStorageEditForm to allow + * administrators to configure field-level settings. * * Field storage might reject field definition changes that affect the field * storage schema if the field already has data. When the $has_data parameter diff --git a/core/modules/block_content/block_content.module b/core/modules/block_content/block_content.module index 706fa691e461..dadcf4ba1959 100644 --- a/core/modules/block_content/block_content.module +++ b/core/modules/block_content/block_content.module @@ -6,8 +6,8 @@ */ use Drupal\Core\Routing\RouteMatchInterface; -use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldInstanceConfig; +use Drupal\field\Entity\FieldStorageConfig; /** * Implements hook_help(). @@ -77,19 +77,19 @@ function block_content_entity_type_alter(array &$entity_types) { */ function block_content_add_body_field($block_type_id, $label = 'Body') { // Add or remove the body field, as needed. - $field = FieldConfig::loadByName('block_content', 'body'); + $field_storage = FieldStorageConfig::loadByName('block_content', 'body'); $instance = FieldInstanceConfig::loadByName('block_content', $block_type_id, 'body'); - if (empty($field)) { - $field = entity_create('field_config', array( + if (empty($field_storage)) { + $field_storage = entity_create('field_storage_config', array( 'name' => 'body', 'entity_type' => 'block_content', 'type' => 'text_with_summary', )); - $field->save(); + $field_storage->save(); } if (empty($instance)) { $instance = entity_create('field_instance_config', array( - 'field' => $field, + 'field_storage' => $field_storage, 'bundle' => $block_type_id, 'label' => $label, 'settings' => array('display_summary' => FALSE), diff --git a/core/modules/block_content/src/Tests/BlockContentFieldTest.php b/core/modules/block_content/src/Tests/BlockContentFieldTest.php index 094d14796e64..28f010b96897 100644 --- a/core/modules/block_content/src/Tests/BlockContentFieldTest.php +++ b/core/modules/block_content/src/Tests/BlockContentFieldTest.php @@ -26,9 +26,9 @@ class BlockContentFieldTest extends BlockContentTestBase { /** * The created field. * - * @var \Drupal\field\Entity\FieldConfig + * @var \Drupal\field\Entity\FieldStorageConfig */ - protected $field; + protected $fieldStorage; /** * The created instance. @@ -54,15 +54,15 @@ public function testBlockFields() { $this->blockType = $this->createBlockContentType('link'); // Create a field with settings to validate. - $this->field = entity_create('field_config', array( + $this->fieldStorage = entity_create('field_storage_config', array( 'name' => drupal_strtolower($this->randomName()), 'entity_type' => 'block_content', 'type' => 'link', 'cardinality' => 2, )); - $this->field->save(); + $this->fieldStorage->save(); $this->instance = entity_create('field_instance_config', array( - 'field' => $this->field, + 'field_storage' => $this->fieldStorage, 'bundle' => 'link', 'settings' => array( 'title' => DRUPAL_OPTIONAL, @@ -70,12 +70,12 @@ public function testBlockFields() { )); $this->instance->save(); entity_get_form_display('block_content', 'link', 'default') - ->setComponent($this->field->getName(), array( + ->setComponent($this->fieldStorage->getName(), array( 'type' => 'link_default', )) ->save(); entity_get_display('block_content', 'link', 'default') - ->setComponent($this->field->getName(), array( + ->setComponent($this->fieldStorage->getName(), array( 'type' => 'link', 'label' => 'hidden', )) @@ -85,8 +85,8 @@ public function testBlockFields() { $this->drupalGet('block/add/link'); $edit = array( 'info[0][value]' => $this->randomName(8), - $this->field->getName() . '[0][url]' => 'http://example.com', - $this->field->getName() . '[0][title]' => 'Example.com' + $this->fieldStorage->getName() . '[0][url]' => 'http://example.com', + $this->fieldStorage->getName() . '[0][title]' => 'Example.com' ); $this->drupalPostForm(NULL, $edit, t('Save')); $block = entity_load('block_content', 1); diff --git a/core/modules/comment/comment.install b/core/modules/comment/comment.install index fc859bafaeed..4ce2b37cffe6 100644 --- a/core/modules/comment/comment.install +++ b/core/modules/comment/comment.install @@ -6,14 +6,14 @@ */ use Drupal\Core\Entity\EntityTypeInterface; -use Drupal\field\Entity\FieldConfig; +use Drupal\field\Entity\FieldStorageConfig; /** * Implements hook_uninstall(). */ function comment_uninstall() { // Remove the comment fields. - $fields = entity_load_multiple_by_properties('field_config', array('type' => 'comment')); + $fields = entity_load_multiple_by_properties('field_storage_config', array('type' => 'comment')); foreach ($fields as $field) { $field->delete(); } @@ -56,7 +56,7 @@ function comment_schema() { 'type' => 'varchar', 'not null' => TRUE, 'default' => '', - 'length' => FieldConfig::NAME_MAX_LENGTH, + 'length' => FieldStorageConfig::NAME_MAX_LENGTH, 'description' => 'The field_name of the field that was used to add this comment.', ), 'cid' => array( diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index c42c8311012b..f2347ffad0e0 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -24,9 +24,9 @@ use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Render\Element; use Drupal\Core\Url; -use Drupal\field\Entity\FieldConfig; +use Drupal\field\Entity\FieldStorageConfig; use Drupal\field\FieldInstanceConfigInterface; -use Drupal\field\FieldConfigInterface; +use Drupal\field\FieldStorageConfigInterface; use Drupal\file\FileInterface; use Drupal\user\EntityOwnerInterface; use Drupal\node\NodeInterface; @@ -174,12 +174,12 @@ function comment_field_instance_config_update(FieldInstanceConfigInterface $inst } /** - * Implements hook_ENTITY_TYPE_insert() for 'field_config'. + * Implements hook_ENTITY_TYPE_insert() for 'field_storage_config'. */ -function comment_field_config_insert(FieldConfigInterface $field) { - if ($field->getType() == 'comment') { +function comment_field_storage_config_insert(FieldStorageConfigInterface $field_storage) { + if ($field_storage->getType() == 'comment') { // Check that the target entity type uses an integer ID. - $entity_type_id = $field->getTargetEntityTypeId(); + $entity_type_id = $field_storage->getTargetEntityTypeId(); if (!_comment_entity_uses_integer_id($entity_type_id)) { throw new \UnexpectedValueException('You cannot attach a comment field to an entity with a non-integer ID field'); } @@ -646,7 +646,7 @@ function comment_form_field_ui_display_overview_form_alter(&$form, $form_state) /** * Implements hook_form_FORM_ID_alter(). */ -function comment_form_field_ui_field_edit_form_alter(&$form, $form_state) { +function comment_form_field_ui_field_storage_edit_form_alter(&$form, $form_state) { if ($form['#field']->getType() == 'comment') { // We only support posting one comment at the time so it doesn't make sense // to let the site builder choose anything else. diff --git a/core/modules/comment/src/CommentManager.php b/core/modules/comment/src/CommentManager.php index 1bed27015ef3..5cb57166cad9 100644 --- a/core/modules/comment/src/CommentManager.php +++ b/core/modules/comment/src/CommentManager.php @@ -19,7 +19,7 @@ use Drupal\Core\Session\AccountInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\Core\StringTranslation\TranslationInterface; -use Drupal\field\Entity\FieldConfig; +use Drupal\field\Entity\FieldStorageConfig; use Drupal\field\Entity\FieldInstanceConfig; /** @@ -158,9 +158,9 @@ public function addDefaultField($entity_type, $bundle, $field_name = 'comment', ))->save(); } // Make sure the field doesn't already exist. - if (!FieldConfig::loadByName($entity_type, $field_name)) { + if (!FieldStorageConfig::loadByName($entity_type, $field_name)) { // Add a default comment field for existing node comments. - $field = $this->entityManager->getStorage('field_config')->create(array( + $field_storage = $this->entityManager->getStorage('field_storage_config')->create(array( 'entity_type' => $entity_type, 'name' => $field_name, 'type' => 'comment', @@ -170,7 +170,7 @@ public function addDefaultField($entity_type, $bundle, $field_name = 'comment', ), )); // Create the field. - $field->save(); + $field_storage->save(); } // Make sure the instance doesn't already exist. if (!array_key_exists($field_name, $this->entityManager->getFieldDefinitions($entity_type, $bundle))) { @@ -235,14 +235,14 @@ public function addDefaultField($entity_type, $bundle, $field_name = 'comment', */ public function addBodyField($comment_type_id) { // Create the field if needed. - $field = FieldConfig::loadByName('comment', 'comment_body'); - if (!$field) { - $field = $this->entityManager->getStorage('field_config')->create(array( + $field_storage = FieldStorageConfig::loadByName('comment', 'comment_body'); + if (!$field_storage) { + $field_storage = $this->entityManager->getStorage('field_storage_config')->create(array( 'name' => 'comment_body', 'type' => 'text_long', 'entity_type' => 'comment', )); - $field->save(); + $field_storage->save(); } if (!FieldInstanceConfig::loadByName('comment', $comment_type_id, 'comment_body')) { // Attaches the body field by default. diff --git a/core/modules/comment/src/CommentPostRenderCache.php b/core/modules/comment/src/CommentPostRenderCache.php index 15831e0242c2..24db82dc6c48 100644 --- a/core/modules/comment/src/CommentPostRenderCache.php +++ b/core/modules/comment/src/CommentPostRenderCache.php @@ -9,7 +9,7 @@ use Drupal\Core\Entity\EntityFormBuilderInterface; use Drupal\Core\Entity\EntityManagerInterface; -use Drupal\field\Entity\FieldConfig; +use Drupal\field\Entity\FieldStorageConfig; /** * Defines a service for comment post render cache callbacks. @@ -60,12 +60,12 @@ public function __construct(EntityManagerInterface $entity_manager, EntityFormBu public function renderForm(array $element, array $context) { $field_name = $context['field_name']; $entity = $this->entityManager->getStorage($context['entity_type'])->load($context['entity_id']); - $field = Fieldconfig::loadByName($entity->getEntityTypeId(), $field_name); + $field_storage = FieldStorageConfig::loadByName($entity->getEntityTypeId(), $field_name); $values = array( 'entity_type' => $entity->getEntityTypeId(), 'entity_id' => $entity->id(), 'field_name' => $field_name, - 'comment_type' => $field->getSetting('bundle'), + 'comment_type' => $field_storage->getSetting('bundle'), 'pid' => NULL, ); $comment = $this->entityManager->getStorage('comment')->create($values); diff --git a/core/modules/comment/src/Entity/Comment.php b/core/modules/comment/src/Entity/Comment.php index 8ca87f50e75d..e4964bccac9d 100644 --- a/core/modules/comment/src/Entity/Comment.php +++ b/core/modules/comment/src/Entity/Comment.php @@ -13,7 +13,7 @@ use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Field\FieldDefinition; -use Drupal\field\Entity\FieldConfig; +use Drupal\field\Entity\FieldStorageConfig; use Drupal\user\UserInterface; /** @@ -302,7 +302,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { $fields['field_name'] = FieldDefinition::create('string') ->setLabel(t('Comment field name')) ->setDescription(t('The field name through which this comment was added.')) - ->setSetting('max_length', FieldConfig::NAME_MAX_LENGTH); + ->setSetting('max_length', FieldStorageConfig::NAME_MAX_LENGTH); return $fields; } @@ -509,8 +509,8 @@ public function getChangedTime() { */ public static function preCreate(EntityStorageInterface $storage, array &$values) { if (empty($values['comment_type']) && !empty($values['field_name']) && !empty($values['entity_type'])) { - $field = FieldConfig::loadByName($values['entity_type'], $values['field_name']); - $values['comment_type'] = $field->getSetting('comment_type'); + $field_storage = FieldStorageConfig::loadByName($values['entity_type'], $values['field_name']); + $values['comment_type'] = $field_storage->getSetting('comment_type'); } } diff --git a/core/modules/comment/src/Form/CommentTypeDeleteForm.php b/core/modules/comment/src/Form/CommentTypeDeleteForm.php index d653e5661a8b..b7178fcea151 100644 --- a/core/modules/comment/src/Form/CommentTypeDeleteForm.php +++ b/core/modules/comment/src/Form/CommentTypeDeleteForm.php @@ -12,7 +12,7 @@ use Drupal\Core\Entity\EntityManager; use Drupal\Core\Entity\Query\QueryFactory; use Drupal\Core\Url; -use Drupal\field\Entity\FieldConfig; +use Drupal\field\Entity\FieldStorageConfig; use Psr\Log\LoggerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -116,11 +116,11 @@ public function buildForm(array $form, array &$form_state) { $entity_type = $this->entity->getTargetEntityTypeId(); $caption = ''; foreach (array_keys($this->commentManager->getFields($entity_type)) as $field_name) { - /** @var \Drupal\field\FieldConfigInterface $field */ - if (($field = FieldConfig::loadByName($entity_type, $field_name)) && $field->getSetting('comment_type') == $this->entity->id() && !$field->deleted) { + /** @var \Drupal\field\FieldStorageConfigInterface $field_storage */ + if (($field_storage = FieldStorageConfig::loadByName($entity_type, $field_name)) && $field_storage->getSetting('comment_type') == $this->entity->id() && !$field_storage->deleted) { $caption .= '<p>' . $this->t('%label is used by the %field field on your site. You can not remove this comment type until you have removed the field.', array( '%label' => $this->entity->label(), - '%field' => $field->label(), + '%field' => $field_storage->label(), )) . '</p>'; } } diff --git a/core/modules/comment/src/Tests/CommentFieldsTest.php b/core/modules/comment/src/Tests/CommentFieldsTest.php index 0fb468e29b36..e0fd2559f070 100644 --- a/core/modules/comment/src/Tests/CommentFieldsTest.php +++ b/core/modules/comment/src/Tests/CommentFieldsTest.php @@ -8,7 +8,7 @@ namespace Drupal\comment\Tests; use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; -use Drupal\field\Entity\FieldConfig; +use Drupal\field\Entity\FieldStorageConfig; use Drupal\field\Entity\FieldInstanceConfig; /** @@ -41,8 +41,8 @@ function testCommentDefaultFields() { $instance->delete(); // Check that the 'comment_body' field is deleted. - $field = FieldConfig::loadByName('comment', 'comment_body'); - $this->assertTrue(empty($field), 'The comment_body field was deleted'); + $field_storage = FieldStorageConfig::loadByName('comment', 'comment_body'); + $this->assertTrue(empty($field_storage), 'The comment_body field was deleted'); // Create a new content type. $type_name = 'test_node_type_2'; @@ -51,15 +51,15 @@ function testCommentDefaultFields() { // Check that the 'comment_body' field exists and has an instance on the // new comment bundle. - $field = FieldConfig::loadByName('comment', 'comment_body'); - $this->assertTrue($field, 'The comment_body field exists'); + $field_storage = FieldStorageConfig::loadByName('comment', 'comment_body'); + $this->assertTrue($field_storage, 'The comment_body field exists'); $instance = FieldInstanceConfig::loadByName('comment', 'comment', 'comment_body'); $this->assertTrue(isset($instance), format_string('The comment_body field is present for comments on type @type', array('@type' => $type_name))); // Test adding a field that defaults to CommentItemInterface::CLOSED. $this->container->get('comment.manager')->addDefaultField('node', 'test_node_type', 'who_likes_ponies', CommentItemInterface::CLOSED, 'who_likes_ponies'); - $field = entity_load('field_instance_config', 'node.test_node_type.who_likes_ponies'); - $this->assertEqual($field->default_value[0]['status'], CommentItemInterface::CLOSED); + $field_storage = entity_load('field_instance_config', 'node.test_node_type.who_likes_ponies'); + $this->assertEqual($field_storage->default_value[0]['status'], CommentItemInterface::CLOSED); } /** @@ -71,9 +71,9 @@ function testCommentInstallAfterContentModule() { $this->drupalLogin($this->admin_user); // Drop default comment field added in CommentTestBase::setup(). - FieldConfig::loadByName('node', 'comment')->delete(); - if ($field = FieldConfig::loadByName('node', 'comment_forum')) { - $field->delete(); + FieldStorageConfig::loadByName('node', 'comment')->delete(); + if ($field_storage = FieldStorageConfig::loadByName('node', 'comment_forum')) { + $field_storage->delete(); } // Purge field data now to allow comment module to be uninstalled once the diff --git a/core/modules/comment/src/Tests/CommentLanguageTest.php b/core/modules/comment/src/Tests/CommentLanguageTest.php index 1cdb26693c6a..cd130b231525 100644 --- a/core/modules/comment/src/Tests/CommentLanguageTest.php +++ b/core/modules/comment/src/Tests/CommentLanguageTest.php @@ -9,7 +9,7 @@ use Drupal\comment\Entity\Comment; use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; -use Drupal\field\Entity\FieldConfig; +use Drupal\field\Entity\FieldStorageConfig; use Drupal\simpletest\WebTestBase; /** @@ -70,10 +70,10 @@ function setUp() { $this->container->get('comment.manager')->addDefaultField('node', 'article'); // Make comment body translatable. - $field = FieldConfig::loadByName('comment', 'comment_body'); - $field->translatable = TRUE; - $field->save(); - $this->assertTrue($field->isTranslatable(), 'Comment body is translatable.'); + $field_storage = FieldStorageConfig::loadByName('comment', 'comment_body'); + $field_storage->translatable = TRUE; + $field_storage->save(); + $this->assertTrue($field_storage->isTranslatable(), 'Comment body is translatable.'); } /** diff --git a/core/modules/comment/src/Tests/CommentNodeChangesTest.php b/core/modules/comment/src/Tests/CommentNodeChangesTest.php index 6f3f67aa8c25..4652c6613ddd 100644 --- a/core/modules/comment/src/Tests/CommentNodeChangesTest.php +++ b/core/modules/comment/src/Tests/CommentNodeChangesTest.php @@ -27,11 +27,11 @@ function testNodeDeletion() { $this->assertFalse(Comment::load($comment->id()), 'The comment could not be loaded after the node was deleted.'); // Make sure the comment field and all its instances are deleted when node // type is deleted. - $this->assertNotNull(entity_load('field_config', 'node.comment'), 'Comment field exists'); + $this->assertNotNull(entity_load('field_storage_config', 'node.comment'), 'Comment field exists'); $this->assertNotNull(entity_load('field_instance_config', 'node.article.comment'), 'Comment instance exists'); // Delete the node type. entity_delete_multiple('node_type', array($this->node->bundle())); - $this->assertNull(entity_load('field_config', 'node.comment'), 'Comment field deleted'); + $this->assertNull(entity_load('field_storage_config', 'node.comment'), 'Comment field deleted'); $this->assertNull(entity_load('field_instance_config', 'node.article.comment'), 'Comment instance deleted'); } } diff --git a/core/modules/comment/src/Tests/CommentNonNodeTest.php b/core/modules/comment/src/Tests/CommentNonNodeTest.php index 3bdeb72fcfab..dfc4f8949ef3 100644 --- a/core/modules/comment/src/Tests/CommentNonNodeTest.php +++ b/core/modules/comment/src/Tests/CommentNonNodeTest.php @@ -397,9 +397,9 @@ function testCommentFunctionality() { $this->assertRaw(t('Saved %name configuration', array('%name' => 'Barfoo'))); // Check the field contains the correct comment type. - $field = entity_load('field_config', 'entity_test.field_barfoo'); - $this->assertTrue($field); - $this->assertEqual($field->getSetting('comment_type'), 'foobar'); + $field_storage = entity_load('field_storage_config', 'entity_test.field_barfoo'); + $this->assertTrue($field_storage); + $this->assertEqual($field_storage->getSetting('comment_type'), 'foobar'); // Test the new entity commenting inherits default. $random_label = $this->randomName(); diff --git a/core/modules/comment/src/Tests/CommentStringIdEntitiesTest.php b/core/modules/comment/src/Tests/CommentStringIdEntitiesTest.php index 88c2d904da54..a65aed0bd620 100644 --- a/core/modules/comment/src/Tests/CommentStringIdEntitiesTest.php +++ b/core/modules/comment/src/Tests/CommentStringIdEntitiesTest.php @@ -50,7 +50,7 @@ public function testCommentFieldNonStringId() { 'target_entity_type_id' => 'entity_test_string_id', )); $bundle->save(); - $field = entity_create('field_config', array( + $field_storage = entity_create('field_storage_config', array( 'name' => 'foo', 'entity_type' => 'entity_test_string_id', 'settings' => array( @@ -58,7 +58,7 @@ public function testCommentFieldNonStringId() { ), 'type' => 'comment', )); - $field->save(); + $field_storage->save(); $this->fail('Did not throw an exception as expected.'); } catch (\UnexpectedValueException $e) { diff --git a/core/modules/comment/src/Tests/CommentTranslationUITest.php b/core/modules/comment/src/Tests/CommentTranslationUITest.php index ab6cca4b4270..207b69c58775 100644 --- a/core/modules/comment/src/Tests/CommentTranslationUITest.php +++ b/core/modules/comment/src/Tests/CommentTranslationUITest.php @@ -9,7 +9,7 @@ use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; use Drupal\content_translation\Tests\ContentTranslationUITest; -use Drupal\field\Entity\FieldConfig; +use Drupal\field\Entity\FieldStorageConfig; /** * Tests the Comment Translation UI. @@ -68,9 +68,9 @@ protected function getTranslatorPermissions() { */ function setupTestFields() { parent::setupTestFields(); - $field = FieldConfig::loadByName('comment', 'comment_body'); - $field->translatable = TRUE; - $field->save(); + $field_storage = FieldStorageConfig::loadByName('comment', 'comment_body'); + $field_storage->translatable = TRUE; + $field_storage->save(); } /** diff --git a/core/modules/comment/src/Tests/CommentTypeTest.php b/core/modules/comment/src/Tests/CommentTypeTest.php index a88f714eca07..d136bcb6f005 100644 --- a/core/modules/comment/src/Tests/CommentTypeTest.php +++ b/core/modules/comment/src/Tests/CommentTypeTest.php @@ -9,7 +9,7 @@ use Drupal\comment\Entity\Comment; use Drupal\comment\Entity\CommentType; use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; -use Drupal\field\Entity\FieldConfig; +use Drupal\field\Entity\FieldStorageConfig; use Drupal\field\Entity\FieldInstanceConfig; use Drupal\node\Entity\Node; @@ -116,7 +116,7 @@ public function testCommentTypeDeletion() { $type = $this->createCommentType('foo'); $this->drupalCreateContentType(array('type' => 'page')); \Drupal::service('comment.manager')->addDefaultField('node', 'page', 'foo', CommentItemInterface::OPEN, 'foo'); - $field = FieldConfig::loadByName('node', 'foo'); + $field_storage = FieldStorageConfig::loadByName('node', 'foo'); $this->drupalLogin($this->adminUser); @@ -153,7 +153,7 @@ public function testCommentTypeDeletion() { // Delete the comment and the field. $comment->delete(); - $field->delete(); + $field_storage->delete(); // Attempt to delete the comment type, which should now be allowed. $this->drupalGet('admin/structure/comment/manage/' . $type->id() . '/delete'); $this->assertRaw( diff --git a/core/modules/comment/src/Tests/CommentUninstallTest.php b/core/modules/comment/src/Tests/CommentUninstallTest.php index db58aea35937..00796dc20104 100644 --- a/core/modules/comment/src/Tests/CommentUninstallTest.php +++ b/core/modules/comment/src/Tests/CommentUninstallTest.php @@ -7,7 +7,7 @@ namespace Drupal\comment\Tests; -use Drupal\field\Entity\FieldConfig; +use Drupal\field\Entity\FieldStorageConfig; use Drupal\simpletest\WebTestBase; /** @@ -38,15 +38,15 @@ protected function setUp() { */ function testCommentUninstallWithField() { // Ensure that the field exists before uninstallation. - $field = FieldConfig::loadByName('comment', 'comment_body'); - $this->assertNotNull($field, 'The comment_body field exists.'); + $field_storage = FieldStorageConfig::loadByName('comment', 'comment_body'); + $this->assertNotNull($field_storage, 'The comment_body field exists.'); // Uninstall the comment module which should trigger field deletion. $this->container->get('module_handler')->uninstall(array('comment')); // Check that the field is now deleted. - $field = FieldConfig::loadByName('comment', 'comment_body'); - $this->assertNull($field, 'The comment_body field has been deleted.'); + $field_storage = FieldStorageConfig::loadByName('comment', 'comment_body'); + $this->assertNull($field_storage, 'The comment_body field has been deleted.'); } @@ -55,13 +55,13 @@ function testCommentUninstallWithField() { */ function testCommentUninstallWithoutField() { // Manually delete the comment_body field before module uninstallation. - $field = FieldConfig::loadByName('comment', 'comment_body'); - $this->assertNotNull($field, 'The comment_body field exists.'); - $field->delete(); + $field_storage = FieldStorageConfig::loadByName('comment', 'comment_body'); + $this->assertNotNull($field_storage, 'The comment_body field exists.'); + $field_storage->delete(); // Check that the field is now deleted. - $field = FieldConfig::loadByName('comment', 'comment_body'); - $this->assertNull($field, 'The comment_body field has been deleted.'); + $field_storage = FieldStorageConfig::loadByName('comment', 'comment_body'); + $this->assertNull($field_storage, 'The comment_body field has been deleted.'); // Ensure that uninstallation succeeds even if the field has already been // deleted manually beforehand. diff --git a/core/modules/comment/src/Tests/CommentValidationTest.php b/core/modules/comment/src/Tests/CommentValidationTest.php index d150da08b1b8..391fe0895738 100644 --- a/core/modules/comment/src/Tests/CommentValidationTest.php +++ b/core/modules/comment/src/Tests/CommentValidationTest.php @@ -46,7 +46,7 @@ public function testValidation() { ))->save(); // Add comment field to content. - $this->entityManager->getStorage('field_config')->create(array( + $this->entityManager->getStorage('field_storage_config')->create(array( 'entity_type' => 'node', 'name' => 'comment', 'type' => 'comment', diff --git a/core/modules/config/src/Tests/ConfigExportImportUITest.php b/core/modules/config/src/Tests/ConfigExportImportUITest.php index bd0c70f7a41a..18bee10977af 100644 --- a/core/modules/config/src/Tests/ConfigExportImportUITest.php +++ b/core/modules/config/src/Tests/ConfigExportImportUITest.php @@ -63,27 +63,28 @@ public function testExportImport() { $this->content_type = $this->drupalCreateContentType(); // Create a field. - $this->field = entity_create('field_config', array( - 'name' => drupal_strtolower($this->randomName()), + $this->fieldName = drupal_strtolower($this->randomName()); + $this->fieldStorage = entity_create('field_storage_config', array( + 'name' => $this->fieldName, 'entity_type' => 'node', 'type' => 'text', )); - $this->field->save(); + $this->fieldStorage->save(); entity_create('field_instance_config', array( - 'field' => $this->field, + 'field_storage' => $this->fieldStorage, 'bundle' => $this->content_type->type, ))->save(); entity_get_form_display('node', $this->content_type->type, 'default') - ->setComponent($this->field->name, array( + ->setComponent($this->fieldName, array( 'type' => 'text_textfield', )) ->save(); entity_get_display('node', $this->content_type->type, 'full') - ->setComponent($this->field->name) + ->setComponent($this->fieldName) ->save(); $this->drupalGet('node/add/' . $this->content_type->type); - $this->assertFieldByName("{$this->field->name}[0][value]", '', 'Widget is displayed'); + $this->assertFieldByName("{$this->fieldName}[0][value]", '', 'Widget is displayed'); // Export the configuration. $this->drupalPostForm('admin/config/development/configuration/full/export', array(), 'Export'); @@ -97,18 +98,18 @@ public function testExportImport() { // Delete the custom field. $field_instances = entity_load_multiple('field_instance_config'); foreach ($field_instances as $field_instance) { - if ($field_instance->field_name == $this->field->name) { + if ($field_instance->field_name == $this->fieldName) { $field_instance->delete(); } } - $fields = entity_load_multiple('field_config'); - foreach ($fields as $field) { - if ($field->name == $this->field->name) { - $field->delete(); + $field_storages = entity_load_multiple('field_storage_config'); + foreach ($field_storages as $field_storage) { + if ($field_storage->name == $this->fieldName) { + $field_storage->delete(); } } $this->drupalGet('node/add/' . $this->content_type->type); - $this->assertNoFieldByName("{$this->field->name}[0][value]", '', 'Widget is not displayed'); + $this->assertNoFieldByName("{$this->fieldName}[0][value]", '', 'Widget is not displayed'); // Import the configuration. $filename = 'temporary://' . $this->randomName(); @@ -119,7 +120,7 @@ public function testExportImport() { $this->assertEqual(\Drupal::config('system.site')->get('slogan'), $this->newSlogan); $this->drupalGet('node/add'); - $this->assertFieldByName("{$this->field->name}[0][value]", '', 'Widget is displayed'); + $this->assertFieldByName("{$this->fieldName}[0][value]", '', 'Widget is displayed'); } /** diff --git a/core/modules/config/src/Tests/ConfigImportAllTest.php b/core/modules/config/src/Tests/ConfigImportAllTest.php index f1f86c6d2518..5c941f9c5f30 100644 --- a/core/modules/config/src/Tests/ConfigImportAllTest.php +++ b/core/modules/config/src/Tests/ConfigImportAllTest.php @@ -71,8 +71,8 @@ public function testInstallUninstall() { // example, if a comment field exists then module becomes required and can // not be uninstalled. - $fields = \Drupal::entityManager()->getStorage('field_config')->loadMultiple(); - \Drupal::entityManager()->getStorage('field_config')->delete($fields); + $field_storages = \Drupal::entityManager()->getStorage('field_storage_config')->loadMultiple(); + \Drupal::entityManager()->getStorage('field_storage_config')->delete($field_storages); // Purge the data. field_purge_batch(1000); diff --git a/core/modules/contact/src/Tests/Views/ContactFieldsTest.php b/core/modules/contact/src/Tests/Views/ContactFieldsTest.php index e6e70ad93d1d..da0175e77d82 100644 --- a/core/modules/contact/src/Tests/Views/ContactFieldsTest.php +++ b/core/modules/contact/src/Tests/Views/ContactFieldsTest.php @@ -25,21 +25,21 @@ class ContactFieldsTest extends ViewTestBase { public static $modules = array('field', 'text', 'contact'); /** - * Contains the field definition array attached to contact used for this test. + * Contains the field storage definition for contact used for this test. * - * @var \Drupal\field\Entity\FieldConfig + * @var \Drupal\field\Entity\FieldStorageConfig */ - protected $field; + protected $field_storage; protected function setUp() { parent::setUp(); - $this->field = entity_create('field_config', array( + $this->field_storage = entity_create('field_storage_config', array( 'name' => strtolower($this->randomName()), 'entity_type' => 'contact_message', 'type' => 'text' )); - $this->field->save(); + $this->field_storage->save(); entity_create('contact_category', array( 'id' => 'contact_message', @@ -47,7 +47,7 @@ protected function setUp() { ))->save(); entity_create('field_instance_config', array( - 'field' => $this->field, + 'field_storage' => $this->field_storage, 'bundle' => 'contact_message', ))->save(); @@ -60,7 +60,7 @@ protected function setUp() { public function testViewsData() { // Test that the field is not exposed to views, since contact_message // entities have no storage. - $table_name = ContentEntityDatabaseStorage::_fieldTableName($this->field); + $table_name = ContentEntityDatabaseStorage::_fieldTableName($this->field_storage); $data = $this->container->get('views.views_data')->get($table_name); $this->assertFalse($data, 'The field is not exposed to Views.'); } diff --git a/core/modules/content_translation/content_translation.install b/core/modules/content_translation/content_translation.install index 383d043cdf49..06a355b775aa 100644 --- a/core/modules/content_translation/content_translation.install +++ b/core/modules/content_translation/content_translation.install @@ -89,7 +89,7 @@ function content_translation_install() { module_set_weight('content_translation', 10); \Drupal::service('language_negotiator')->saveConfiguration(LanguageInterface::TYPE_CONTENT, array(LanguageNegotiationUrl::METHOD_ID => 0)); - $config_names = \Drupal::configFactory()->listAll('field.field.'); + $config_names = \Drupal::configFactory()->listAll(\Drupal::entityManager()->getDefinition('field_storage_config')->getConfigPrefix() . '.'); foreach ($config_names as $name) { \Drupal::config($name) ->set('settings.translation_sync', FALSE) @@ -123,7 +123,7 @@ function content_translation_enable() { * Implements hook_uninstall(). */ function content_translation_uninstall() { - $config_names = \Drupal::configFactory()->listAll('field.field.'); + $config_names = \Drupal::configFactory()->listAll(\Drupal::entityManager()->getDefinition('field_storage_config')->getConfigPrefix() . '.'); foreach ($config_names as $name) { \Drupal::config($name) ->clear('settings.translation_sync') diff --git a/core/modules/content_translation/content_translation.module b/core/modules/content_translation/content_translation.module index f7179419c4eb..4fbd597b1d3d 100644 --- a/core/modules/content_translation/content_translation.module +++ b/core/modules/content_translation/content_translation.module @@ -683,7 +683,7 @@ function content_translation_form_field_ui_field_instance_edit_form_alter(array function content_translation_entity_presave(EntityInterface $entity) { // By default no column has to be synchronized. // @todo Replace with own storage in https://drupal.org/node/2224761 - if ($entity->getEntityTypeId() === 'field_config') { + if ($entity->getEntityTypeId() === 'field_storage_config') { $entity->settings += array('translation_sync' => FALSE); } // Synchronization can be enabled per instance. diff --git a/core/modules/content_translation/src/Tests/ContentTranslationSettingsTest.php b/core/modules/content_translation/src/Tests/ContentTranslationSettingsTest.php index 5d877155b51f..445fd5b49ca4 100644 --- a/core/modules/content_translation/src/Tests/ContentTranslationSettingsTest.php +++ b/core/modules/content_translation/src/Tests/ContentTranslationSettingsTest.php @@ -218,7 +218,7 @@ function testFieldTranslatableSettingsUI() { 'entity_type' => 'node', 'type' => 'text', ); - entity_create('field_config', $field)->save(); + entity_create('field_storage_config', $field)->save(); $instance = array( 'field_name' => 'article_text', 'entity_type' => 'node', diff --git a/core/modules/content_translation/src/Tests/ContentTranslationSyncImageTest.php b/core/modules/content_translation/src/Tests/ContentTranslationSyncImageTest.php index 4ce8d844bd95..f8edf5cdc06c 100644 --- a/core/modules/content_translation/src/Tests/ContentTranslationSyncImageTest.php +++ b/core/modules/content_translation/src/Tests/ContentTranslationSyncImageTest.php @@ -49,7 +49,7 @@ protected function setupTestFields() { $this->fieldName = 'field_test_et_ui_image'; $this->cardinality = 3; - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => $this->fieldName, 'entity_type' => $this->entityTypeId, 'type' => 'image', diff --git a/core/modules/content_translation/src/Tests/ContentTranslationTestBase.php b/core/modules/content_translation/src/Tests/ContentTranslationTestBase.php index b299b3f23283..bf6ea2374bac 100644 --- a/core/modules/content_translation/src/Tests/ContentTranslationTestBase.php +++ b/core/modules/content_translation/src/Tests/ContentTranslationTestBase.php @@ -175,7 +175,7 @@ protected function enableTranslation() { protected function setupTestFields() { $this->fieldName = 'field_test_et_ui_test'; - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => $this->fieldName, 'type' => 'text', 'entity_type' => $this->entityTypeId, diff --git a/core/modules/datetime/src/Tests/DateTimeFieldTest.php b/core/modules/datetime/src/Tests/DateTimeFieldTest.php index 924bdc5f0795..7de27423812f 100644 --- a/core/modules/datetime/src/Tests/DateTimeFieldTest.php +++ b/core/modules/datetime/src/Tests/DateTimeFieldTest.php @@ -26,11 +26,11 @@ class DateTimeFieldTest extends WebTestBase { public static $modules = array('node', 'entity_test', 'datetime', 'field_ui'); /** - * A field to use in this test class. + * A field storage to use in this test class. * - * @var \Drupal\field\Entity\FieldConfig + * @var \Drupal\field\Entity\FieldStorageConfig */ - protected $field; + protected $fieldStorage; /** * The instance used in this test class. @@ -52,22 +52,22 @@ function setUp() { $this->drupalLogin($web_user); // Create a field with settings to validate. - $this->field = entity_create('field_config', array( + $this->fieldStorage = entity_create('field_storage_config', array( 'name' => drupal_strtolower($this->randomName()), 'entity_type' => 'entity_test', 'type' => 'datetime', 'settings' => array('datetime_type' => 'date'), )); - $this->field->save(); + $this->fieldStorage->save(); $this->instance = entity_create('field_instance_config', array( - 'field' => $this->field, + 'field_storage' => $this->fieldStorage, 'bundle' => 'entity_test', 'required' => TRUE, )); $this->instance->save(); entity_get_form_display($this->instance->entity_type, $this->instance->bundle, 'default') - ->setComponent($this->field->name, array( + ->setComponent($this->fieldStorage->name, array( 'type' => 'datetime_default', )) ->save(); @@ -78,7 +78,7 @@ function setUp() { 'settings' => array('format_type' => 'medium'), ); entity_get_display($this->instance->entity_type, $this->instance->bundle, 'full') - ->setComponent($this->field->name, $this->display_options) + ->setComponent($this->fieldStorage->name, $this->display_options) ->save(); } @@ -86,7 +86,7 @@ function setUp() { * Tests date field functionality. */ function testDateField() { - $field_name = $this->field->name; + $field_name = $this->fieldStorage->name; // Display creation form. $this->drupalGet('entity_test/add'); @@ -153,10 +153,10 @@ function testDateField() { * Tests date and time field. */ function testDatetimeField() { - $field_name = $this->field->name; + $field_name = $this->fieldStorage->name; // Change the field to a datetime field. - $this->field->settings['datetime_type'] = 'datetime'; - $this->field->save(); + $this->fieldStorage->settings['datetime_type'] = 'datetime'; + $this->fieldStorage->save(); // Display creation form. $this->drupalGet('entity_test/add'); @@ -220,10 +220,10 @@ function testDatetimeField() { * Tests Date List Widget functionality. */ function testDatelistWidget() { - $field_name = $this->field->name; + $field_name = $this->fieldStorage->name; // Change the field to a datetime field. - $this->field->settings['datetime_type'] = 'datetime'; - $this->field->save(); + $this->fieldStorage->settings['datetime_type'] = 'datetime'; + $this->fieldStorage->save(); // Change the widget to a datelist widget. entity_get_form_display($this->instance->entity_type, $this->instance->bundle, 'default') @@ -288,17 +288,17 @@ function testDefaultValue() { // Create a test content type. $this->drupalCreateContentType(array('type' => 'date_content')); - // Create a field with settings to validate. - $field = entity_create('field_config', array( + // Create a field storage with settings to validate. + $field_storage = entity_create('field_storage_config', array( 'name' => drupal_strtolower($this->randomName()), 'entity_type' => 'node', 'type' => 'datetime', 'settings' => array('datetime_type' => 'date'), )); - $field->save(); + $field_storage->save(); $instance = entity_create('field_instance_config', array( - 'field' => $field, + 'field_storage' => $field_storage, 'bundle' => 'date_content', )); $instance->save(); @@ -307,14 +307,14 @@ function testDefaultValue() { $instance_edit = array( 'default_value_input[default_date]' => 'now', ); - $this->drupalPostForm('admin/structure/types/manage/date_content/fields/node.date_content.' . $field->name, $instance_edit, t('Save settings')); + $this->drupalPostForm('admin/structure/types/manage/date_content/fields/node.date_content.' . $field_storage->name, $instance_edit, t('Save settings')); // Check that default value is selected in default value form. - $this->drupalGet('admin/structure/types/manage/date_content/fields/node.date_content.' . $field->name); + $this->drupalGet('admin/structure/types/manage/date_content/fields/node.date_content.' . $field_storage->name); $this->assertRaw('<option value="now" selected="selected">The current date</option>', 'The default value is selected in instance settings page'); // Check if default_date has been stored successfully. - $config_entity = $this->container->get('config.factory')->get('field.instance.node.date_content.' . $field->name)->get(); + $config_entity = $this->container->get('config.factory')->get('field.instance.node.date_content.' . $field_storage->name)->get(); $this->assertEqual($config_entity['default_value'][0]['default_date'], 'now', 'Default value has been stored successfully'); // Clear field cache in order to avoid stale cache values. @@ -323,20 +323,20 @@ function testDefaultValue() { // Create a new node to check that datetime field default value is today. $new_node = entity_create('node', array('type' => 'date_content')); $expected_date = new DrupalDateTime('now', DATETIME_STORAGE_TIMEZONE); - $this->assertEqual($new_node->get($field->name)->offsetGet(0)->value, $expected_date->format(DATETIME_DATE_STORAGE_FORMAT)); + $this->assertEqual($new_node->get($field_storage->name)->offsetGet(0)->value, $expected_date->format(DATETIME_DATE_STORAGE_FORMAT)); // Remove default value. $instance_edit = array( 'default_value_input[default_date]' => '', ); - $this->drupalPostForm('admin/structure/types/manage/date_content/fields/node.date_content.' . $field->name, $instance_edit, t('Save settings')); + $this->drupalPostForm('admin/structure/types/manage/date_content/fields/node.date_content.' . $field_storage->name, $instance_edit, t('Save settings')); // Check that default value is selected in default value form. - $this->drupalGet('admin/structure/types/manage/date_content/fields/node.date_content.' . $field->name); + $this->drupalGet('admin/structure/types/manage/date_content/fields/node.date_content.' . $field_storage->name); $this->assertRaw('<option value="" selected="selected">' . t('- None -') . '</option>', 'The default value is selected in instance settings page'); // Check if default_date has been stored successfully. - $config_entity = $this->container->get('config.factory')->get('field.instance.node.date_content.' . $field->name)->get(); + $config_entity = $this->container->get('config.factory')->get('field.instance.node.date_content.' . $field_storage->name)->get(); $this->assertTrue(empty($config_entity['default_value']), 'Empty default value has been stored successfully'); // Clear field cache in order to avoid stale cache values. @@ -344,7 +344,7 @@ function testDefaultValue() { // Create a new node to check that datetime field default value is today. $new_node = entity_create('node', array('type' => 'date_content')); - $this->assertNull($new_node->get($field->name)->offsetGet(0)->value, 'Default value is not set'); + $this->assertNull($new_node->get($field_storage->name)->offsetGet(0)->value, 'Default value is not set'); } /** @@ -353,9 +353,9 @@ function testDefaultValue() { function testInvalidField() { // Change the field to a datetime field. - $this->field->settings['datetime_type'] = 'datetime'; - $this->field->save(); - $field_name = $this->field->name; + $this->fieldStorage->settings['datetime_type'] = 'datetime'; + $this->fieldStorage->save(); + $field_name = $this->fieldStorage->name; // Display creation form. $this->drupalGet('entity_test/add'); diff --git a/core/modules/datetime/src/Tests/DateTimeItemTest.php b/core/modules/datetime/src/Tests/DateTimeItemTest.php index d2ee54a7d2b8..e12e6f59f6bb 100644 --- a/core/modules/datetime/src/Tests/DateTimeItemTest.php +++ b/core/modules/datetime/src/Tests/DateTimeItemTest.php @@ -29,15 +29,15 @@ public function setUp() { parent::setUp(); // Create a field with settings to validate. - $this->field = entity_create('field_config', array( + $this->fieldStorage = entity_create('field_storage_config', array( 'name' => 'field_datetime', 'type' => 'datetime', 'entity_type' => 'entity_test', 'settings' => array('datetime_type' => 'date'), )); - $this->field->save(); + $this->fieldStorage->save(); $this->instance = entity_create('field_instance_config', array( - 'field' => $this->field, + 'field_storage' => $this->fieldStorage, 'bundle' => 'entity_test', 'settings' => array( 'default_value' => 'blank', diff --git a/core/modules/editor/src/Tests/QuickEditIntegrationTest.php b/core/modules/editor/src/Tests/QuickEditIntegrationTest.php index f24704b30952..531f1ac0c5c1 100644 --- a/core/modules/editor/src/Tests/QuickEditIntegrationTest.php +++ b/core/modules/editor/src/Tests/QuickEditIntegrationTest.php @@ -144,8 +144,8 @@ public function testEditorSelection() { $this->assertEqual('editor', $this->getSelectedEditor($this->entity->id(), $this->field_name), "With cardinality 1, and the full_html text format, the 'editor' editor is selected."); // Editor selection with text processing, cardinality >1 - $this->field_textarea_field->cardinality = 2; - $this->field_textarea_field->save(); + $this->field_textarea_field_storage->cardinality = 2; + $this->field_textarea_field_storage->save(); $this->assertEqual('form', $this->getSelectedEditor($this->entity->id(), $this->field_name), "With cardinality >1, and both items using the full_html text format, the 'form' editor is selected."); } diff --git a/core/modules/entity/src/Tests/EntityDisplayTest.php b/core/modules/entity/src/Tests/EntityDisplayTest.php index d76d603932e0..1e6d05d907f3 100644 --- a/core/modules/entity/src/Tests/EntityDisplayTest.php +++ b/core/modules/entity/src/Tests/EntityDisplayTest.php @@ -140,15 +140,15 @@ public function testFieldComponent() { $this->enableModules(array('field_test')); $field_name = 'test_field'; - // Create a field and an instance. - $field = entity_create('field_config', array( + // Create a field storage and an instance. + $field_storage = entity_create('field_storage_config', array( 'name' => $field_name, 'entity_type' => 'entity_test', 'type' => 'test_field' )); - $field->save(); + $field_storage->save(); $instance = entity_create('field_instance_config', array( - 'field' => $field, + 'field_storage' => $field_storage, 'bundle' => 'entity_test', )); $instance->save(); @@ -161,7 +161,7 @@ public function testFieldComponent() { // Check that providing no options results in default values being used. $display->setComponent($field_name); - $field_type_info = \Drupal::service('plugin.manager.field.field_type')->getDefinition($field->type); + $field_type_info = \Drupal::service('plugin.manager.field.field_type')->getDefinition($field_storage->type); $default_formatter = $field_type_info['default_formatter']; $formatter_settings = \Drupal::service('plugin.manager.field.formatter')->getDefaultSettings($default_formatter); $expected = array( @@ -317,15 +317,15 @@ public function testDeleteFieldInstance() { $this->enableModules(array('field_test')); $field_name = 'test_field'; - // Create a field and an instance. - $field = entity_create('field_config', array( + // Create a field storage and an instance. + $field_storage = entity_create('field_storage_config', array( 'name' => $field_name, 'entity_type' => 'entity_test', 'type' => 'test_field' )); - $field->save(); + $field_storage->save(); $instance = entity_create('field_instance_config', array( - 'field' => $field, + 'field_storage' => $field_storage, 'bundle' => 'entity_test', )); $instance->save(); diff --git a/core/modules/entity/src/Tests/EntityFormDisplayTest.php b/core/modules/entity/src/Tests/EntityFormDisplayTest.php index 32efcc2ab23f..ee7eb9d084b5 100644 --- a/core/modules/entity/src/Tests/EntityFormDisplayTest.php +++ b/core/modules/entity/src/Tests/EntityFormDisplayTest.php @@ -49,16 +49,16 @@ public function testEntityGetFromDisplay() { public function testFieldComponent() { $this->enableModules(array('field_test')); - // Create a field and an instance. + // Create a field storage and an instance. $field_name = 'test_field'; - $field = entity_create('field_config', array( + $field_storage = entity_create('field_storage_config', array( 'name' => $field_name, 'entity_type' => 'entity_test', 'type' => 'test_field' )); - $field->save(); + $field_storage->save(); $instance = entity_create('field_instance_config', array( - 'field' => $field, + 'field_storage' => $field_storage, 'bundle' => 'entity_test', )); $instance->save(); @@ -71,7 +71,7 @@ public function testFieldComponent() { // Check that providing no options results in default values being used. $form_display->setComponent($field_name); - $field_type_info = \Drupal::service('plugin.manager.field.field_type')->getDefinition($field->type); + $field_type_info = \Drupal::service('plugin.manager.field.field_type')->getDefinition($field_storage->type); $default_widget = $field_type_info['default_widget']; $widget_settings = \Drupal::service('plugin.manager.field.widget')->getDefaultSettings($default_widget); $expected = array( @@ -180,15 +180,15 @@ public function testDeleteFieldInstance() { $this->enableModules(array('field_sql_storage', 'field_test')); $field_name = 'test_field'; - // Create a field and an instance. - $field = entity_create('field_config', array( + // Create a field storage and an instance. + $field_storage = entity_create('field_storage_config', array( 'name' => $field_name, 'entity_type' => 'entity_test', 'type' => 'test_field' )); - $field->save(); + $field_storage->save(); $instance = entity_create('field_instance_config', array( - 'field' => $field, + 'field_storage' => $field_storage, 'bundle' => 'entity_test', )); $instance->save(); diff --git a/core/modules/entity_reference/entity_reference.module b/core/modules/entity_reference/entity_reference.module index 48ffc927ea0a..7fcc560f6b41 100644 --- a/core/modules/entity_reference/entity_reference.module +++ b/core/modules/entity_reference/entity_reference.module @@ -7,13 +7,11 @@ use Drupal\Component\Utility\NestedArray; use Drupal\Core\Database\Query\AlterableInterface; -use Drupal\Core\Entity\EntityInterface; -use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Render\Element; use Drupal\Core\Routing\RouteMatchInterface; -use Drupal\field\Entity\FieldConfig; +use Drupal\field\Entity\FieldStorageConfig; use Drupal\field\Entity\FieldInstanceConfig; -use Drupal\field\FieldConfigInterface; +use Drupal\field\FieldStorageConfigInterface; /** * Implements hook_help(). @@ -65,34 +63,34 @@ function entity_reference_field_widget_info_alter(&$info) { } /** - * Implements hook_ENTITY_TYPE_update() for 'field_config'. + * Implements hook_ENTITY_TYPE_update() for 'field_storage_config'. * * Reset the instance handler settings, when the target type is changed. */ -function entity_reference_field_config_update(FieldConfigInterface $field) { - if ($field->type != 'entity_reference') { +function entity_reference_field_storage_config_update(FieldStorageConfigInterface $field_storage) { + if ($field_storage->type != 'entity_reference') { // Only act on entity reference fields. return; } - if ($field->isSyncing()) { + if ($field_storage->isSyncing()) { // Don't change anything during a configuration sync. return; } - if ($field->getSetting('target_type') == $field->original->getSetting('target_type')) { + if ($field_storage->getSetting('target_type') == $field_storage->original->getSetting('target_type')) { // Target type didn't change. return; } - if (empty($field->bundles)) { + if (empty($field_storage->bundles)) { // Field has no instances. return; } - $field_name = $field->getName(); + $field_name = $field_storage->getName(); - foreach ($field->bundles() as $entity_type => $bundles) { + foreach ($field_storage->bundles() as $entity_type => $bundles) { foreach ($bundles as $bundle) { $instance = FieldInstanceConfig::loadByName($entity_type, $bundle, $field_name); $instance->settings['handler_settings'] = array(); @@ -207,11 +205,11 @@ function entity_reference_query_entity_reference_alter(AlterableInterface $query */ function entity_reference_create_instance($entity_type, $bundle, $field_name, $field_label, $target_entity_type, $selection_handler = 'default', $selection_handler_settings = array(), $cardinality = 1) { // Look for or add the specified field to the requested entity bundle. - $field = FieldConfig::loadByName($entity_type, $field_name); + $field_storage = FieldStorageConfig::loadByName($entity_type, $field_name); $instance = FieldInstanceConfig::loadByName($entity_type, $bundle, $field_name); - if (empty($field)) { - $field = array( + if (empty($field_storage)) { + $field_storage = array( 'name' => $field_name, 'type' => 'entity_reference', 'entity_type' => $entity_type, @@ -220,7 +218,7 @@ function entity_reference_create_instance($entity_type, $bundle, $field_name, $f 'target_type' => $target_entity_type, ), ); - entity_create('field_config', $field)->save(); + entity_create('field_storage_config', $field_storage)->save(); } if (empty($instance)) { diff --git a/core/modules/entity_reference/entity_reference.views.inc b/core/modules/entity_reference/entity_reference.views.inc index 47f01791aed9..e35884b796d4 100644 --- a/core/modules/entity_reference/entity_reference.views.inc +++ b/core/modules/entity_reference/entity_reference.views.inc @@ -6,17 +6,17 @@ */ use Drupal\Core\Entity\ContentEntityDatabaseStorage; -use Drupal\field\FieldConfigInterface; +use Drupal\field\FieldStorageConfigInterface; /** * Implements hook_field_views_data(). */ -function entity_reference_field_views_data(FieldConfigInterface $field) { - $data = field_views_field_default_views_data($field); +function entity_reference_field_views_data(FieldStorageConfigInterface $field_storage) { + $data = field_views_field_default_views_data($field_storage); $entity_manager = \Drupal::entityManager(); foreach ($data as $table_name => $table_data) { // Add a relationship to the target entity type. - $target_entity_type_id = $field->getSetting('target_type'); + $target_entity_type_id = $field_storage->getSetting('target_type'); $target_entity_type = $entity_manager->getDefinition($target_entity_type_id); $target_base_table = $target_entity_type->getBaseTable(); @@ -24,31 +24,31 @@ function entity_reference_field_views_data(FieldConfigInterface $field) { // field. $args = array( '@label' => $target_entity_type->getLabel(), - '@field_name' => $field->getName(), + '@field_name' => $field_storage->getName(), ); - $data[$table_name][$field->getName()]['relationship'] = array( + $data[$table_name][$field_storage->getName()]['relationship'] = array( 'id' => 'standard', 'base' => $target_base_table, 'entity type' => $target_entity_type_id, 'base field' => $target_entity_type->getKey('id'), - 'relationship field' => $field->getName() . '_target_id', + 'relationship field' => $field_storage->getName() . '_target_id', 'title' => t('@label referenced from @field_name', $args), 'label' => t('@field_name: @label', $args), ); // Provide a reverse relationship for the entity type that is referenced by // the field. - $pseudo_field_name = 'reverse__' . $field->getTargetEntityTypeId() . '__' . $field->getName(); + $pseudo_field_name = 'reverse__' . $field_storage->getTargetEntityTypeId() . '__' . $field_storage->getName(); $data[$target_base_table][$pseudo_field_name]['relationship'] = array( 'title' => t('@label using @field_name', $args), 'help' => t('Relate each @label with a @field_name.', $args), 'id' => 'entity_reverse', - 'field_name' => $field->getName(), - 'field table' => ContentEntityDatabaseStorage::_fieldTableName($field), - 'field field' => $field->getName() . '_target_id', + 'field_name' => $field_storage->getName(), + 'field table' => ContentEntityDatabaseStorage::_fieldTableName($field_storage), + 'field field' => $field_storage->getName() . '_target_id', 'base' => $target_entity_type->getBaseTable(), 'base field' => $target_entity_type->getKey('id'), - 'label' => t('@field_name', array('@field_name' => $field->getName())), + 'label' => t('@field_name', array('@field_name' => $field_storage->getName())), ); } diff --git a/core/modules/entity_reference/src/ConfigurableEntityReferenceItem.php b/core/modules/entity_reference/src/ConfigurableEntityReferenceItem.php index cabf660aeb66..269ad8c0e5af 100644 --- a/core/modules/entity_reference/src/ConfigurableEntityReferenceItem.php +++ b/core/modules/entity_reference/src/ConfigurableEntityReferenceItem.php @@ -15,7 +15,7 @@ use Drupal\Core\TypedData\AllowedValuesInterface; use Drupal\Core\TypedData\DataDefinition; use Drupal\Core\Validation\Plugin\Validation\Constraint\AllowedValuesConstraint; -use Drupal\field\FieldConfigInterface; +use Drupal\field\FieldStorageConfigInterface; /** * Alternative plugin implementation of the 'entity_reference' field type. @@ -144,7 +144,7 @@ public static function schema(FieldStorageDefinitionInterface $field_definition) $target_type = $field_definition->getSetting('target_type'); $target_type_info = \Drupal::entityManager()->getDefinition($target_type); - if ($target_type_info->isSubclassOf('\Drupal\Core\Entity\ContentEntityInterface') && $field_definition instanceof FieldConfigInterface) { + if ($target_type_info->isSubclassOf('\Drupal\Core\Entity\ContentEntityInterface') && $field_definition instanceof FieldStorageConfigInterface) { $schema['columns']['revision_id'] = array( 'description' => 'The revision ID of the target entity.', 'type' => 'int', diff --git a/core/modules/entity_reference/src/Tests/EntityReferenceAutoCreateTest.php b/core/modules/entity_reference/src/Tests/EntityReferenceAutoCreateTest.php index ecdbeb66ab79..a16b421300bb 100644 --- a/core/modules/entity_reference/src/Tests/EntityReferenceAutoCreateTest.php +++ b/core/modules/entity_reference/src/Tests/EntityReferenceAutoCreateTest.php @@ -29,7 +29,7 @@ function setUp() { $referenced = $this->drupalCreateContentType(); $this->referenced_type = $referenced->type; - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => 'test_field', 'entity_type' => 'node', 'translatable' => FALSE, diff --git a/core/modules/entity_reference/src/Tests/EntityReferenceFieldDefaultValueTest.php b/core/modules/entity_reference/src/Tests/EntityReferenceFieldDefaultValueTest.php index e65d6f903f5e..b93f322011f6 100644 --- a/core/modules/entity_reference/src/Tests/EntityReferenceFieldDefaultValueTest.php +++ b/core/modules/entity_reference/src/Tests/EntityReferenceFieldDefaultValueTest.php @@ -42,15 +42,15 @@ function testEntityReferenceDefaultValue() { // Create a node to be referenced. $referenced_node = $this->drupalCreateNode(array('type' => 'referenced_content')); - $this->field = entity_create('field_config', array( + $this->fieldStorage = entity_create('field_storage_config', array( 'name' => drupal_strtolower($this->randomName()), 'entity_type' => 'node', 'type' => 'entity_reference', 'settings' => array('target_type' => 'node'), )); - $this->field->save(); + $this->fieldStorage->save(); $this->instance = entity_create('field_instance_config', array( - 'field' => $this->field, + 'field_storage' => $this->fieldStorage, 'bundle' => 'reference_content', 'settings' => array( 'handler' => 'default', @@ -64,16 +64,16 @@ function testEntityReferenceDefaultValue() { // Set created node as default_value. $instance_edit = array( - 'default_value_input[' . $this->field->name . '][0][target_id]' => $referenced_node->getTitle() . ' (' .$referenced_node->id() . ')', + 'default_value_input[' . $this->fieldStorage->name . '][0][target_id]' => $referenced_node->getTitle() . ' (' .$referenced_node->id() . ')', ); - $this->drupalPostForm('admin/structure/types/manage/reference_content/fields/node.reference_content.' . $this->field->name, $instance_edit, t('Save settings')); + $this->drupalPostForm('admin/structure/types/manage/reference_content/fields/node.reference_content.' . $this->fieldStorage->name, $instance_edit, t('Save settings')); // Check that default value is selected in default value form. - $this->drupalGet('admin/structure/types/manage/reference_content/fields/node.reference_content.' . $this->field->name); - $this->assertRaw('name="default_value_input[' . $this->field->name . '][0][target_id]" value="' . $referenced_node->getTitle() .' (' .$referenced_node->id() . ')', 'The default value is selected in instance settings page'); + $this->drupalGet('admin/structure/types/manage/reference_content/fields/node.reference_content.' . $this->fieldStorage->name); + $this->assertRaw('name="default_value_input[' . $this->fieldStorage->name . '][0][target_id]" value="' . $referenced_node->getTitle() .' (' .$referenced_node->id() . ')', 'The default value is selected in instance settings page'); // Check if the ID has been converted to UUID in config entity. - $config_entity = $this->container->get('config.factory')->get('field.instance.node.reference_content.' . $this->field->name)->get(); + $config_entity = $this->container->get('config.factory')->get('field.instance.node.reference_content.' . $this->fieldStorage->name)->get(); $this->assertTrue(isset($config_entity['default_value'][0]['target_uuid']), 'Default value contains target_uuid property'); $this->assertEqual($config_entity['default_value'][0]['target_uuid'], $referenced_node->uuid(), 'Content uuid and config entity uuid are the same'); @@ -82,7 +82,7 @@ function testEntityReferenceDefaultValue() { // Create a new node to check that UUID has been converted to numeric ID. $new_node = entity_create('node', array('type' => 'reference_content')); - $this->assertEqual($new_node->get($this->field->name)->offsetGet(0)->target_id, $referenced_node->id()); + $this->assertEqual($new_node->get($this->fieldStorage->name)->offsetGet(0)->target_id, $referenced_node->id()); } } diff --git a/core/modules/entity_reference/src/Tests/EntityReferenceFieldTest.php b/core/modules/entity_reference/src/Tests/EntityReferenceFieldTest.php index 7c157df85777..0024d4f31262 100644 --- a/core/modules/entity_reference/src/Tests/EntityReferenceFieldTest.php +++ b/core/modules/entity_reference/src/Tests/EntityReferenceFieldTest.php @@ -7,10 +7,8 @@ namespace Drupal\entity_reference\Tests; -use Drupal\Core\Field\FieldStorageDefinitionInterface; -use Drupal\field\Entity\FieldConfig; -use Drupal\field\Entity\FieldInstanceConfig; use Drupal\system\Tests\Entity\EntityUnitTestBase; +use Drupal\Core\Field\FieldStorageDefinitionInterface; /** * Tests for the entity reference field. @@ -47,20 +45,6 @@ class EntityReferenceFieldTest extends EntityUnitTestBase { */ protected $fieldName = 'field_test'; - /** - * A field array. - * - * @var array - */ - protected $field; - - /** - * An associative array of field instance data. - * - * @var array - */ - protected $instance; - /** * Modules to enable. * @@ -85,8 +69,6 @@ public function setUp() { FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED ); - $this->field = FieldConfig::loadByName($this->entityType, $this->fieldName); - $this->instance = FieldInstanceConfig::loadByName($this->entityType, $this->bundle, $this->fieldName); } /** diff --git a/core/modules/entity_reference/src/Tests/EntityReferenceFormatterTest.php b/core/modules/entity_reference/src/Tests/EntityReferenceFormatterTest.php index 071f44655bf5..e3653bb879f0 100644 --- a/core/modules/entity_reference/src/Tests/EntityReferenceFormatterTest.php +++ b/core/modules/entity_reference/src/Tests/EntityReferenceFormatterTest.php @@ -58,7 +58,7 @@ public function setUp() { // Set up a field, so that the entity that'll be referenced bubbles up a // cache tag when rendering it entirely. - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => 'body', 'entity_type' => $this->entityType, 'type' => 'text', diff --git a/core/modules/entity_reference/src/Tests/EntityReferenceSelectionAccessTest.php b/core/modules/entity_reference/src/Tests/EntityReferenceSelectionAccessTest.php index ae9b55a0f504..6b71da5c8cbf 100644 --- a/core/modules/entity_reference/src/Tests/EntityReferenceSelectionAccessTest.php +++ b/core/modules/entity_reference/src/Tests/EntityReferenceSelectionAccessTest.php @@ -55,8 +55,8 @@ protected function assertReferenceable(FieldDefinitionInterface $field_definitio * Test the node-specific overrides of the entity handler. */ public function testNodeHandler() { - // Create a field and instance. - $field = entity_create('field_config', array( + // Create a field storage and instance. + $field_storage = entity_create('field_storage_config', array( 'name' => 'test_field', 'entity_type' => 'entity_test', 'translatable' => FALSE, @@ -67,9 +67,9 @@ public function testNodeHandler() { 'type' => 'entity_reference', 'cardinality' => '1', )); - $field->save(); + $field_storage->save(); $instance = entity_create('field_instance_config', array( - 'field' => $field, + 'field_storage' => $field_storage, 'bundle' => 'test_bundle', 'settings' => array( 'handler' => 'default', @@ -198,8 +198,8 @@ public function testNodeHandler() { * Test the user-specific overrides of the entity handler. */ public function testUserHandler() { - // Create a field and instance. - $field = entity_create('field_config', array( + // Create a field storage and instance. + $field_storage = entity_create('field_storage_config', array( 'name' => 'test_field', 'entity_type' => 'entity_test', 'translatable' => FALSE, @@ -209,9 +209,9 @@ public function testUserHandler() { 'type' => 'entity_reference', 'cardinality' => '1', )); - $field->save(); + $field_storage->save(); $instance = entity_create('field_instance_config', array( - 'field' => $field, + 'field_storage' => $field_storage, 'bundle' => 'test_bundle', 'settings' => array( 'handler' => 'default', @@ -342,8 +342,8 @@ public function testUserHandler() { * Test the comment-specific overrides of the entity handler. */ public function testCommentHandler() { - // Create a field and instance. - $field = entity_create('field_config', array( + // Create a field storage and instance. + $field_storage = entity_create('field_storage_config', array( 'name' => 'test_field', 'entity_type' => 'entity_test', 'translatable' => FALSE, @@ -354,9 +354,9 @@ public function testCommentHandler() { 'type' => 'entity_reference', 'cardinality' => '1', )); - $field->save(); + $field_storage->save(); $instance = entity_create('field_instance_config', array( - 'field' => $field, + 'field_storage' => $field_storage, 'bundle' => 'test_bundle', 'settings' => array( 'handler' => 'default', diff --git a/core/modules/entity_reference/src/Tests/EntityReferenceSelectionSortTest.php b/core/modules/entity_reference/src/Tests/EntityReferenceSelectionSortTest.php index 0ae4acc847b7..34dd67aaedb6 100644 --- a/core/modules/entity_reference/src/Tests/EntityReferenceSelectionSortTest.php +++ b/core/modules/entity_reference/src/Tests/EntityReferenceSelectionSortTest.php @@ -31,7 +31,7 @@ function setUp() { */ public function testSort() { // Add text field to entity, to sort by. - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => 'field_text', 'entity_type' => 'node', 'type' => 'text', @@ -48,8 +48,8 @@ public function testSort() { ))->save(); - // Create a field and instance. - $field = entity_create('field_config', array( + // Create a field storage and instance. + $field_storage = entity_create('field_storage_config', array( 'name' => 'test_field', 'entity_type' => 'entity_test', 'translatable' => FALSE, @@ -59,9 +59,9 @@ public function testSort() { 'type' => 'entity_reference', 'cardinality' => 1, )); - $field->save(); + $field_storage->save(); $instance = entity_create('field_instance_config', array( - 'field' => $field, + 'field_storage' => $field_storage, 'entity_type' => 'entity_test', 'bundle' => 'test_bundle', 'settings' => array( diff --git a/core/modules/entity_reference/src/Tests/Views/EntityReferenceRelationshipTest.php b/core/modules/entity_reference/src/Tests/Views/EntityReferenceRelationshipTest.php index a2c1dbdeb585..3f9d7b1dff2f 100644 --- a/core/modules/entity_reference/src/Tests/Views/EntityReferenceRelationshipTest.php +++ b/core/modules/entity_reference/src/Tests/Views/EntityReferenceRelationshipTest.php @@ -8,7 +8,7 @@ namespace Drupal\entity_reference\Tests\Views; use Drupal\Core\Field\FieldStorageDefinitionInterface; -use Drupal\field\Entity\FieldConfig; +use Drupal\field\Entity\FieldStorageConfig; use Drupal\field\Entity\FieldInstanceConfig; use Drupal\views\Tests\ViewTestData; use Drupal\views\Tests\ViewUnitTestBase; @@ -53,7 +53,7 @@ protected function setUp() { ViewTestData::createTestViews(get_class($this), array('entity_reference_test_views')); - $field = FieldConfig::create(array( + $field_storage = FieldStorageConfig::create(array( 'settings' => array( 'target_type' => 'entity_test', ), @@ -62,7 +62,7 @@ protected function setUp() { 'type' => 'entity_reference', 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED, )); - $field->save(); + $field_storage->save(); $instance = FieldInstanceConfig::create(array( 'entity_type' => 'entity_test', diff --git a/core/modules/entity_reference/src/Tests/Views/SelectionTest.php b/core/modules/entity_reference/src/Tests/Views/SelectionTest.php index cbd604568b8f..dbfe0f6a4792 100644 --- a/core/modules/entity_reference/src/Tests/Views/SelectionTest.php +++ b/core/modules/entity_reference/src/Tests/Views/SelectionTest.php @@ -33,8 +33,8 @@ public function testSelectionHandler() { $nodes[$node->getType()][$node->id()] = $node->label(); } - // Create a field and instance. - $field = entity_create('field_config', array( + // Create a field storage and instance. + $field_storage = entity_create('field_storage_config', array( 'name' => 'test_field', 'entity_type' => 'entity_test', 'translatable' => FALSE, @@ -44,9 +44,9 @@ public function testSelectionHandler() { 'type' => 'entity_reference', 'cardinality' => '1', )); - $field->save(); + $field_storage->save(); $instance = entity_create('field_instance_config', array( - 'field' => $field, + 'field_storage' => $field_storage, 'bundle' => 'test_bundle', 'settings' => array( 'handler' => 'views', diff --git a/core/modules/field/config/schema/field.schema.yml b/core/modules/field/config/schema/field.schema.yml index 671d02414024..ce97e1932e92 100644 --- a/core/modules/field/config/schema/field.schema.yml +++ b/core/modules/field/config/schema/field.schema.yml @@ -8,7 +8,7 @@ field.settings: type: integer label: 'Maximum number of field data records to purge' -field.field.*.*: +field.storage.*.*: type: config_entity label: 'Field' mapping: diff --git a/core/modules/field/field.api.php b/core/modules/field/field.api.php index fed48ca1065d..5b50dce9cc9d 100644 --- a/core/modules/field/field.api.php +++ b/core/modules/field/field.api.php @@ -237,7 +237,7 @@ function hook_field_info_max_weight($entity_type, $bundle, $context, $context_mo */ /** - * Forbid a field update from occurring. + * Forbid a field storage update from occurring. * * Any module may forbid any update for any reason. For example, the * field's storage module might forbid an update if it would change @@ -249,47 +249,47 @@ function hook_field_info_max_weight($entity_type, $bundle, $context, $context_mo * To forbid the update from occurring, throw a * \Drupal\Core\Entity\Exception\StorageDefinitionUpdateForbiddenException. * - * @param \Drupal\field\FieldConfigInterface $field - * The field as it will be post-update. - * @param \Drupal\field\FieldConfigInterface $prior_field - * The field as it is pre-update. + * @param \Drupal\field\FieldStorageConfigInterface $field_storage + * The field storage as it will be post-update. + * @param \Drupal\field\FieldStorageConfigInterface $prior_field_storage + * The field storage as it is pre-update. * * @see entity_crud */ -function hook_field_config_update_forbid(\Drupal\field\FieldConfigInterface $field, \Drupal\field\FieldConfigInterface $prior_field) { +function hook_field_storage_config_update_forbid(\Drupal\field\FieldStorageConfigInterface $field_storage, \Drupal\field\FieldStorageConfigInterface $prior_field_storage) { // A 'list' field stores integer keys mapped to display values. If // the new field will have fewer values, and any data exists for the // abandoned keys, the field will have no way to display them. So, // forbid such an update. - if ($field->hasData() && count($field['settings']['allowed_values']) < count($prior_field['settings']['allowed_values'])) { + if ($field_storage->hasData() && count($field_storage['settings']['allowed_values']) < count($prior_field_storage['settings']['allowed_values'])) { // Identify the keys that will be lost. - $lost_keys = array_diff(array_keys($field['settings']['allowed_values']), array_keys($prior_field['settings']['allowed_values'])); + $lost_keys = array_diff(array_keys($field_storage['settings']['allowed_values']), array_keys($prior_field_storage['settings']['allowed_values'])); // If any data exist for those keys, forbid the update. $query = new EntityFieldQuery(); $found = $query - ->fieldCondition($prior_field['field_name'], 'value', $lost_keys) + ->fieldCondition($prior_field_storage['field_name'], 'value', $lost_keys) ->range(0, 1) ->execute(); if ($found) { - throw new \Drupal\Core\Entity\Exception\FieldStorageDefinitionUpdateForbiddenException("Cannot update a list field not to include keys with existing data"); + throw new \Drupal\Core\Entity\Exception\FieldStorageDefinitionUpdateForbiddenException("Cannot update a list field storage not to include keys with existing data"); } } } /** - * Acts when a field record is being purged. + * Acts when a field storage definition is being purged. * - * In field_purge_field(), after the field definition has been removed from the - * the system, the entity storage has purged stored field data, and the field - * info cache has been cleared, this hook is invoked on all modules to allow - * them to respond to the field being purged. + * In field_purge_field_storage(), after the storage definition has been removed + * from the system, the entity storage has purged stored field data, and the + * field definitions cache has been cleared, this hook is invoked on all modules + * to allow them to respond to the field storage being purged. * - * @param $field - * The field being purged. + * @param $field_storage \Drupal\field\Entity\FieldStorageConfig + * The field storage being purged. */ -function hook_field_purge_field($field) { - db_delete('my_module_field_info') - ->condition('id', $field['id']) +function hook_field_purge_field_storage(\Drupal\field\Entity\FieldStorageConfig $field_storage) { + db_delete('my_module_field_storage_info') + ->condition('uuid', $field_storage->uuid()) ->execute(); } diff --git a/core/modules/field/field.module b/core/modules/field/field.module index 25e09e35a8bd..444a92dbf432 100644 --- a/core/modules/field/field.module +++ b/core/modules/field/field.module @@ -126,7 +126,7 @@ function field_system_info_alter(&$info, Extension $file, $type) { // It is not safe to call entity_load_multiple_by_properties() during // maintenance mode. if ($type == 'module' && !defined('MAINTENANCE_MODE')) { - $fields = entity_load_multiple_by_properties('field_config', array('module' => $file->getName(), 'include_deleted' => TRUE)); + $fields = entity_load_multiple_by_properties('field_storage_config', array('module' => $file->getName(), 'include_deleted' => TRUE)); if ($fields) { $info['required'] = TRUE; @@ -163,15 +163,15 @@ function field_entity_field_storage_info(\Drupal\Core\Entity\EntityTypeInterface if ($entity_type->isFieldable()) { // Query by filtering on the ID as this is more efficient than filtering // on the entity_type property directly. - $ids = \Drupal::entityQuery('field_config') + $ids = \Drupal::entityQuery('field_storage_config') ->condition('id', $entity_type->id() . '.', 'STARTS_WITH') ->execute(); // Fetch all fields and key them by field name. - $field_configs = entity_load_multiple('field_config', $ids); + $field_storages = entity_load_multiple('field_storage_config', $ids); $result = array(); - foreach ($field_configs as $field_config) { - $result[$field_config->getName()] = $field_config; + foreach ($field_storages as $field_storage) { + $result[$field_storage->getName()] = $field_storage; } return $result; } @@ -324,11 +324,11 @@ function field_hook_info() { * Implements hook_config_import_steps_alter(). */ function field_config_import_steps_alter(&$sync_steps, ConfigImporter $config_importer) { - $fields = \Drupal\field\ConfigImporterFieldPurger::getFieldsToPurge( + $field_storages = \Drupal\field\ConfigImporterFieldPurger::getFieldStoragesToPurge( $config_importer->getStorageComparer()->getSourceStorage()->read('core.extension'), $config_importer->getStorageComparer()->getChangelist('delete') ); - if ($fields) { + if ($field_storages) { // Add a step to the beginning of the configuration synchronization process // to purge field data where the module that provides the field is being // uninstalled. @@ -348,16 +348,16 @@ function field_form_config_admin_import_form_alter(&$form, &$form_state) { // Only display the message when there is a storage comparer available and the // form is not submitted. if (isset($form_state['storage_comparer']) && empty($form_state['input'])) { - $fields = \Drupal\field\ConfigImporterFieldPurger::getFieldsToPurge( + $field_storages = \Drupal\field\ConfigImporterFieldPurger::getFieldStoragesToPurge( $form_state['storage_comparer']->getSourceStorage()->read('core.extension'), $form_state['storage_comparer']->getChangelist('delete') ); - if ($fields) { - foreach ($fields as $field) { + if ($field_storages) { + foreach ($field_storages as $field) { $field_labels[] = $field->label(); } drupal_set_message(\Drupal::translation()->formatPlural( - count($fields), + count($field_storages), 'This synchronization will delete data from the field %fields.', 'This synchronization will delete data from the fields: %fields.', array('%fields' => implode(', ', $field_labels)) diff --git a/core/modules/field/field.purge.inc b/core/modules/field/field.purge.inc index 4a289cf58c98..a17e6f2dda98 100644 --- a/core/modules/field/field.purge.inc +++ b/core/modules/field/field.purge.inc @@ -5,7 +5,8 @@ * Provides support for field data purge after mass deletion. */ -use Drupal\field\Entity\FieldConfig; +use Drupal\field\Entity\FieldStorageConfig; +use Drupal\field\FieldStorageConfigInterface; use Drupal\field\FieldException; /** @@ -68,18 +69,19 @@ * * @param $batch_size * The maximum number of field data records to purge before returning. - * @param string $field_uuid - * (optional) Limit the purge to a specific field. + * @param string $field_storage_uuid + * (optional) Limit the purge to a specific field storage. */ -function field_purge_batch($batch_size, $field_uuid = NULL) { - // Retrieve all deleted field instances. We cannot use field_info_instances() - // because that function does not return deleted instances. - if ($field_uuid) { - $instances = entity_load_multiple_by_properties('field_instance_config', array('deleted' => TRUE, 'include_deleted' => TRUE, 'field_uuid' => $field_uuid)); - } - else { - $instances = entity_load_multiple_by_properties('field_instance_config', array('deleted' => TRUE, 'include_deleted' => TRUE)); +function field_purge_batch($batch_size, $field_storage_uuid = NULL) { + $properties = array( + 'deleted' => TRUE, + 'include_deleted' => TRUE, + ); + if ($field_storage_uuid) { + $properties['field_storage_uuid'] = $field_storage_uuid; } + $instances = entity_load_multiple_by_properties('field_instance_config', $properties); + $info = \Drupal::entityManager()->getDefinitions(); foreach ($instances as $instance) { $entity_type = $instance->entity_type; @@ -103,11 +105,12 @@ function field_purge_batch($batch_size, $field_uuid = NULL) { } } - // Retrieve all deleted fields. Any that have no instances can be purged. - $deleted_fields = \Drupal::state()->get('field.field.deleted') ?: array(); - foreach ($deleted_fields as $field) { - $field = new FieldConfig($field); - if ($field_uuid && $field->uuid() != $field_uuid) { + // Retrieve all deleted field storages. Any that have no instances can be + // purged. + $deleted_storages = \Drupal::state()->get('field.storage.deleted') ?: array(); + foreach ($deleted_storages as $field_storage) { + $field_storage = new FieldStorageConfig($field_storage); + if ($field_storage_uuid && $field_storage->uuid() != $field_storage_uuid) { // If a specific UUID is provided, only purge the corresponding field. continue; } @@ -115,13 +118,13 @@ function field_purge_batch($batch_size, $field_uuid = NULL) { // We cannot purge anything if the entity type is unknown (e.g. the // providing module was uninstalled). // @todo Revisit after https://drupal.org/node/2080823. - if (!isset($info[$field->entity_type])) { + if (!isset($info[$field_storage->entity_type])) { continue; } - $instances = entity_load_multiple_by_properties('field_instance_config', array('field_id' => $field->uuid(), 'include_deleted' => TRUE)); + $instances = entity_load_multiple_by_properties('field_instance_config', array('field_storage_uuid' => $field_storage->uuid(), 'include_deleted' => TRUE)); if (empty($instances)) { - field_purge_field($field); + field_purge_field_storage($field_storage); } } } @@ -151,25 +154,25 @@ function field_purge_instance($instance) { * This function assumes all instances for the field has already been purged, * and should only be called by field_purge_batch(). * - * @param $field - * The field record to purge. + * @param \Drupal\field\FieldStorageConfigInterface $field_storage + * The field storage to purge. */ -function field_purge_field($field) { - $instances = entity_load_multiple_by_properties('field_instance_config', array('field_id' => $field->uuid(), 'include_deleted' => TRUE)); +function field_purge_field_storage(FieldStorageConfigInterface $field_storage) { + $instances = entity_load_multiple_by_properties('field_instance_config', array('field_storage_uuid' => $field_storage->uuid(), 'include_deleted' => TRUE)); if (count($instances) > 0) { - throw new FieldException(t('Attempt to purge a field @field_name that still has instances.', array('@field_name' => $field->getName()))); + throw new FieldException(t('Attempt to purge a field storage @field_name that still has instances.', array('@field_name' => $field_storage->getName()))); } $state = \Drupal::state(); - $deleted_fields = $state->get('field.field.deleted'); - unset($deleted_fields[$field->uuid()]); - $state->set('field.field.deleted', $deleted_fields); + $deleted_storages = $state->get('field.storage.deleted'); + unset($deleted_storages[$field_storage->uuid()]); + $state->set('field.storage.deleted', $deleted_storages); // Notify the storage layer. - \Drupal::entityManager()->getStorage($field->entity_type)->finalizePurge($field); + \Drupal::entityManager()->getStorage($field_storage->entity_type)->finalizePurge($field_storage); // Invoke external hooks after the cache is cleared for API consistency. - \Drupal::moduleHandler()->invokeAll('field_purge_field', array($field)); + \Drupal::moduleHandler()->invokeAll('field_purge_field_storage', array($field_storage)); } /** diff --git a/core/modules/field/field.views.inc b/core/modules/field/field.views.inc index f74e97c1b48b..f5f1b3385e03 100644 --- a/core/modules/field/field.views.inc +++ b/core/modules/field/field.views.inc @@ -8,7 +8,7 @@ use Drupal\Component\Utility\NestedArray; use Drupal\Core\Entity\ContentEntityDatabaseStorage; use Drupal\Core\Entity\EntityStorageInterface; -use Drupal\field\FieldConfigInterface; +use Drupal\field\FieldStorageConfigInterface; use Drupal\field\FieldInstanceConfigInterface; /** @@ -21,7 +21,7 @@ function field_views_data() { $data = array(); $module_handler = \Drupal::moduleHandler(); - foreach (\Drupal::entityManager()->getStorage('field_config')->loadMultiple() as $field) { + foreach (\Drupal::entityManager()->getStorage('field_storage_config')->loadMultiple() as $field) { if (_field_views_is_sql_entity_type($field)) { $result = (array) $module_handler->invoke($field->module, 'field_views_data', array($field)); if (empty($result)) { @@ -47,7 +47,7 @@ function field_views_data() { * in field_views_data. */ function field_views_data_alter(&$data) { - foreach (\Drupal::entityManager()->getStorage('field_config')->loadMultiple() as $field) { + foreach (\Drupal::entityManager()->getStorage('field_storage_config')->loadMultiple() as $field) { if (_field_views_is_sql_entity_type($field)) { $function = $field->module . '_field_views_data_views_data_alter'; if (function_exists($function)) { @@ -60,15 +60,15 @@ function field_views_data_alter(&$data) { /** * Determines whether the entity type the field appears in is SQL based. * - * @param \Drupal\field\FieldConfigInterface $field - * The field definition. + * @param \Drupal\field\FieldStorageConfigInterface $field_storage + * The field storage definition. * * @return bool * True if the entity type uses ContentEntityDatabaseStorage. */ -function _field_views_is_sql_entity_type(FieldConfigInterface $field) { +function _field_views_is_sql_entity_type(FieldStorageConfigInterface $field_storage) { $entity_manager = \Drupal::entityManager(); - return $entity_manager->hasDefinition($field->entity_type) && $entity_manager->getStorage($field->entity_type) instanceof ContentEntityDatabaseStorage; + return $entity_manager->hasDefinition($field_storage->entity_type) && $entity_manager->getStorage($field_storage->entity_type) instanceof ContentEntityDatabaseStorage; } /** @@ -103,30 +103,30 @@ function field_views_field_label($entity_type, $field_name) { /** * Default views data implementation for a field. * - * @param \Drupal\field\FieldConfigInterface $field + * @param \Drupal\field\FieldStorageConfigInterface $field_storage * The field definition. * * @return array * The default views data for the field. */ -function field_views_field_default_views_data(FieldConfigInterface $field) { +function field_views_field_default_views_data(FieldStorageConfigInterface $field_storage) { $data = array(); // Check the field type is available. - if (!\Drupal::service('plugin.manager.field.field_type')->hasDefinition($field->getType())) { + if (!\Drupal::service('plugin.manager.field.field_type')->hasDefinition($field_storage->getType())) { return $data; } // Check the field has instances. - if (!$field->getBundles()) { + if (!$field_storage->getBundles()) { return $data; } - $field_name = $field->getName(); - $field_columns = $field->getColumns(); + $field_name = $field_storage->getName(); + $field_columns = $field_storage->getColumns(); // Grab information about the entity type tables. $entity_manager = \Drupal::entityManager(); - $entity_type_id = $field->entity_type; + $entity_type_id = $field_storage->entity_type; $entity_type = $entity_manager->getDefinition($entity_type_id); if (!$entity_table = $entity_type->getBaseTable()) { return $data; @@ -141,13 +141,13 @@ function field_views_field_default_views_data(FieldConfigInterface $field) { // Description of the field tables. $field_tables = array( EntityStorageInterface::FIELD_LOAD_CURRENT => array( - 'table' => ContentEntityDatabaseStorage::_fieldTableName($field), + 'table' => ContentEntityDatabaseStorage::_fieldTableName($field_storage), 'alias' => "{$entity_type_id}__{$field_name}", ), ); if ($supports_revisions) { $field_tables[EntityStorageInterface::FIELD_LOAD_REVISION] = array( - 'table' => ContentEntityDatabaseStorage::_fieldRevisionTableName($field), + 'table' => ContentEntityDatabaseStorage::_fieldRevisionTableName($field_storage), 'alias' => "{$entity_type_id}_revision__{$field_name}", ); } @@ -174,11 +174,11 @@ function field_views_field_default_views_data(FieldConfigInterface $field) { $group_name = $entity_type->getLabel(); // Get the list of bundles the field appears in. - $bundles_names = $field->getBundles(); + $bundles_names = $field_storage->getBundles(); // Build the list of additional fields to add to queries. $add_fields = array('delta', 'langcode', 'bundle'); foreach (array_keys($field_columns) as $column) { - $add_fields[] = ContentEntityDatabaseStorage::_fieldColumnName($field, $column); + $add_fields[] = ContentEntityDatabaseStorage::_fieldColumnName($field_storage, $column); } // Determine the label to use for the field. We don't have a label available // at the field level, so we just go through all instances and take the one @@ -302,10 +302,10 @@ function field_views_field_default_views_data(FieldConfigInterface $field) { else { $group = t('@group (historical data)', array('@group' => $group_name)); } - $column_real_name = ContentEntityDatabaseStorage::_fieldColumnName($field, $column); + $column_real_name = ContentEntityDatabaseStorage::_fieldColumnName($field_storage, $column); // Load all the fields from the table by default. - $field_sql_schema = ContentEntityDatabaseStorage::_fieldSqlSchema($field); + $field_sql_schema = ContentEntityDatabaseStorage::_fieldSqlSchema($field_storage); $additional_fields = array_keys($field_sql_schema[$table]['fields']); $data[$table_alias][$column_real_name] = array( @@ -370,7 +370,7 @@ function field_views_field_default_views_data(FieldConfigInterface $field) { } // Expose additional delta column for multiple value fields. - if ($field->isMultiple()) { + if ($field_storage->isMultiple()) { $title_delta = t('@label (!name:delta)', array('@label' => $label, '!name' => $field_name)); $title_short_delta = t('@label:delta', array('@label' => $label)); @@ -412,7 +412,7 @@ function field_views_field_default_views_data(FieldConfigInterface $field) { } // Expose additional language column for translatable fields. - if ($field->isTranslatable()) { + if ($field_storage->isTranslatable()) { $title_language = t('@label (!name:language)', array('@label' => $label, '!name' => $field_name)); $title_short_language = t('@label:language', array('@label' => $label)); @@ -461,15 +461,15 @@ function field_views_field_default_views_data(FieldConfigInterface $field) { /** * Have a different filter handler for lists. This should allow to select values of the list. */ -function list_field_views_data($field) { - $data = field_views_field_default_views_data($field); +function list_field_views_data(FieldStorageConfigInterface $field_storage) { + $data = field_views_field_default_views_data($field_storage); foreach ($data as $table_name => $table_data) { foreach ($table_data as $field_name => $field_data) { if (isset($field_data['filter']) && $field_name != 'delta') { $data[$table_name][$field_name]['filter']['id'] = 'field_list'; } if (isset($field_data['argument']) && $field_name != 'delta') { - if ($field->getType() == 'list_text') { + if ($field_storage->getType() == 'list_text') { $data[$table_name][$field_name]['argument']['id'] = 'field_list_string'; } else { diff --git a/core/modules/field/src/ConfigImporterFieldPurger.php b/core/modules/field/src/ConfigImporterFieldPurger.php index 74f7acde1d91..f7629541ae67 100644 --- a/core/modules/field/src/ConfigImporterFieldPurger.php +++ b/core/modules/field/src/ConfigImporterFieldPurger.php @@ -9,6 +9,7 @@ use Drupal\Core\Config\ConfigImporter; use Drupal\Core\Config\Entity\ConfigEntityStorage; +use Drupal\field\Entity\FieldStorageConfig; /** * Processes field purges before a configuration synchronization. @@ -31,27 +32,27 @@ public static function process(array &$context, ConfigImporter $config_importer) static::initializeSandbox($context, $config_importer); } - // Get the list of fields to purge. - $fields = static::getFieldsToPurge($context['sandbox']['field']['extensions'], $config_importer->getUnprocessedConfiguration('delete')); - // Get the first field to process. - $field = reset($fields); - if (!isset($context['sandbox']['field']['current_field_id']) || $context['sandbox']['field']['current_field_id'] != $field->id()) { - $context['sandbox']['field']['current_field_id'] = $field->id(); - // If the field has not been deleted yet we need to do that. This is the - // case when the field deletion is staged. - if (!$field->deleted) { - $field->delete(); + // Get the list of field storages to purge. + $field_storages = static::getFieldStoragesToPurge($context['sandbox']['field']['extensions'], $config_importer->getUnprocessedConfiguration('delete')); + // Get the first field storage to process. + $field_storage = reset($field_storages); + if (!isset($context['sandbox']['field']['current_storage_id']) || $context['sandbox']['field']['current_storage_id'] != $field_storage->id()) { + $context['sandbox']['field']['current_storage_id'] = $field_storage->id(); + // If the storage has not been deleted yet we need to do that. This is the + // case when the storage deletion is staged. + if (!$field_storage->deleted) { + $field_storage->delete(); } } - field_purge_batch($context['sandbox']['field']['purge_batch_size'], $field->uuid()); + field_purge_batch($context['sandbox']['field']['purge_batch_size'], $field_storage->uuid()); $context['sandbox']['field']['current_progress']++; - $fields_to_delete_count = count(static::getFieldsToPurge($context['sandbox']['field']['extensions'], $config_importer->getUnprocessedConfiguration('delete'))); + $fields_to_delete_count = count(static::getFieldStoragesToPurge($context['sandbox']['field']['extensions'], $config_importer->getUnprocessedConfiguration('delete'))); if ($fields_to_delete_count == 0) { $context['finished'] = 1; } else { $context['finished'] = $context['sandbox']['field']['current_progress'] / $context['sandbox']['field']['steps_to_delete']; - $context['message'] = \Drupal::translation()->translate('Purging field @field_label', array('@field_label' => $field->label())); + $context['message'] = \Drupal::translation()->translate('Purging field @field_label', array('@field_label' => $field_storage->label())); } } @@ -73,7 +74,7 @@ protected static function initializeSandbox(array &$context, ConfigImporter $con $context['sandbox']['field']['extensions'] = $config_importer->getStorageComparer()->getSourceStorage()->read('core.extension'); $context['sandbox']['field']['steps_to_delete'] = 0; - $fields = static::getFieldsToPurge($context['sandbox']['field']['extensions'], $config_importer->getUnprocessedConfiguration('delete')); + $fields = static::getFieldStoragesToPurge($context['sandbox']['field']['extensions'], $config_importer->getUnprocessedConfiguration('delete')); foreach ($fields as $field) { $row_count = \Drupal::entityManager()->getStorage($field->getTargetEntityTypeId()) ->countFieldData($field); @@ -108,41 +109,42 @@ protected static function initializeSandbox(array &$context, ConfigImporter $con * The configuration that will be deleted by the configuration * synchronization. * - * @return \Drupal\field\Entity\FieldConfig[] - * An array of fields that need purging before configuration can be + * @return \Drupal\field\Entity\FieldStorageConfig[] + * An array of field storages that need purging before configuration can be * synchronized. */ - public static function getFieldsToPurge(array $extensions, array $deletes) { + public static function getFieldStoragesToPurge(array $extensions, array $deletes) { $providers = array_keys($extensions['module']); $providers[] = 'core'; - $fields_to_delete = array(); + $storages_to_delete = array(); // Gather fields that will be deleted during configuration synchronization // where the module that provides the field type is also being uninstalled. - $field_ids = array(); + $field_storage_ids = array(); foreach ($deletes as $config_name) { - if (strpos($config_name, 'field.field.') === 0) { - $field_ids[] = ConfigEntityStorage::getIDFromConfigName($config_name, 'field.field'); + $field_storage_config_prefix = \Drupal::entityManager()->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); } } - if (!empty($field_ids)) { - $fields = \Drupal::entityQuery('field_config') - ->condition('id', $field_ids, 'IN') + if (!empty($field_storage_ids)) { + $field_storages = \Drupal::entityQuery('field_storage_config') + ->condition('id', $field_storage_ids, 'IN') ->condition('module', $providers, 'NOT IN') ->execute(); - if (!empty($fields)) { - $fields_to_delete = entity_load_multiple('field_config', $fields); + if (!empty($field_storages)) { + $storages_to_delete = FieldStorageConfig::loadMultiple($field_storages); } } // Gather deleted fields from modules that are being uninstalled. - $fields = entity_load_multiple_by_properties('field_config', array('deleted' => TRUE, 'include_deleted' => TRUE)); - foreach ($fields as $field) { - if (!in_array($field->module, $providers)) { - $fields_to_delete[$field->id()] = $field; + $field_storages = entity_load_multiple_by_properties('field_storage_config', array('deleted' => TRUE, 'include_deleted' => TRUE)); + foreach ($field_storages as $field_storage) { + if (!in_array($field_storage->module, $providers)) { + $storages_to_delete[$field_storage->id()] = $field_storage; } } - return $fields_to_delete; + return $storages_to_delete; } } diff --git a/core/modules/field/src/Entity/FieldInstanceConfig.php b/core/modules/field/src/Entity/FieldInstanceConfig.php index 79830db7d5bc..7a41fa2813d3 100644 --- a/core/modules/field/src/Entity/FieldInstanceConfig.php +++ b/core/modules/field/src/Entity/FieldInstanceConfig.php @@ -14,7 +14,7 @@ use Drupal\Core\Field\FieldDefinition; use Drupal\Core\Field\TypedData\FieldItemDataDefinition; use Drupal\field\FieldException; -use Drupal\field\FieldConfigInterface; +use Drupal\field\FieldStorageConfigInterface; use Drupal\field\FieldInstanceConfigInterface; /** @@ -188,9 +188,9 @@ class FieldInstanceConfig extends ConfigEntityBase implements FieldInstanceConfi /** * The field ConfigEntity object this is an instance of. * - * @var \Drupal\field\Entity\FieldConfig + * @var \Drupal\field\Entity\FieldStorageConfig */ - protected $field; + protected $fieldStorage; /** * Flag indicating whether the bundle name can be renamed or not. @@ -214,10 +214,11 @@ class FieldInstanceConfig extends ConfigEntityBase implements FieldInstanceConfi * parameter as in this constructor. * * @param array $values - * An array of field instance properties, keyed by property name. The field - * this is an instance of can be specified either with: - * - field: the FieldConfigInterface object, - * or by referring to an existing field in the current configuration with: + * An array of field instance properties, keyed by property name. The + * storage associated to the instance can be specified either with: + * - field_storage: the FieldStorageConfigInterface object, + * or by referring to an existing field storage in the current configuration + * with: * - field_name: The field name. * - entity_type: The entity type. * Additionally, a 'bundle' property is required to indicate the entity @@ -228,28 +229,28 @@ class FieldInstanceConfig extends ConfigEntityBase implements FieldInstanceConfi * @see entity_create() */ public function __construct(array $values, $entity_type = 'field_instance_config') { - // Allow either an injected FieldConfig object, or a field_name and + // Allow either an injected FieldStorageConfig object, or a field_name and // entity_type. - if (isset($values['field'])) { - if (!$values['field'] instanceof FieldConfigInterface) { - throw new FieldException('Attempt to create a configurable instance of a non-configurable field.'); + if (isset($values['field_storage'])) { + if (!$values['field_storage'] instanceof FieldStorageConfigInterface) { + throw new FieldException('Attempt to create a configurable field instance for a non-configurable field storage.'); } - $field = $values['field']; - $values['field_name'] = $field->getName(); - $values['entity_type'] = $field->getTargetEntityTypeId(); - $this->field = $field; + $field_storage = $values['field_storage']; + $values['field_name'] = $field_storage->getName(); + $values['entity_type'] = $field_storage->getTargetEntityTypeId(); + $this->fieldStorage = $field_storage; } else { if (empty($values['field_name'])) { - throw new FieldException('Attempt to create an instance of a field without a field_name.'); + throw new FieldException('Attempt to create a field instance without a field_name.'); } if (empty($values['entity_type'])) { - throw new FieldException(String::format('Attempt to create an instance of field @field_name without an entity_type.', array('@field_name' => $values['field_name']))); + throw new FieldException(String::format('Attempt to create a field instance @field_name without an entity_type.', array('@field_name' => $values['field_name']))); } } // 'bundle' is required in either case. if (empty($values['bundle'])) { - throw new FieldException(String::format('Attempt to create an instance of field @field_name without a bundle.', array('@field_name' => $values['field_name']))); + throw new FieldException(String::format('Attempt to create a field instance @field_name without a bundle.', array('@field_name' => $values['field_name']))); } // Discard the 'field_type' entry that is added in config records to ease @@ -297,8 +298,8 @@ public function toArray() { * {@inheritdoc} */ public function postCreate(EntityStorageInterface $storage) { - // Validate that we have a valid field for this instance. This throws an - // exception if the field is invalid. + // Validate that we have a valid storage for this instance. This throws an + // exception if the storage is invalid. $this->getFieldStorageDefinition(); // 'Label' defaults to the field name (mostly useful for field instances @@ -320,11 +321,11 @@ public function preSave(EntityStorageInterface $storage) { $entity_manager = \Drupal::entityManager(); $field_type_manager = \Drupal::service('plugin.manager.field.field_type'); - $field = $this->getFieldStorageDefinition(); + $storage_definition = $this->getFieldStorageDefinition(); if ($this->isNew()) { // Set the default instance settings. - $this->settings += $field_type_manager->getDefaultInstanceSettings($field->type); + $this->settings += $field_type_manager->getDefaultInstanceSettings($storage_definition->type); // Notify the entity storage. $entity_manager->getStorage($this->entity_type)->onFieldDefinitionCreate($this); } @@ -336,11 +337,11 @@ public function preSave(EntityStorageInterface $storage) { if ($this->bundle != $this->original->bundle && empty($this->bundle_rename_allowed)) { throw new FieldException("Cannot change an existing instance's bundle."); } - if ($field->uuid() != $this->original->getFieldStorageDefinition()->uuid()) { - throw new FieldException("Cannot change an existing instance's field."); + if ($storage_definition->uuid() != $this->original->getFieldStorageDefinition()->uuid()) { + throw new FieldException("Cannot change an existing instance's storage."); } // Set the default instance settings. - $this->settings += $field_type_manager->getDefaultInstanceSettings($field->type); + $this->settings += $field_type_manager->getDefaultInstanceSettings($storage_definition->type); // Notify the entity storage. $entity_manager->getStorage($this->entity_type)->onFieldDefinitionUpdate($this, $this->original); } @@ -395,7 +396,7 @@ public static function preDelete(EntityStorageInterface $storage, array $instanc if (!$instance->deleted) { $config = $instance->toArray(); $config['deleted'] = TRUE; - $config['field_uuid'] = $instance->getFieldStorageDefinition()->uuid(); + $config['field_storage_uuid'] = $instance->getFieldStorageDefinition()->uuid(); $deleted_instances[$instance->uuid()] = $config; } } @@ -406,8 +407,6 @@ public static function preDelete(EntityStorageInterface $storage, array $instanc * {@inheritdoc} */ public static function postDelete(EntityStorageInterface $storage, array $instances) { - $field_storage = \Drupal::entityManager()->getStorage('field_config'); - // Clear the cache upfront, to refresh the results of getBundles(). \Drupal::entityManager()->clearCachedFieldDefinitions(); @@ -425,17 +424,17 @@ public static function postDelete(EntityStorageInterface $storage, array $instan return; } - // Delete fields that have no more instances. - $fields_to_delete = array(); + // Delete field storages that have no more instances. + $storages_to_delete = array(); foreach ($instances as $instance) { - $field = $instance->getFieldStorageDefinition(); - if (!$instance->deleted && empty($instance->noFieldDelete) && !$instance->isUninstalling() && count($field->getBundles()) == 0) { - // Key by field UUID to avoid deleting the same field twice. - $fields_to_delete[$field->uuid()] = $field; + $storage_definition = $instance->getFieldStorageDefinition(); + if (!$instance->deleted && empty($instance->noFieldDelete) && !$instance->isUninstalling() && count($storage_definition->getBundles()) == 0) { + // Key by field UUID to avoid deleting the same storage twice. + $storages_to_delete[$storage_definition->uuid()] = $storage_definition; } } - if ($fields_to_delete) { - $field_storage->delete($fields_to_delete); + if ($storages_to_delete) { + \Drupal::entityManager()->getStorage('field_storage_config')->delete($storages_to_delete); } // Cleanup entity displays. @@ -444,11 +443,11 @@ public static function postDelete(EntityStorageInterface $storage, array $instan if (!$instance->deleted) { $view_modes = \Drupal::entityManager()->getViewModeOptions($instance->entity_type, TRUE); foreach (array_keys($view_modes) as $mode) { - $displays_to_update['entity_view_display'][$instance->entity_type . '.' . $instance->bundle . '.' . $mode][] = $instance->field_name; + $displays_to_update['entity_view_display'][$instance->entity_type . '.' . $instance->bundle . '.' . $mode][] = $instance->getName(); } $form_modes = \Drupal::entityManager()->getFormModeOptions($instance->entity_type, TRUE); foreach (array_keys($form_modes) as $mode) { - $displays_to_update['entity_form_display'][$instance->entity_type . '.' . $instance->bundle . '.' . $mode][] = $instance->field_name; + $displays_to_update['entity_form_display'][$instance->entity_type . '.' . $instance->bundle . '.' . $mode][] = $instance->getName(); } } } @@ -466,18 +465,18 @@ public static function postDelete(EntityStorageInterface $storage, array $instan * {@inheritdoc} */ public function getFieldStorageDefinition() { - if (!$this->field) { - $fields = \Drupal::entityManager()->getFieldStorageDefinitions($this->entity_type); - if (!isset($fields[$this->field_name])) { - throw new FieldException(String::format('Attempt to create an instance of field @field_name that does not exist on entity type @entity_type.', array('@field_name' => $this->field_name, '@entity_type' => $this->entity_type))); + if (!$this->fieldStorage) { + $storages = \Drupal::entityManager()->getFieldStorageDefinitions($this->entity_type); + if (!isset($storages[$this->field_name])) { + throw new FieldException(String::format('Attempt to create an instance @field_name while the storage does not exist on entity type @entity_type.', array('@field_name' => $this->field_name, '@entity_type' => $this->entity_type))); } - if (!$fields[$this->field_name] instanceof FieldConfigInterface) { - throw new FieldException(String::format('Attempt to create a configurable instance of non-configurable field @field_name.', array('@field_name' => $this->field_name, '@entity_type' => $this->entity_type))); + if (!$storages[$this->field_name] instanceof FieldStorageConfigInterface) { + throw new FieldException(String::format('Attempt to create a configurable instance for a non-configurable storage @field_name.', array('@field_name' => $this->field_name, '@entity_type' => $this->entity_type))); } - $this->field = $fields[$this->field_name]; + $this->fieldStorage = $storages[$this->field_name]; } - return $this->field; + return $this->fieldStorage; } /** @@ -522,7 +521,7 @@ protected function linkTemplates() { $link_templates = parent::linkTemplates(); if (\Drupal::moduleHandler()->moduleExists('field_ui')) { $link_templates['edit-form'] = 'field_ui.instance_edit_' . $this->entity_type; - $link_templates['field-settings-form'] = 'field_ui.field_edit_' . $this->entity_type; + $link_templates['storage-edit-form'] = 'field_ui.storage_edit_' . $this->entity_type; $link_templates['delete-form'] = 'field_ui.delete_' . $this->entity_type; if (isset($link_templates['drupal:config-translation-overview'])) { diff --git a/core/modules/field/src/Entity/FieldConfig.php b/core/modules/field/src/Entity/FieldStorageConfig.php similarity index 90% rename from core/modules/field/src/Entity/FieldConfig.php rename to core/modules/field/src/Entity/FieldStorageConfig.php index af025e3626bf..dcae40b58991 100644 --- a/core/modules/field/src/Entity/FieldConfig.php +++ b/core/modules/field/src/Entity/FieldStorageConfig.php @@ -2,7 +2,7 @@ /** * @file - * Contains \Drupal\field\Entity\FieldConfig. + * Contains \Drupal\field\Entity\FieldStorageConfig. */ namespace Drupal\field\Entity; @@ -13,25 +13,25 @@ use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\field\FieldException; -use Drupal\field\FieldConfigInterface; +use Drupal\field\FieldStorageConfigInterface; /** - * Defines the Field entity. + * Defines the Field storage configuration entity. * * @ConfigEntityType( - * id = "field_config", + * id = "field_storage_config", * label = @Translation("Field"), * controllers = { - * "storage" = "Drupal\field\FieldConfigStorage" + * "storage" = "Drupal\field\FieldStorageConfigStorage" * }, - * config_prefix = "field", + * config_prefix = "storage", * entity_keys = { * "id" = "id", * "label" = "id" * } * ) */ -class FieldConfig extends ConfigEntityBase implements FieldConfigInterface { +class FieldStorageConfig extends ConfigEntityBase implements FieldStorageConfigInterface { /** * The maximum length of the field name, in characters. @@ -181,7 +181,7 @@ class FieldConfig extends ConfigEntityBase implements FieldConfigInterface { protected $propertyDefinitions; /** - * Constructs a FieldConfig object. + * Constructs a FieldStorageConfig object. * * @param array $values * An array of field properties, keyed by property name. Most array @@ -194,24 +194,24 @@ class FieldConfig extends ConfigEntityBase implements FieldConfigInterface { * - type: required. * * In most cases, Field entities are created via - * entity_create('field_config', $values)), where $values is the same + * entity_create('field_storage_config', $values)), where $values is the same * parameter as in this constructor. * * @see entity_create() */ - public function __construct(array $values, $entity_type = 'field_config') { + public function __construct(array $values, $entity_type = 'field_storage_config') { // Check required properties. if (empty($values['name'])) { - throw new FieldException('Attempt to create an unnamed field.'); + throw new FieldException('Attempt to create an unnamed field storage.'); } if (!preg_match('/^[_a-z]+[_a-z0-9]*$/', $values['name'])) { - throw new FieldException(String::format('Attempt to create a field @field_name with invalid characters. Only lowercase alphanumeric characters and underscores are allowed, and only lowercase letters and underscore are allowed as the first character', array('@field_name' => $values['name']))); + throw new FieldException(String::format('Attempt to create a field storage @field_name with invalid characters. Only lowercase alphanumeric characters and underscores are allowed, and only lowercase letters and underscore are allowed as the first character', array('@field_name' => $values['name']))); } if (empty($values['type'])) { - throw new FieldException(String::format('Attempt to create field @field_name with no type.', array('@field_name' => $values['name']))); + throw new FieldException(String::format('Attempt to create a field storage @field_name with no type.', array('@field_name' => $values['name']))); } if (empty($values['entity_type'])) { - throw new FieldException(String::format('Attempt to create a field @field_name with no entity_type.', array('@field_name' => $values['name']))); + throw new FieldException(String::format('Attempt to create a field storage @field_name with no entity_type.', array('@field_name' => $values['name']))); } parent::__construct($values, $entity_type); @@ -263,12 +263,12 @@ protected function preSaveNew(EntityStorageInterface $storage) { // Assign the ID. $this->id = $this->id(); - // Field name cannot be longer than FieldConfig::NAME_MAX_LENGTH characters. + // Field name cannot be longer than FieldStorageConfig::NAME_MAX_LENGTH characters. // We use Unicode::strlen() because the DB layer assumes that column widths // are given in characters rather than bytes. if (Unicode::strlen($this->name) > static::NAME_MAX_LENGTH) { throw new FieldException(String::format( - 'Attempt to create a field with an ID longer than @max characters: %name', array( + 'Attempt to create a field storage with an name longer than @max characters: %name', array( '@max' => static::NAME_MAX_LENGTH, '%name' => $this->name, ) @@ -278,13 +278,13 @@ protected function preSaveNew(EntityStorageInterface $storage) { // Disallow reserved field names. $disallowed_field_names = array_keys($entity_manager->getBaseFieldDefinitions($this->entity_type)); if (in_array($this->name, $disallowed_field_names)) { - throw new FieldException(String::format('Attempt to create field %name which is reserved by entity type %type.', array('%name' => $this->name, '%type' => $this->entity_type))); + throw new FieldException(String::format('Attempt to create field storage %name which is reserved by entity type %type.', array('%name' => $this->name, '%type' => $this->entity_type))); } // Check that the field type is known. $field_type = $field_type_manager->getDefinition($this->type, FALSE); if (!$field_type) { - throw new FieldException(String::format('Attempt to create a field of unknown type %type.', array('%type' => $this->type))); + throw new FieldException(String::format('Attempt to create a field storage of unknown type %type.', array('%type' => $this->type))); } $this->module = $field_type['provider']; @@ -322,10 +322,10 @@ protected function preSaveUpdated(EntityStorageInterface $storage) { // Some updates are always disallowed. if ($this->type != $this->original->type) { - throw new FieldException("Cannot change an existing field's type."); + throw new FieldException("Cannot change the field type for an existing field storage."); } if ($this->entity_type != $this->original->entity_type) { - throw new FieldException("Cannot change an existing field's entity_type."); + throw new FieldException("Cannot change the entity type for an existing field storage."); } // Make sure all settings are present, so that a complete field @@ -333,8 +333,8 @@ protected function preSaveUpdated(EntityStorageInterface $storage) { $this->settings += $field_type_manager->getDefaultSettings($this->type); // See if any module forbids the update by throwing an exception. This - // invokes hook_field_config_update_forbid(). - $module_handler->invokeAll('field_config_update_forbid', array($this, $this->original)); + // invokes hook_field_storage_config_update_forbid(). + $module_handler->invokeAll('field_storage_config_update_forbid', array($this, $this->original)); // Notify the storage. The controller can reject the definition // update as invalid by raising an exception, which stops execution before @@ -388,17 +388,17 @@ public static function preDelete(EntityStorageInterface $storage, array $fields) // Keep the field definitions in the state storage so we can use them later // during field_purge_batch(). - $deleted_fields = $state->get('field.field.deleted') ?: array(); + $deleted_storages = $state->get('field.storage.deleted') ?: array(); foreach ($fields as $field) { if (!$field->deleted) { $config = $field->toArray(); $config['deleted'] = TRUE; $config['bundles'] = $field->getBundles(); - $deleted_fields[$field->uuid()] = $config; + $deleted_storages[$field->uuid()] = $config; } } - $state->set('field.field.deleted', $deleted_fields); + $state->set('field.storage.deleted', $deleted_storages); } /** @@ -739,7 +739,7 @@ protected function getFieldItemClass() { * otherwise NULL. */ public static function loadByName($entity_type_id, $field_name) { - return \Drupal::entityManager()->getStorage('field_config')->load($entity_type_id . '.' . $field_name); + return \Drupal::entityManager()->getStorage('field_storage_config')->load($entity_type_id . '.' . $field_name); } } diff --git a/core/modules/field/src/FieldConfigInterface.php b/core/modules/field/src/FieldConfigInterface.php deleted file mode 100644 index c6575ec7876b..000000000000 --- a/core/modules/field/src/FieldConfigInterface.php +++ /dev/null @@ -1,34 +0,0 @@ -<?php - -/** - * @file - * Contains \Drupal\field\FieldConfigInterface. - */ - -namespace Drupal\field; - -use Drupal\Core\Config\Entity\ConfigEntityInterface; -use Drupal\Core\Field\FieldStorageDefinitionInterface; - -/** - * Provides an interface defining a field entity. - */ -interface FieldConfigInterface extends ConfigEntityInterface, FieldStorageDefinitionInterface { - - /** - * Returns the list of bundles where the field has instances. - * - * @return array - * An array of bundle names. - */ - public function getBundles(); - - /** - * Returns whether the field is locked or not. - * - * @return bool - * TRUE if the field is locked. - */ - public function isLocked(); - -} diff --git a/core/modules/field/src/FieldInstanceConfigInterface.php b/core/modules/field/src/FieldInstanceConfigInterface.php index f23aaba9cd98..affcd49d2c02 100644 --- a/core/modules/field/src/FieldInstanceConfigInterface.php +++ b/core/modules/field/src/FieldInstanceConfigInterface.php @@ -18,8 +18,8 @@ interface FieldInstanceConfigInterface extends ConfigEntityInterface, FieldDefin /** * Returns the field entity for this instance. * - * @return \Drupal\field\FieldConfigInterface - * The field entity for this instance. + * @return \Drupal\field\FieldStorageConfigInterface + * The field storage entity for this instance. */ public function getFieldStorageDefinition(); diff --git a/core/modules/field/src/FieldInstanceConfigStorage.php b/core/modules/field/src/FieldInstanceConfigStorage.php index 20dc083089c2..ed3e0d426aab 100644 --- a/core/modules/field/src/FieldInstanceConfigStorage.php +++ b/core/modules/field/src/FieldInstanceConfigStorage.php @@ -11,13 +11,11 @@ use Drupal\Core\Config\Entity\ConfigEntityStorage; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityTypeInterface; -use Drupal\Core\Entity\Query\QueryFactory; use Drupal\Core\Language\LanguageManagerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Component\Uuid\UuidInterface; use Drupal\Core\Config\StorageInterface; -use Drupal\Core\Extension\ModuleHandler; use Drupal\Core\State\StateInterface; /** @@ -124,11 +122,11 @@ public function loadByProperties(array $conditions = array()) { // Merge deleted instances (stored in state) if needed. if ($include_deleted || !empty($conditions['deleted'])) { $deleted_instances = $this->state->get('field.instance.deleted') ?: array(); - $deleted_fields = $this->state->get('field.field.deleted') ?: array(); + $deleted_storages = $this->state->get('field.storage.deleted') ?: array(); foreach ($deleted_instances as $id => $config) { // If the field itself is deleted, inject it directly in the instance. - if (isset($deleted_fields[$config['field_uuid']])) { - $config['field'] = $this->entityManager->getStorage('field_config')->create($deleted_fields[$config['field_uuid']]); + if (isset($deleted_storages[$config['field_storage_uuid']])) { + $config['field_storage'] = $this->entityManager->getStorage('field_storage_config')->create($deleted_storages[$config['field_storage_uuid']]); } $instances[$id] = $this->create($config); } @@ -138,19 +136,19 @@ public function loadByProperties(array $conditions = array()) { $matching_instances = array(); foreach ($instances as $instance) { // Some conditions are checked against the field. - $field = $instance->getFieldStorageDefinition(); + $field_storage = $instance->getFieldStorageDefinition(); // Only keep the instance if it matches all conditions. foreach ($conditions as $key => $value) { // Extract the actual value against which the condition is checked. switch ($key) { case 'field_name': - $checked_value = $field->name; + $checked_value = $field_storage->name; break; case 'field_id': - case 'field_uuid': - $checked_value = $field->uuid(); + case 'field_storage_uuid': + $checked_value = $field_storage->uuid(); break; case 'uuid'; diff --git a/core/modules/field/src/FieldStorageConfigInterface.php b/core/modules/field/src/FieldStorageConfigInterface.php new file mode 100644 index 000000000000..4f4eb0416cb1 --- /dev/null +++ b/core/modules/field/src/FieldStorageConfigInterface.php @@ -0,0 +1,34 @@ +<?php + +/** + * @file + * Contains \Drupal\field\FieldStorageConfigInterface. + */ + +namespace Drupal\field; + +use Drupal\Core\Config\Entity\ConfigEntityInterface; +use Drupal\Core\Field\FieldStorageDefinitionInterface; + +/** + * Provides an interface defining a field storage entity. + */ +interface FieldStorageConfigInterface extends ConfigEntityInterface, FieldStorageDefinitionInterface { + + /** + * Returns the list of bundles where the field storage has fields. + * + * @return array + * An array of bundle names. + */ + public function getBundles(); + + /** + * Returns whether the field storage is locked or not. + * + * @return bool + * TRUE if the field storage is locked. + */ + public function isLocked(); + +} diff --git a/core/modules/field/src/FieldConfigStorage.php b/core/modules/field/src/FieldStorageConfigStorage.php similarity index 81% rename from core/modules/field/src/FieldConfigStorage.php rename to core/modules/field/src/FieldStorageConfigStorage.php index 841942487f2d..d4adc6360875 100644 --- a/core/modules/field/src/FieldConfigStorage.php +++ b/core/modules/field/src/FieldStorageConfigStorage.php @@ -2,17 +2,15 @@ /** * @file - * Contains \Drupal\field\FieldConfigStorage. + * Contains \Drupal\field\FieldStorageConfigStorage. */ namespace Drupal\field; use Drupal\Component\Uuid\UuidInterface; -use Drupal\Core\Config\Config; use Drupal\Core\Config\Entity\ConfigEntityStorage; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityTypeInterface; -use Drupal\Core\Entity\Query\QueryFactory; use Drupal\Core\Language\LanguageManagerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Core\Config\ConfigFactoryInterface; @@ -21,9 +19,9 @@ use Drupal\Core\State\StateInterface; /** - * Controller class for fields. + * Controller class for "field storage" configuration entities. */ -class FieldConfigStorage extends ConfigEntityStorage { +class FieldStorageConfigStorage extends ConfigEntityStorage { /** * The module handler. @@ -47,7 +45,7 @@ class FieldConfigStorage extends ConfigEntityStorage { protected $state; /** - * Constructs a FieldConfigStorage object. + * Constructs a FieldStorageConfigStorage object. * * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type * The entity type definition. @@ -97,34 +95,34 @@ public function loadByProperties(array $conditions = array()) { $include_deleted = isset($conditions['include_deleted']) ? $conditions['include_deleted'] : FALSE; unset($conditions['include_deleted']); - $fields = array(); + $storages = array(); - // Get fields stored in configuration. If we are explicitly looking for - // deleted fields only, this can be skipped, because they will be retrieved - // from state below. + // Get field storages living in configuration. If we are explicitly looking + // for deleted storages only, this can be skipped, because they will be + // retrieved from state below. if (empty($conditions['deleted'])) { if (isset($conditions['entity_type']) && isset($conditions['field_name'])) { // Optimize for the most frequent case where we do have a specific ID. $id = $conditions['entity_type'] . $conditions['field_name']; - $fields = $this->loadMultiple(array($id)); + $storages = $this->loadMultiple(array($id)); } else { - // No specific ID, we need to examine all existing fields. - $fields = $this->loadMultiple(); + // No specific ID, we need to examine all existing storages. + $storages = $this->loadMultiple(); } } - // Merge deleted fields (stored in state) if needed. + // Merge deleted field storages (living in state) if needed. if ($include_deleted || !empty($conditions['deleted'])) { - $deleted_fields = $this->state->get('field.field.deleted') ?: array(); - foreach ($deleted_fields as $id => $config) { - $fields[$id] = $this->create($config); + $deleted_storages = $this->state->get('field.storage.deleted') ?: array(); + foreach ($deleted_storages as $id => $config) { + $storages[$id] = $this->create($config); } } // Collect matching fields. - $matching_fields = array(); - foreach ($fields as $field) { + $matches = array(); + foreach ($storages as $field) { foreach ($conditions as $key => $value) { // Extract the actual value against which the condition is checked. switch ($key) { @@ -150,10 +148,10 @@ public function loadByProperties(array $conditions = array()) { // When returning deleted fields, key the results by UUID since they can // include several fields with the same ID. $key = $include_deleted ? $field->uuid() : $field->id(); - $matching_fields[$key] = $field; + $matches[$key] = $field; } - return $matching_fields; + return $matches; } } diff --git a/core/modules/field/src/FieldStorageConfigUpdateForbiddenException.php b/core/modules/field/src/FieldStorageConfigUpdateForbiddenException.php new file mode 100644 index 000000000000..ef709ba4dd56 --- /dev/null +++ b/core/modules/field/src/FieldStorageConfigUpdateForbiddenException.php @@ -0,0 +1,13 @@ +<?php + +/** + * @file + * Contains \Drupal\field\FieldStorageConfigUpdateForbiddenException. + */ + +namespace Drupal\field; + +/** + * Exception class thrown by hook_field_storage_config_update_forbid(). + */ +class FieldStorageConfigUpdateForbiddenException extends FieldException {} diff --git a/core/modules/field/src/Plugin/views/argument/FieldList.php b/core/modules/field/src/Plugin/views/argument/FieldList.php index d55ca6a64e6f..5bfd9350dd38 100644 --- a/core/modules/field/src/Plugin/views/argument/FieldList.php +++ b/core/modules/field/src/Plugin/views/argument/FieldList.php @@ -36,8 +36,8 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o parent::init($view, $display, $options); $field_storage_definitions = \Drupal::entityManager()->getFieldStorageDefinitions($this->definition['entity_type']); - $field = $field_storage_definitions[$this->definition['field_name']]; - $this->allowed_values = options_allowed_values($field); + $field_storage = $field_storage_definitions[$this->definition['field_name']]; + $this->allowed_values = options_allowed_values($field_storage); } protected function defineOptions() { diff --git a/core/modules/field/src/Plugin/views/argument/ListString.php b/core/modules/field/src/Plugin/views/argument/ListString.php index 742a15105048..02d049a55b8a 100644 --- a/core/modules/field/src/Plugin/views/argument/ListString.php +++ b/core/modules/field/src/Plugin/views/argument/ListString.php @@ -36,8 +36,8 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o parent::init($view, $display, $options); $field_storage_definitions = \Drupal::entityManager()->getFieldStorageDefinitions($this->definition['entity_type']); - $field = $field_storage_definitions[$this->definition['field_name']]; - $this->allowed_values = options_allowed_values($field); + $field_storage = $field_storage_definitions[$this->definition['field_name']]; + $this->allowed_values = options_allowed_values($field_storage); } protected function defineOptions() { diff --git a/core/modules/field/src/Plugin/views/field/Field.php b/core/modules/field/src/Plugin/views/field/Field.php index f3814c46b04d..ad3543b46526 100644 --- a/core/modules/field/src/Plugin/views/field/Field.php +++ b/core/modules/field/src/Plugin/views/field/Field.php @@ -55,8 +55,10 @@ class Field extends FieldPluginBase { /** * The field config. + * + * @var \Drupal\field\FieldStorageConfigInterface */ - protected $fieldConfig; + protected $fieldStorageConfig; /** * Does the field supports multiple field values. @@ -153,8 +155,8 @@ public static function create(ContainerInterface $container, array $configuratio */ protected function getFieldDefinition() { if (!$this->fieldDefinition) { - $field_config = $this->getFieldConfig(); - $this->fieldDefinition = FieldDefinition::createFromFieldStorageDefinition($field_config); + $field_storage_config = $this->getFieldStorageConfig(); + $this->fieldDefinition = FieldDefinition::createFromFieldStorageDefinition($field_storage_config); } return $this->fieldDefinition; } @@ -162,14 +164,14 @@ protected function getFieldDefinition() { /** * Gets the field configuration. * - * @return \Drupal\field\FieldConfigInterface + * @return \Drupal\field\FieldStorageConfigInterface */ - protected function getFieldConfig() { - if (!$this->fieldConfig) { + protected function getFieldStorageConfig() { + if (!$this->fieldStorageConfig) { $field_storage_definitions = \Drupal::entityManager()->getFieldStorageDefinitions($this->definition['entity_type']); - $this->fieldConfig = $field_storage_definitions[$this->definition['field_name']]; + $this->fieldStorageConfig = $field_storage_definitions[$this->definition['field_name']]; } - return $this->fieldConfig; + return $this->fieldStorageConfig; } /** @@ -351,8 +353,8 @@ public function clickSort($order) { $this->ensureMyTable(); $field_storage_definitions = $this->entityManager->getFieldStorageDefinitions($this->definition['entity_type']); - $field = $field_storage_definitions[$this->definition['field_name']]; - $column = ContentEntityDatabaseStorage::_fieldColumnName($field, $this->options['click_sort_column']); + $field_storage = $field_storage_definitions[$this->definition['field_name']]; + $column = ContentEntityDatabaseStorage::_fieldColumnName($field_storage, $this->options['click_sort_column']); if (!isset($this->aliases[$column])) { // Column is not in query; add a sort on it (without adding the column). $this->aliases[$column] = $this->tableAlias . '.' . $column; @@ -364,9 +366,9 @@ protected function defineOptions() { $options = parent::defineOptions(); $field_storage_definitions = $this->entityManager->getFieldStorageDefinitions($this->definition['entity_type']); - $field = $field_storage_definitions[$this->definition['field_name']]; - $field_type = \Drupal::service('plugin.manager.field.field_type')->getDefinition($field->getType()); - $column_names = array_keys($field->getColumns()); + $field_storage = $field_storage_definitions[$this->definition['field_name']]; + $field_type = \Drupal::service('plugin.manager.field.field_type')->getDefinition($field_storage->getType()); + $column_names = array_keys($field_storage->getColumns()); $default_column = ''; // Try to determine a sensible default. if (count($column_names) == 1) { @@ -401,7 +403,7 @@ protected function defineOptions() { // If we know the exact number of allowed values, then that can be // the default. Otherwise, default to 'all'. $options['delta_limit'] = array( - 'default' => ($field->getCardinality() > 1) ? $field->getCardinality() : 'all', + 'default' => ($field_storage->getCardinality() > 1) ? $field_storage->getCardinality() : 'all', ); $options['delta_offset'] = array( 'default' => 0, @@ -937,8 +939,8 @@ function field_langcode(EntityInterface $entity) { * {@inheritdoc} */ public function getDependencies() { - // Add the module providing the configured field as a dependency. - return array('entity' => array($this->getFieldConfig()->getConfigDependencyName())); + // Add the module providing the configured field storage as a dependency. + return array('entity' => array($this->getFieldStorageConfig()->getConfigDependencyName())); } diff --git a/core/modules/field/src/Plugin/views/filter/FieldList.php b/core/modules/field/src/Plugin/views/filter/FieldList.php index 16024fb7065e..42061e11a2c4 100644 --- a/core/modules/field/src/Plugin/views/filter/FieldList.php +++ b/core/modules/field/src/Plugin/views/filter/FieldList.php @@ -20,8 +20,8 @@ class FieldList extends ManyToOne { public function getValueOptions() { $field_storage_definitions = \Drupal::entityManager()->getFieldStorageDefinitions($this->definition['entity_type']); - $field = $field_storage_definitions[$this->definition['field_name']]; - $this->value_options = list_allowed_values($field); + $field_storage = $field_storage_definitions[$this->definition['field_name']]; + $this->value_options = list_allowed_values($field_storage); } } diff --git a/core/modules/field/src/Tests/Boolean/BooleanFieldTest.php b/core/modules/field/src/Tests/Boolean/BooleanFieldTest.php index ee2e039e338f..3ef06b74cf5e 100644 --- a/core/modules/field/src/Tests/Boolean/BooleanFieldTest.php +++ b/core/modules/field/src/Tests/Boolean/BooleanFieldTest.php @@ -7,7 +7,7 @@ namespace Drupal\field\Tests\Boolean; -use Drupal\field\Entity\FieldConfig; +use Drupal\field\Entity\FieldStorageConfig; use Drupal\field\Entity\FieldInstanceConfig; use Drupal\simpletest\WebTestBase; @@ -28,7 +28,7 @@ class BooleanFieldTest extends WebTestBase { /** * A field to use in this test class. * - * @var \Drupal\field\Entity\FieldConfig + * @var \Drupal\field\Entity\FieldStorageConfig */ protected $field; @@ -64,7 +64,7 @@ function testBooleanField() { // Create a field with settings to validate. $field_name = drupal_strtolower($this->randomName()); - $this->field = FieldConfig::create(array( + $this->field = FieldStorageConfig::create(array( 'name' => $field_name, 'entity_type' => 'entity_test', 'type' => 'boolean', @@ -169,7 +169,7 @@ function testBooleanField() { ); // Test the boolean field settings. - $this->drupalGet('entity_test/structure/entity_test/fields/entity_test.entity_test.' . $field_name . '/field'); + $this->drupalGet('entity_test/structure/entity_test/fields/entity_test.entity_test.' . $field_name . '/storage'); $this->assertFieldById('edit-field-settings-on-label', $on); $this->assertFieldById('edit-field-settings-off-label', $off); } diff --git a/core/modules/field/src/Tests/Boolean/BooleanItemTest.php b/core/modules/field/src/Tests/Boolean/BooleanItemTest.php index 73031321b069..60cb878948e3 100644 --- a/core/modules/field/src/Tests/Boolean/BooleanItemTest.php +++ b/core/modules/field/src/Tests/Boolean/BooleanItemTest.php @@ -25,7 +25,7 @@ public function setUp() { parent::setUp(); // Create an boolean field and instance for validation. - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => 'field_boolean', 'entity_type' => 'entity_test', 'type' => 'boolean', diff --git a/core/modules/field/src/Tests/BulkDeleteTest.php b/core/modules/field/src/Tests/BulkDeleteTest.php index 39105f72d973..ebfec7068fd9 100644 --- a/core/modules/field/src/Tests/BulkDeleteTest.php +++ b/core/modules/field/src/Tests/BulkDeleteTest.php @@ -10,8 +10,6 @@ use Drupal\Core\Entity\ContentEntityDatabaseStorage; use Drupal\Core\Entity\EntityInterface; use Drupal\field\Entity\FieldInstanceConfig; -use Drupal\field\FieldConfigInterface; - /** * Bulk delete fields and instances, and clean up afterwards. @@ -25,7 +23,7 @@ class BulkDeleteTest extends FieldUnitTestBase { * * @var array */ - protected $fields; + protected $fieldStorages; /** * The entities to use in this test. @@ -97,7 +95,7 @@ function checkHooksInvocations($expected_hooks, $actual_hooks) { function setUp() { parent::setUp(); - $this->fields = array(); + $this->fieldStorages = array(); $this->entities = array(); $this->entities_by_bundles = array(); @@ -108,36 +106,36 @@ function setUp() { } // Create two fields. - $field = entity_create('field_config', array( + $field_storage = entity_create('field_storage_config', array( 'name' => 'bf_1', 'entity_type' => $this->entity_type, 'type' => 'test_field', 'cardinality' => 1 )); - $field->save(); - $this->fields[] = $field; - $field = entity_create('field_config', array( + $field_storage->save(); + $this->fieldStorages[] = $field_storage; + $field_storage = entity_create('field_storage_config', array( 'name' => 'bf_2', 'entity_type' => $this->entity_type, 'type' => 'test_field', 'cardinality' => 4 )); - $field->save(); - $this->fields[] = $field; + $field_storage->save(); + $this->fieldStorages[] = $field_storage; // For each bundle, create an instance of each field, and 10 // entities with values for each field. foreach ($this->bundles as $bundle) { - foreach ($this->fields as $field) { + foreach ($this->fieldStorages as $field_storage) { entity_create('field_instance_config', array( - 'field' => $field, + 'field_storage' => $field_storage, 'bundle' => $bundle, ))->save(); } for ($i = 0; $i < 10; $i++) { $entity = entity_create($this->entity_type, array('type' => $bundle)); - foreach ($this->fields as $field) { - $entity->{$field->getName()}->setValue($this->_generateTestFieldValues($field->getCardinality())); + foreach ($this->fieldStorages as $field_storage) { + $entity->{$field_storage->getName()}->setValue($this->_generateTestFieldValues($field_storage->getCardinality())); } $entity->save(); } @@ -159,8 +157,8 @@ function setUp() { */ function testDeleteFieldInstance() { $bundle = reset($this->bundles); - $field = reset($this->fields); - $field_name = $field->name; + $field_storage = reset($this->fieldStorages); + $field_name = $field_storage->name; $factory = \Drupal::service('entity.query'); // There are 10 entities of this bundle. @@ -170,24 +168,24 @@ function testDeleteFieldInstance() { $this->assertEqual(count($found), 10, 'Correct number of entities found before deleting'); // Delete the instance. - $instance = FieldInstanceConfig::loadByName($this->entity_type, $bundle, $field->name); + $instance = FieldInstanceConfig::loadByName($this->entity_type, $bundle, $field_storage->name); $instance->delete(); // The instance still exists, deleted. - $instances = entity_load_multiple_by_properties('field_instance_config', array('field_id' => $field->uuid(), 'deleted' => TRUE, 'include_deleted' => TRUE)); + $instances = entity_load_multiple_by_properties('field_instance_config', array('field_storage_uuid' => $field_storage->uuid(), 'deleted' => TRUE, 'include_deleted' => TRUE)); $this->assertEqual(count($instances), 1, 'There is one deleted instance'); $instance = $instances[$instance->uuid()]; $this->assertEqual($instance->bundle, $bundle, 'The deleted instance is for the correct bundle'); // Check that the actual stored content did not change during delete. - $schema = ContentEntityDatabaseStorage::_fieldSqlSchema($field); - $table = ContentEntityDatabaseStorage::_fieldTableName($field); - $column = ContentEntityDatabaseStorage::_fieldColumnName($field, 'value'); + $schema = ContentEntityDatabaseStorage::_fieldSqlSchema($field_storage); + $table = ContentEntityDatabaseStorage::_fieldTableName($field_storage); + $column = ContentEntityDatabaseStorage::_fieldColumnName($field_storage, 'value'); $result = db_select($table, 't') ->fields('t', array_keys($schema[$table]['fields'])) ->execute(); foreach ($result as $row) { - $this->assertEqual($this->entities[$row->entity_id]->{$field->name}->value, $row->$column); + $this->assertEqual($this->entities[$row->entity_id]->{$field_storage->name}->value, $row->$column); } // There are 0 entities of this bundle with non-deleted data. @@ -217,10 +215,10 @@ function testPurgeInstance() { field_test_memorize(); $bundle = reset($this->bundles); - $field = reset($this->fields); + $field_storage = reset($this->fieldStorages); // Delete the instance. - $instance = FieldInstanceConfig::loadByName($this->entity_type, $bundle, $field->name); + $instance = FieldInstanceConfig::loadByName($this->entity_type, $bundle, $field_storage->name); $instance->delete(); // No field hooks were called. @@ -235,7 +233,7 @@ function testPurgeInstance() { // There are $count deleted entities left. $found = \Drupal::entityQuery('entity_test') ->condition('type', $bundle) - ->condition($field->name . '.deleted', 1) + ->condition($field_storage->name . '.deleted', 1) ->execute(); $this->assertEqual(count($found), $count, 'Correct number of entities found after purging 2'); } @@ -252,34 +250,35 @@ function testPurgeInstance() { $this->checkHooksInvocations($hooks, $actual_hooks); // The instance still exists, deleted. - $instances = entity_load_multiple_by_properties('field_instance_config', array('field_id' => $field->uuid(), 'deleted' => TRUE, 'include_deleted' => TRUE)); + $instances = entity_load_multiple_by_properties('field_instance_config', array('field_storage_uuid' => $field_storage->uuid(), 'deleted' => TRUE, 'include_deleted' => TRUE)); $this->assertEqual(count($instances), 1, 'There is one deleted instance'); // Purge the instance. field_purge_batch($batch_size); // The instance is gone. - $instances = entity_load_multiple_by_properties('field_instance_config', array('field_id' => $field->uuid(), 'deleted' => TRUE, 'include_deleted' => TRUE)); + $instances = entity_load_multiple_by_properties('field_instance_config', array('field_storage_uuid' => $field_storage->uuid(), 'deleted' => TRUE, 'include_deleted' => TRUE)); $this->assertEqual(count($instances), 0, 'The instance is gone'); - // The field still exists, not deleted, because it has a second instance. - $fields = entity_load_multiple_by_properties('field_config', array('uuid' => $field->uuid(), 'include_deleted' => TRUE)); - $this->assertTrue(isset($fields[$field->uuid()]), 'The field exists and is not deleted'); + // The field storage still exists, not deleted, because it has a second + // instance. + $storages = entity_load_multiple_by_properties('field_storage_config', array('uuid' => $field_storage->uuid(), 'include_deleted' => TRUE)); + $this->assertTrue(isset($storages[$field_storage->uuid()]), 'The field storage exists and is not deleted'); } /** - * Verify that fields are preserved and purged correctly as multiple + * Verify that field storages are preserved and purged correctly as multiple * instances are deleted and purged. */ - function testPurgeField() { + function testPurgeFieldStorage() { // Start recording hook invocations. field_test_memorize(); - $field = reset($this->fields); + $field_storage = reset($this->fieldStorages); // Delete the first instance. $bundle = reset($this->bundles); - $instance = FieldInstanceConfig::loadByName($this->entity_type, $bundle, $field->name); + $instance = FieldInstanceConfig::loadByName($this->entity_type, $bundle, $field_storage->name); $instance->delete(); // Assert that FieldItemInterface::delete() was not called yet. @@ -310,13 +309,13 @@ function testPurgeField() { // The instance is gone. $instances = entity_load_multiple_by_properties('field_instance_config', array('uuid' => $instance->uuid(), 'include_deleted' => TRUE)); $this->assertEqual(count($instances), 0, 'The instance is purged.'); - // The field still exists, not deleted. - $fields = entity_load_multiple_by_properties('field_config', array('uuid' => $field->uuid(), 'include_deleted' => TRUE)); - $this->assertTrue(isset($fields[$field->uuid()]) && !$fields[$field->uuid()]->deleted, 'The field exists and is not deleted'); + // The field storage still exists, not deleted. + $storages = entity_load_multiple_by_properties('field_storage_config', array('uuid' => $field_storage->uuid(), 'include_deleted' => TRUE)); + $this->assertTrue(isset($storages[$field_storage->uuid()]) && !$storages[$field_storage->uuid()]->deleted, 'The field storage exists and is not deleted'); // Delete the second instance. $bundle = next($this->bundles); - $instance = FieldInstanceConfig::loadByName($this->entity_type, $bundle, $field->name); + $instance = FieldInstanceConfig::loadByName($this->entity_type, $bundle, $field_storage->name); $instance->delete(); // Assert that FieldItemInterface::delete() was not called yet. @@ -335,20 +334,20 @@ function testPurgeField() { } $this->checkHooksInvocations($hooks, $actual_hooks); - // The field and instance still exist, deleted. + // The field storage and instance still exist, deleted. $instances = entity_load_multiple_by_properties('field_instance_config', array('uuid' => $instance->uuid(), 'include_deleted' => TRUE)); $this->assertTrue(isset($instances[$instance->uuid()]) && $instances[$instance->uuid()]->deleted, 'The instance exists and is deleted'); - $fields = entity_load_multiple_by_properties('field_config', array('uuid' => $field->uuid(), 'include_deleted' => TRUE)); - $this->assertTrue(isset($fields[$field->uuid()]) && $fields[$field->uuid()]->deleted, 'The field exists and is deleted'); + $storages = entity_load_multiple_by_properties('field_storage_config', array('uuid' => $field_storage->uuid(), 'include_deleted' => TRUE)); + $this->assertTrue(isset($storages[$field_storage->uuid()]) && $storages[$field_storage->uuid()]->deleted, 'The field storage exists and is deleted'); - // Purge again to purge the instance and the field. + // Purge again to purge the instance and the field storage. field_purge_batch(0); - // The field and instance are gone. + // The field storage and instance are gone. $instances = entity_load_multiple_by_properties('field_instance_config', array('uuid' => $instance->uuid(), 'include_deleted' => TRUE)); $this->assertEqual(count($instances), 0, 'The instance is purged.'); - $fields = entity_load_multiple_by_properties('field_config', array('uuid' => $field->uuid(), 'include_deleted' => TRUE)); - $this->assertEqual(count($fields), 0, 'The field is purged.'); + $storages = entity_load_multiple_by_properties('field_storage_config', array('uuid' => $field_storage->uuid(), 'include_deleted' => TRUE)); + $this->assertEqual(count($storages), 0, 'The field storage is purged.'); } } diff --git a/core/modules/field/src/Tests/CrudTest.php b/core/modules/field/src/Tests/CrudTest.php index 39ed52155371..a7dbb19d84dd 100644 --- a/core/modules/field/src/Tests/CrudTest.php +++ b/core/modules/field/src/Tests/CrudTest.php @@ -9,11 +9,11 @@ use Drupal\Core\Entity\EntityStorageException; use Drupal\Core\Entity\Exception\FieldStorageDefinitionUpdateForbiddenException; -use Drupal\field\Entity\FieldConfig; +use Drupal\field\Entity\FieldStorageConfig; use Drupal\field\FieldException; /** - * Tests field create, read, update, and delete. + * Tests field storage create, read, update, and delete. * * @group field */ @@ -32,42 +32,42 @@ class CrudTest extends FieldUnitTestBase { // defer actual $field comparison to a helper function, used for the two cases above /** - * Test the creation of a field. + * Test the creation of a field storage. */ - function testCreateField() { - $field_definition = array( + function testCreate() { + $field_storage_definition = array( 'name' => 'field_2', 'entity_type' => 'entity_test', 'type' => 'test_field', ); field_test_memorize(); - $field = entity_create('field_config', $field_definition); - $field->save(); + $field_storage = entity_create('field_storage_config', $field_storage_definition); + $field_storage->save(); $mem = field_test_memorize(); - $this->assertIdentical($mem['field_test_field_config_create'][0][0]->getName(), $field_definition['name'], 'hook_entity_create() called with correct arguments.'); - $this->assertIdentical($mem['field_test_field_config_create'][0][0]->getType(), $field_definition['type'], 'hook_entity_create() called with correct arguments.'); + $this->assertIdentical($mem['field_test_field_storage_config_create'][0][0]->getName(), $field_storage_definition['name'], 'hook_entity_create() called with correct arguments.'); + $this->assertIdentical($mem['field_test_field_storage_config_create'][0][0]->getType(), $field_storage_definition['type'], 'hook_entity_create() called with correct arguments.'); // Read the configuration. Check against raw configuration data rather than // the loaded ConfigEntity, to be sure we check that the defaults are // applied on write. - $field_config = \Drupal::config('field.field.' . $field->id())->get(); + $field_storage_config = \Drupal::config('field.storage.' . $field_storage->id())->get(); // Ensure that basic properties are preserved. - $this->assertEqual($field_config['name'], $field_definition['name'], 'The field name is properly saved.'); - $this->assertEqual($field_config['entity_type'], $field_definition['entity_type'], 'The field entity type is properly saved.'); - $this->assertEqual($field_config['id'], $field_definition['entity_type'] . '.' . $field_definition['name'], 'The field id is properly saved.'); - $this->assertEqual($field_config['type'], $field_definition['type'], 'The field type is properly saved.'); + $this->assertEqual($field_storage_config['name'], $field_storage_definition['name'], 'The field name is properly saved.'); + $this->assertEqual($field_storage_config['entity_type'], $field_storage_definition['entity_type'], 'The field entity type is properly saved.'); + $this->assertEqual($field_storage_config['id'], $field_storage_definition['entity_type'] . '.' . $field_storage_definition['name'], 'The field id is properly saved.'); + $this->assertEqual($field_storage_config['type'], $field_storage_definition['type'], 'The field type is properly saved.'); // Ensure that cardinality defaults to 1. - $this->assertEqual($field_config['cardinality'], 1, 'Cardinality defaults to 1.'); + $this->assertEqual($field_storage_config['cardinality'], 1, 'Cardinality defaults to 1.'); // Ensure that default settings are present. $field_type_manager = \Drupal::service('plugin.manager.field.field_type'); - $this->assertEqual($field_config['settings'], $field_type_manager->getDefaultSettings($field_definition['type']), 'Default field settings have been written.'); + $this->assertEqual($field_storage_config['settings'], $field_type_manager->getDefaultSettings($field_storage_definition['type']), 'Default field settings have been written.'); // Guarantee that the name is unique. try { - entity_create('field_config', $field_definition)->save(); + entity_create('field_storage_config', $field_storage_definition)->save(); $this->fail(t('Cannot create two fields with the same name.')); } catch (EntityStorageException $e) { @@ -76,11 +76,11 @@ function testCreateField() { // Check that field type is required. try { - $field_definition = array( + $field_storage_definition = array( 'name' => 'field_1', 'entity_type' => 'entity_type', ); - entity_create('field_config', $field_definition)->save(); + entity_create('field_storage_config', $field_storage_definition)->save(); $this->fail(t('Cannot create a field with no type.')); } catch (FieldException $e) { @@ -89,11 +89,11 @@ function testCreateField() { // Check that field name is required. try { - $field_definition = array( + $field_storage_definition = array( 'type' => 'test_field', 'entity_type' => 'entity_test', ); - entity_create('field_config', $field_definition)->save(); + entity_create('field_storage_config', $field_storage_definition)->save(); $this->fail(t('Cannot create an unnamed field.')); } catch (FieldException $e) { @@ -101,11 +101,11 @@ function testCreateField() { } // Check that entity type is required. try { - $field_definition = array( + $field_storage_definition = array( 'name' => 'test_field', 'type' => 'test_field' ); - entity_create('field_config', $field_definition)->save(); + entity_create('field_storage_config', $field_storage_definition)->save(); $this->fail('Cannot create a field without an entity type.'); } catch (FieldException $e) { @@ -114,12 +114,12 @@ function testCreateField() { // Check that field name must start with a letter or _. try { - $field_definition = array( + $field_storage_definition = array( 'name' => '2field_2', 'entity_type' => 'entity_test', 'type' => 'test_field', ); - entity_create('field_config', $field_definition)->save(); + entity_create('field_storage_config', $field_storage_definition)->save(); $this->fail(t('Cannot create a field with a name starting with a digit.')); } catch (FieldException $e) { @@ -128,12 +128,12 @@ function testCreateField() { // Check that field name must only contain lowercase alphanumeric or _. try { - $field_definition = array( + $field_storage_definition = array( 'name' => 'field#_3', 'entity_type' => 'entity_test', 'type' => 'test_field', ); - entity_create('field_config', $field_definition)->save(); + entity_create('field_storage_config', $field_storage_definition)->save(); $this->fail(t('Cannot create a field with a name containing an illegal character.')); } catch (FieldException $e) { @@ -142,12 +142,12 @@ function testCreateField() { // Check that field name cannot be longer than 32 characters long. try { - $field_definition = array( + $field_storage_definition = array( 'name' => '_12345678901234567890123456789012', 'entity_type' => 'entity_test', 'type' => 'test_field', ); - entity_create('field_config', $field_definition)->save(); + entity_create('field_storage_config', $field_storage_definition)->save(); $this->fail(t('Cannot create a field with a name longer than 32 characters.')); } catch (FieldException $e) { @@ -157,12 +157,12 @@ function testCreateField() { // Check that field name can not be an entity key. // "id" is known as an entity key from the "entity_test" type. try { - $field_definition = array( + $field_storage_definition = array( 'type' => 'test_field', 'name' => 'id', 'entity_type' => 'entity_test', ); - entity_create('field_config', $field_definition)->save(); + entity_create('field_storage_config', $field_storage_definition)->save(); $this->fail(t('Cannot create a field bearing the name of an entity key.')); } catch (FieldException $e) { @@ -171,50 +171,50 @@ function testCreateField() { } /** - * Tests that an explicit schema can be provided on creation of a field. + * Tests that an explicit schema can be provided on creation. * - * This behavior is needed to allow field creation within updates, since - * plugin classes (and thus the field type schema) cannot be accessed. + * This behavior is needed to allow field storage creation within updates, + * since plugin classes (and thus the field type schema) cannot be accessed. */ - function testCreateFieldWithExplicitSchema() { - $field_definition = array( + function testCreateWithExplicitSchema() { + $schema = array( + 'dummy' => 'foobar' + ); + $field_storage = entity_create('field_storage_config', array( 'name' => 'field_2', 'entity_type' => 'entity_test', 'type' => 'test_field', - 'schema' => array( - 'dummy' => 'foobar' - ), - ); - $field = entity_create('field_config', $field_definition); - $this->assertEqual($field->getSchema(), $field_definition['schema']); + 'schema' => $schema, + )); + $this->assertEqual($field_storage->getSchema(), $schema); } /** - * Tests reading field definitions. + * Tests reading field storage definitions. */ - function testReadFields() { - $field_definition = array( + function testRead() { + $field_storage_definition = array( 'name' => 'field_1', 'entity_type' => 'entity_test', 'type' => 'test_field', ); - $field = entity_create('field_config', $field_definition); - $field->save(); - $id = $field->id(); + $field_storage = entity_create('field_storage_config', $field_storage_definition); + $field_storage->save(); + $id = $field_storage->id(); // Check that 'single column' criteria works. - $fields = entity_load_multiple_by_properties('field_config', array('field_name' => $field_definition['name'])); + $fields = entity_load_multiple_by_properties('field_storage_config', array('field_name' => $field_storage_definition['name'])); $this->assertTrue(count($fields) == 1 && isset($fields[$id]), 'The field was properly read.'); // Check that 'multi column' criteria works. - $fields = entity_load_multiple_by_properties('field_config', array('field_name' => $field_definition['name'], 'type' => $field_definition['type'])); + $fields = entity_load_multiple_by_properties('field_storage_config', array('field_name' => $field_storage_definition['name'], 'type' => $field_storage_definition['type'])); $this->assertTrue(count($fields) == 1 && isset($fields[$id]), 'The field was properly read.'); - $fields = entity_load_multiple_by_properties('field_config', array('field_name' => $field_definition['name'], 'type' => 'foo')); + $fields = entity_load_multiple_by_properties('field_storage_config', array('field_name' => $field_storage_definition['name'], 'type' => 'foo')); $this->assertTrue(empty($fields), 'No field was found.'); // Create an instance of the field. $instance_definition = array( - 'field_name' => $field_definition['name'], + 'field_name' => $field_storage_definition['name'], 'entity_type' => 'entity_test', 'bundle' => 'entity_test', ); @@ -224,60 +224,57 @@ function testReadFields() { /** * Test creation of indexes on data column. */ - function testFieldIndexes() { + function testIndexes() { // Check that indexes specified by the field type are used by default. - $field_definition = array( + $field_storage = entity_create('field_storage_config', array( 'name' => 'field_1', 'entity_type' => 'entity_test', 'type' => 'test_field', - ); - $field = entity_create('field_config', $field_definition); - $field->save(); - $field = entity_load('field_config', $field->id()); - $schema = $field->getSchema(); + )); + $field_storage->save(); + $field_storage = entity_load('field_storage_config', $field_storage->id()); + $schema = $field_storage->getSchema(); $expected_indexes = array('value' => array('value')); $this->assertEqual($schema['indexes'], $expected_indexes, 'Field type indexes saved by default'); // Check that indexes specified by the field definition override the field // type indexes. - $field_definition = array( + $field_storage = entity_create('field_storage_config', array( 'name' => 'field_2', 'entity_type' => 'entity_test', 'type' => 'test_field', 'indexes' => array( 'value' => array(), ), - ); - $field = entity_create('field_config', $field_definition); - $field->save(); - $field = entity_load('field_config', $field->id()); - $schema = $field->getSchema(); + )); + $field_storage->save(); + $field_storage = entity_load('field_storage_config', $field_storage->id()); + $schema = $field_storage->getSchema(); $expected_indexes = array('value' => array()); $this->assertEqual($schema['indexes'], $expected_indexes, 'Field definition indexes override field type indexes'); // Check that indexes specified by the field definition add to the field // type indexes. - $field_definition = array( + $field_storage = entity_create('field_storage_config', array( 'name' => 'field_3', 'entity_type' => 'entity_test', 'type' => 'test_field', 'indexes' => array( 'value_2' => array('value'), ), - ); - $field = entity_create('field_config', $field_definition); - $field->save(); - $id = $field->id(); - $field = entity_load('field_config', $id); - $schema = $field->getSchema(); + )); + $field_storage->save(); + $id = $field_storage->id(); + $field_storage = entity_load('field_storage_config', $id); + $schema = $field_storage->getSchema(); $expected_indexes = array('value' => array('value'), 'value_2' => array('value')); $this->assertEqual($schema['indexes'], $expected_indexes, 'Field definition indexes are merged with field type indexes'); } /** - * Test the deletion of a field. + * Test the deletion of a field storage. */ - function testDeleteField() { + function testDelete() { // TODO: Also test deletion of the data stored in the field ? // Create two fields (so we can test that only one is deleted). @@ -286,13 +283,13 @@ function testDeleteField() { 'type' => 'test_field', 'entity_type' => 'entity_test', ); - entity_create('field_config', $this->field)->save(); + entity_create('field_storage_config', $this->field)->save(); $this->another_field = array( 'name' => 'field_2', 'type' => 'test_field', 'entity_type' => 'entity_test', ); - entity_create('field_config', $this->another_field)->save(); + entity_create('field_storage_config', $this->another_field)->save(); // Create instances for each. $this->instance_definition = array( @@ -306,14 +303,14 @@ function testDeleteField() { entity_create('field_instance_config', $another_instance_definition)->save(); // Test that the first field is not deleted, and then delete it. - $field = current(entity_load_multiple_by_properties('field_config', array('field_name' => $this->field['name'], 'include_deleted' => TRUE))); - $this->assertTrue(!empty($field) && empty($field->deleted), 'A new field is not marked for deletion.'); - FieldConfig::loadByName('entity_test', $this->field['name'])->delete(); + $field_storage = current(entity_load_multiple_by_properties('field_storage_config', array('field_name' => $this->field['name'], 'include_deleted' => TRUE))); + $this->assertTrue(!empty($field_storage) && empty($field_storage->deleted), 'A new field is not marked for deletion.'); + FieldStorageConfig::loadByName('entity_test', $this->field['name'])->delete(); // Make sure that the field is marked as deleted when it is specifically // loaded. - $field = current(entity_load_multiple_by_properties('field_config', array('field_name' => $this->field['name'], 'include_deleted' => TRUE))); - $this->assertTrue(!empty($field->deleted), 'A deleted field is marked for deletion.'); + $field_storage = current(entity_load_multiple_by_properties('field_storage_config', array('field_name' => $this->field['name'], 'include_deleted' => TRUE))); + $this->assertTrue(!empty($field_storage->deleted), 'A deleted field is marked for deletion.'); // Make sure that this field's instance is marked as deleted when it is // specifically loaded. @@ -321,53 +318,52 @@ function testDeleteField() { $this->assertTrue(!empty($instance->deleted), 'An instance for a deleted field is marked for deletion.'); // Try to load the field normally and make sure it does not show up. - $field = entity_load('field_config', 'entity_test.' . $this->field['name']); - $this->assertTrue(empty($field), 'A deleted field is not loaded by default.'); + $field_storage = entity_load('field_storage_config', 'entity_test.' . $this->field['name']); + $this->assertTrue(empty($field_storage), 'A deleted field is not loaded by default.'); // Try to load the instance normally and make sure it does not show up. $instance = entity_load('field_instance_config', 'entity_test.' . '.' . $this->instance_definition['bundle'] . '.' . $this->instance_definition['field_name']); $this->assertTrue(empty($instance), 'An instance for a deleted field is not loaded by default.'); // Make sure the other field (and its field instance) are not deleted. - $another_field = entity_load('field_config', 'entity_test.' . $this->another_field['name']); - $this->assertTrue(!empty($another_field) && empty($another_field->deleted), 'A non-deleted field is not marked for deletion.'); + $another_field_storage = entity_load('field_storage_config', 'entity_test.' . $this->another_field['name']); + $this->assertTrue(!empty($another_field_storage) && empty($another_field_storage->deleted), 'A non-deleted field is not marked for deletion.'); $another_instance = entity_load('field_instance_config', 'entity_test.' . $another_instance_definition['bundle'] . '.' . $another_instance_definition['field_name']); $this->assertTrue(!empty($another_instance) && empty($another_instance->deleted), 'An instance of a non-deleted field is not marked for deletion.'); // Try to create a new field the same name as a deleted field and // write data into it. - entity_create('field_config', $this->field)->save(); + entity_create('field_storage_config', $this->field)->save(); entity_create('field_instance_config', $this->instance_definition)->save(); - $field = entity_load('field_config', 'entity_test.' . $this->field['name']); - $this->assertTrue(!empty($field) && empty($field->deleted), 'A new field with a previously used name is created.'); + $field_storage = entity_load('field_storage_config', 'entity_test.' . $this->field['name']); + $this->assertTrue(!empty($field_storage) && empty($field_storage->deleted), 'A new field with a previously used name is created.'); $instance = entity_load('field_instance_config', 'entity_test.' . $this->instance_definition['bundle'] . '.' . $this->instance_definition['field_name'] ); $this->assertTrue(!empty($instance) && empty($instance->deleted), 'A new instance for a previously used field name is created.'); // Save an entity with data for the field $entity = entity_create('entity_test'); $values[0]['value'] = mt_rand(1, 127); - $entity->{$field->getName()}->value = $values[0]['value']; + $entity->{$field_storage->getName()}->value = $values[0]['value']; $entity = $this->entitySaveReload($entity); // Verify the field is present on load - $this->assertIdentical(count($entity->{$field->getName()}), count($values), "Data in previously deleted field saves and loads correctly"); + $this->assertIdentical(count($entity->{$field_storage->getName()}), count($values), "Data in previously deleted field saves and loads correctly"); foreach ($values as $delta => $value) { - $this->assertEqual($entity->{$field->getName()}[$delta]->value, $values[$delta]['value'], "Data in previously deleted field saves and loads correctly"); + $this->assertEqual($entity->{$field_storage->getName()}[$delta]->value, $values[$delta]['value'], "Data in previously deleted field saves and loads correctly"); } } function testUpdateFieldType() { - $field_definition = array( + $field_storage = entity_create('field_storage_config', array( 'name' => 'field_type', 'entity_type' => 'entity_test', 'type' => 'decimal', - ); - $field = entity_create('field_config', $field_definition); - $field->save(); + )); + $field_storage->save(); try { - $field->type = 'integer'; - $field->save(); + $field_storage->type = 'integer'; + $field_storage->save(); $this->fail(t('Cannot update a field to a different type.')); } catch (FieldException $e) { @@ -376,22 +372,22 @@ function testUpdateFieldType() { } /** - * Test updating a field. + * Test updating a field storage. */ - function testUpdateField() { + function testUpdate() { // Create a field with a defined cardinality, so that we can ensure it's // respected. Since cardinality enforcement is consistent across database // systems, it makes a good test case. $cardinality = 4; - $field = entity_create('field_config', array( + $field_storage = entity_create('field_storage_config', array( 'name' => 'field_update', 'entity_type' => 'entity_test', 'type' => 'test_field', 'cardinality' => $cardinality, )); - $field->save(); + $field_storage->save(); $instance = entity_create('field_instance_config', array( - 'field' => $field, + 'field_storage' => $field_storage, 'entity_type' => 'entity_test', 'bundle' => 'entity_test', )); @@ -406,22 +402,22 @@ function testUpdateField() { } // Load back and assert there are $cardinality number of values. $entity = $this->entitySaveReload($entity); - $this->assertEqual(count($entity->field_update), $field->cardinality); + $this->assertEqual(count($entity->field_update), $field_storage->cardinality); // Now check the values themselves. for ($delta = 0; $delta < $cardinality; $delta++) { $this->assertEqual($entity->field_update[$delta]->value, $delta + 1); } // Increase $cardinality and set the field cardinality to the new value. - $field->cardinality = ++$cardinality; - $field->save(); + $field_storage->cardinality = ++$cardinality; + $field_storage->save(); } while ($cardinality < 6); } /** * Test field type modules forbidding an update. */ - function testUpdateFieldForbid() { - $field = entity_create('field_config', array( + function testUpdateForbid() { + $field_storage = entity_create('field_storage_config', array( 'name' => 'forbidden', 'entity_type' => 'entity_test', 'type' => 'test_field', @@ -429,18 +425,18 @@ function testUpdateFieldForbid() { 'changeable' => 0, 'unchangeable' => 0 ))); - $field->save(); - $field->settings['changeable']++; + $field_storage->save(); + $field_storage->settings['changeable']++; try { - $field->save(); + $field_storage->save(); $this->pass(t("A changeable setting can be updated.")); } catch (FieldStorageDefinitionUpdateForbiddenException $e) { $this->fail(t("An unchangeable setting cannot be updated.")); } - $field->settings['unchangeable']++; + $field_storage->settings['unchangeable']++; try { - $field->save(); + $field_storage->save(); $this->fail(t("An unchangeable setting can be updated.")); } catch (FieldStorageDefinitionUpdateForbiddenException $e) { diff --git a/core/modules/field/src/Tests/DisplayApiTest.php b/core/modules/field/src/Tests/DisplayApiTest.php index 43bfc0398606..1172e21a1821 100644 --- a/core/modules/field/src/Tests/DisplayApiTest.php +++ b/core/modules/field/src/Tests/DisplayApiTest.php @@ -66,7 +66,7 @@ function setUp() { $this->label = $this->randomName(); $this->cardinality = 4; - $field = array( + $field_storage = array( 'name' => $this->field_name, 'entity_type' => 'entity_test', 'type' => 'test_field', @@ -94,7 +94,7 @@ function setUp() { ), ); - entity_create('field_config', $field)->save(); + entity_create('field_storage_config', $field_storage)->save(); entity_create('field_instance_config', $instance)->save(); // Create a display for the default view mode. entity_get_display($instance['entity_type'], $instance['bundle'], 'default') diff --git a/core/modules/field/src/Tests/Email/EmailFieldTest.php b/core/modules/field/src/Tests/Email/EmailFieldTest.php index 3a10b575cece..93e65f912431 100644 --- a/core/modules/field/src/Tests/Email/EmailFieldTest.php +++ b/core/modules/field/src/Tests/Email/EmailFieldTest.php @@ -24,11 +24,11 @@ class EmailFieldTest extends WebTestBase { public static $modules = array('node', 'entity_test', 'field_ui'); /** - * A field to use in this test class. + * A field storage to use in this test class. * - * @var \Drupal\field\Entity\FieldConfig + * @var \Drupal\field\Entity\FieldStorageConfig */ - protected $field; + protected $fieldStorage; /** * The instance used in this test class. @@ -54,14 +54,14 @@ function setUp() { function testEmailField() { // Create a field with settings to validate. $field_name = drupal_strtolower($this->randomName()); - $this->field = entity_create('field_config', array( + $this->fieldStorage = entity_create('field_storage_config', array( 'name' => $field_name, 'entity_type' => 'entity_test', 'type' => 'email', )); - $this->field->save(); + $this->fieldStorage->save(); $this->instance = entity_create('field_instance_config', array( - 'field' => $this->field, + 'field_storage' => $this->fieldStorage, 'bundle' => 'entity_test', )); $this->instance->save(); diff --git a/core/modules/field/src/Tests/Email/EmailItemTest.php b/core/modules/field/src/Tests/Email/EmailItemTest.php index 3a1338b9b483..ecca155a219c 100644 --- a/core/modules/field/src/Tests/Email/EmailItemTest.php +++ b/core/modules/field/src/Tests/Email/EmailItemTest.php @@ -29,7 +29,7 @@ public function setUp() { parent::setUp(); // Create an email field and instance for validation. - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => 'field_email', 'entity_type' => 'entity_test', 'type' => 'email', diff --git a/core/modules/field/src/Tests/FieldAccessTest.php b/core/modules/field/src/Tests/FieldAccessTest.php index 2bf705ec0627..a981bc5bb203 100644 --- a/core/modules/field/src/Tests/FieldAccessTest.php +++ b/core/modules/field/src/Tests/FieldAccessTest.php @@ -45,14 +45,14 @@ function setUp() { $content_type_info = $this->drupalCreateContentType(); $content_type = $content_type_info->type; - $field = array( + $field_storage = array( 'name' => 'test_view_field', 'entity_type' => 'node', 'type' => 'text', ); - entity_create('field_config', $field)->save(); + entity_create('field_storage_config', $field_storage)->save(); $instance = array( - 'field_name' => $field['name'], + 'field_name' => $field_storage['name'], 'entity_type' => 'node', 'bundle' => $content_type, ); @@ -61,7 +61,7 @@ function setUp() { // Assign display properties for the 'default' and 'teaser' view modes. foreach (array('default', 'teaser') as $view_mode) { entity_get_display('node', $content_type, $view_mode) - ->setComponent($field['name']) + ->setComponent($field_storage['name']) ->save(); } diff --git a/core/modules/field/src/Tests/FieldAttachOtherTest.php b/core/modules/field/src/Tests/FieldAttachOtherTest.php index 606940bd6b50..7356bcebaa11 100644 --- a/core/modules/field/src/Tests/FieldAttachOtherTest.php +++ b/core/modules/field/src/Tests/FieldAttachOtherTest.php @@ -47,9 +47,9 @@ function testEntityDisplayBuild() { $entity_init = entity_create($entity_type); // Populate values to be displayed. - $values = $this->_generateTestFieldValues($this->field->getCardinality()); + $values = $this->_generateTestFieldValues($this->field_storage->getCardinality()); $entity_init->{$this->field_name}->setValue($values); - $values_2 = $this->_generateTestFieldValues($this->field_2->getCardinality()); + $values_2 = $this->_generateTestFieldValues($this->field_storage_2->getCardinality()); $entity_init->{$this->field_name_2}->setValue($values_2); // Simple formatter, label displayed. @@ -64,7 +64,7 @@ function testEntityDisplayBuild() { 'test_formatter_setting' => $formatter_setting, ), ); - $display->setComponent($this->field->getName(), $display_options); + $display->setComponent($this->field_name, $display_options); $formatter_setting_2 = $this->randomName(); $display_options_2 = array( @@ -74,7 +74,7 @@ function testEntityDisplayBuild() { 'test_formatter_setting' => $formatter_setting_2, ), ); - $display->setComponent($this->field_2->getName(), $display_options_2); + $display->setComponent($this->field_name_2, $display_options_2); // View all fields. $content = $display->build($entity); @@ -91,14 +91,14 @@ function testEntityDisplayBuild() { // Label hidden. $entity = clone($entity_init); $display_options['label'] = 'hidden'; - $display->setComponent($this->field->getName(), $display_options); + $display->setComponent($this->field_name, $display_options); $content = $display->build($entity); $this->render($content); $this->assertNoRaw($this->instance->getLabel(), "Hidden label: label is not displayed."); // Field hidden. $entity = clone($entity_init); - $display->removeComponent($this->field->getName()); + $display->removeComponent($this->field_name); $content = $display->build($entity); $this->render($content); $this->assertNoRaw($this->instance->getLabel(), "Hidden field: label is not displayed."); @@ -109,7 +109,7 @@ function testEntityDisplayBuild() { // Multiple formatter. $entity = clone($entity_init); $formatter_setting = $this->randomName(); - $display->setComponent($this->field->getName(), array( + $display->setComponent($this->field_name, array( 'label' => 'above', 'type' => 'field_test_multiple', 'settings' => array( @@ -127,7 +127,7 @@ function testEntityDisplayBuild() { // Test a formatter that uses hook_field_formatter_prepare_view(). $entity = clone($entity_init); $formatter_setting = $this->randomName(); - $display->setComponent($this->field->getName(), array( + $display->setComponent($this->field_name, array( 'label' => 'above', 'type' => 'field_test_with_prepare_view', 'settings' => array( @@ -178,7 +178,7 @@ function testEntityDisplayViewMultiple() { function testEntityCache() { // Initialize random values and a test entity. $entity_init = entity_create('entity_test', array('type' => $this->instance->bundle)); - $values = $this->_generateTestFieldValues($this->field->getCardinality()); + $values = $this->_generateTestFieldValues($this->field_storage->getCardinality()); // Non-cacheable entity type. $entity_type = 'entity_test'; @@ -221,7 +221,7 @@ function testEntityCache() { $this->assertEqual($cache->data, $cached_entity, 'Cached: correct cache entry on load'); // Update with different values, and check that the cache entry is wiped. - $values = $this->_generateTestFieldValues($this->field_2->getCardinality()); + $values = $this->_generateTestFieldValues($this->field_storage_2->getCardinality()); $entity->{$this->field_name_2} = $values; $entity->save(); $this->assertFalse(\Drupal::cache('entity')->get($cid), 'Cached: no cache entry on update'); @@ -233,7 +233,7 @@ function testEntityCache() { $this->assertEqual($cache->data, $cached_entity, 'Cached: correct cache entry on load'); // Create a new revision, and check that the cache entry is wiped. - $values = $this->_generateTestFieldValues($this->field_2->getCardinality()); + $values = $this->_generateTestFieldValues($this->field_storage_2->getCardinality()); $entity->{$this->field_name_2} = $values; $entity->setNewRevision(); $entity->save(); @@ -270,11 +270,11 @@ function testEntityFormDisplayBuildForm() { $this->assertEqual($form[$this->field_name]['widget']['#title'], $this->instance->getLabel(), "First field's form title is {$this->instance->getLabel()}"); $this->assertEqual($form[$this->field_name_2]['widget']['#title'], $this->instance_2->getLabel(), "Second field's form title is {$this->instance_2->getLabel()}"); - for ($delta = 0; $delta < $this->field->getCardinality(); $delta++) { + for ($delta = 0; $delta < $this->field_storage->getCardinality(); $delta++) { // field_test_widget uses 'textfield' $this->assertEqual($form[$this->field_name]['widget'][$delta]['value']['#type'], 'textfield', "First field's form delta $delta widget is textfield"); } - for ($delta = 0; $delta < $this->field_2->getCardinality(); $delta++) { + for ($delta = 0; $delta < $this->field_storage_2->getCardinality(); $delta++) { // field_test_widget uses 'textfield' $this->assertEqual($form[$this->field_name_2]['widget'][$delta]['value']['#type'], 'textfield', "Second field's form delta $delta widget is textfield"); } @@ -292,7 +292,7 @@ function testEntityFormDisplayBuildForm() { $this->assertFalse(isset($form[$this->field_name]), 'The first field does not exist in the form'); $this->assertEqual($form[$this->field_name_2]['widget']['#title'], $this->instance_2->getLabel(), "Second field's form title is {$this->instance_2->getLabel()}"); - for ($delta = 0; $delta < $this->field_2->getCardinality(); $delta++) { + for ($delta = 0; $delta < $this->field_storage_2->getCardinality(); $delta++) { // field_test_widget uses 'textfield' $this->assertEqual($form[$this->field_name_2]['widget'][$delta]['value']['#type'], 'textfield', "Second field's form delta $delta widget is textfield"); } @@ -317,11 +317,11 @@ function testEntityFormDisplayExtractFormValues() { // First field. $values = array(); $weights = array(); - for ($delta = 0; $delta < $this->field->getCardinality(); $delta++) { + for ($delta = 0; $delta < $this->field_storage->getCardinality(); $delta++) { $values[$delta]['value'] = mt_rand(1, 127); // Assign random weight. do { - $weight = mt_rand(0, $this->field->getCardinality()); + $weight = mt_rand(0, $this->field_storage->getCardinality()); } while (in_array($weight, $weights)); $weights[$delta] = $weight; $values[$delta]['_weight'] = $weight; @@ -331,11 +331,11 @@ function testEntityFormDisplayExtractFormValues() { // Second field. $values_2 = array(); $weights_2 = array(); - for ($delta = 0; $delta < $this->field_2->getCardinality(); $delta++) { + for ($delta = 0; $delta < $this->field_storage_2->getCardinality(); $delta++) { $values_2[$delta]['value'] = mt_rand(1, 127); // Assign random weight. do { - $weight = mt_rand(0, $this->field_2->getCardinality()); + $weight = mt_rand(0, $this->field_storage_2->getCardinality()); } while (in_array($weight, $weights_2)); $weights_2[$delta] = $weight; $values_2[$delta]['_weight'] = $weight; diff --git a/core/modules/field/src/Tests/FieldAttachStorageTest.php b/core/modules/field/src/Tests/FieldAttachStorageTest.php index a80c401ddfbb..05db62ed4af4 100644 --- a/core/modules/field/src/Tests/FieldAttachStorageTest.php +++ b/core/modules/field/src/Tests/FieldAttachStorageTest.php @@ -44,7 +44,7 @@ public function setUp() { function testFieldAttachSaveLoad() { $entity_type = 'entity_test_rev'; $this->createFieldWithInstance('', $entity_type); - $cardinality = $this->field->getCardinality(); + $cardinality = $this->field_storage->getCardinality(); // TODO : test empty values filtering and "compression" (store consecutive deltas). // Preparation: create three revisions and store them in $revision array. @@ -108,13 +108,13 @@ function testFieldAttachLoadMultiple() { ); for ($i = 1; $i <= 3; $i++) { $field_names[$i] = 'field_' . $i; - $field = entity_create('field_config', array( + $field_storage = entity_create('field_storage_config', array( 'name' => $field_names[$i], 'entity_type' => $entity_type, 'type' => 'test_field', )); - $field->save(); - $field_ids[$i] = $field->uuid(); + $field_storage->save(); + $field_ids[$i] = $field_storage->uuid(); foreach ($field_bundles_map[$i] as $bundle) { entity_create('field_instance_config', array( 'field_name' => $field_names[$i], @@ -235,7 +235,7 @@ function testFieldAttachSaveEmptyDataDefaultValue() { function testFieldAttachDelete() { $entity_type = 'entity_test_rev'; $this->createFieldWithInstance('', $entity_type); - $cardinality = $this->field->getCardinality(); + $cardinality = $this->field_storage->getCardinality(); $entity = entity_create($entity_type, array('type' => $this->instance->bundle)); $vids = array(); @@ -293,7 +293,7 @@ function testFieldAttachDelete() { function testEntityCreateRenameBundle() { $entity_type = 'entity_test_rev'; $this->createFieldWithInstance('', $entity_type); - $cardinality = $this->field->getCardinality(); + $cardinality = $this->field_storage->getCardinality(); // Create a new bundle. $new_bundle = 'test_bundle_' . drupal_strtolower($this->randomName()); @@ -344,13 +344,13 @@ function testEntityDeleteBundle() { // Create a second field for the test bundle $field_name = drupal_strtolower($this->randomName() . '_field_name'); - $field = array( + $field_storage = array( 'name' => $field_name, 'entity_type' => $entity_type, 'type' => 'test_field', 'cardinality' => 1, ); - entity_create('field_config', $field)->save(); + entity_create('field_storage_config', $field_storage)->save(); $instance = array( 'field_name' => $field_name, 'entity_type' => $entity_type, @@ -363,7 +363,7 @@ function testEntityDeleteBundle() { // Save an entity with data for both fields $entity = entity_create($entity_type, array('type' => $this->instance->bundle)); - $values = $this->_generateTestFieldValues($this->field->getCardinality()); + $values = $this->_generateTestFieldValues($this->field_storage->getCardinality()); $entity->{$this->field_name} = $values; $entity->{$field_name} = $this->_generateTestFieldValues(1); $entity = $this->entitySaveReload($entity); diff --git a/core/modules/field/src/Tests/FieldDataCountTest.php b/core/modules/field/src/Tests/FieldDataCountTest.php index e443825581b5..da72e0b45382 100644 --- a/core/modules/field/src/Tests/FieldDataCountTest.php +++ b/core/modules/field/src/Tests/FieldDataCountTest.php @@ -10,12 +10,12 @@ use Drupal\Core\Entity\ContentEntityDatabaseStorage; /** - * Tests counting field data records and the hasData() method on FieldConfig - * entity. + * Tests counting field data records and the hasData() method on + * FieldStorageConfig entity. * * @group field * @see \Drupal\Core\Entity\FieldableEntityStorageInterface::countFieldData() - * @see \Drupal\field\Entity\FieldConfig::hasData() + * @see \Drupal\field\Entity\FieldStorageConfig::hasData() */ class FieldDataCountTest extends FieldUnitTestBase { @@ -38,29 +38,29 @@ public function setUp() { public function testEntityCountAndHasData() { // Create a field with a cardinality of 2 to show that we are counting // entities and not rows in a table. - /** @var \Drupal\field\Entity\FieldConfig $field */ - $field = entity_create('field_config', array( + /** @var \Drupal\field\Entity\FieldStorageConfig $field_storage */ + $field_storage = entity_create('field_storage_config', array( 'name' => 'field_int', 'entity_type' => 'entity_test', 'type' => 'integer', 'cardinality' => 2, )); - $field->save(); + $field_storage->save(); entity_create('field_instance_config', array( - 'field' => $field, + 'field_storage' => $field_storage, 'bundle' => 'entity_test', ))->save(); - $this->assertIdentical($field->hasdata(), FALSE, 'There are no entities with field data.'); - $this->assertIdentical($this->storage->countFieldData($field), 0, 'There are 0 entities with field data.'); + $this->assertIdentical($field_storage->hasdata(), FALSE, 'There are no entities with field data.'); + $this->assertIdentical($this->storage->countFieldData($field_storage), 0, 'There are 0 entities with field data.'); // Create 1 entity without the field. $entity = entity_create('entity_test'); $entity->name->value = $this->randomName(); $entity->save(); - $this->assertIdentical($field->hasdata(), FALSE, 'There are no entities with field data.'); - $this->assertIdentical($this->storage->countFieldData($field), 0, 'There are 0 entities with field data.'); + $this->assertIdentical($field_storage->hasdata(), FALSE, 'There are no entities with field data.'); + $this->assertIdentical($this->storage->countFieldData($field_storage), 0, 'There are 0 entities with field data.'); // Create 12 entities to ensure that the purging works as expected. for ($i=0; $i < 12; $i++) { @@ -76,7 +76,7 @@ public function testEntityCountAndHasData() { $storage = \Drupal::entityManager()->getStorage('entity_test'); if ($storage instanceof ContentEntityDatabaseStorage) { // Count the actual number of rows in the field table. - $field_table_name = $storage->_fieldTableName($field); + $field_table_name = $storage->_fieldTableName($field_storage); $result = db_select($field_table_name, 't') ->fields('t') ->countQuery() @@ -85,17 +85,17 @@ public function testEntityCountAndHasData() { $this->assertEqual($result, 24, 'The field table has 24 rows.'); } - $this->assertIdentical($field->hasdata(), TRUE, 'There are entities with field data.'); - $this->assertEqual($this->storage->countFieldData($field), 12, 'There are 12 entities with field data.'); + $this->assertIdentical($field_storage->hasdata(), TRUE, 'There are entities with field data.'); + $this->assertEqual($this->storage->countFieldData($field_storage), 12, 'There are 12 entities with field data.'); // Ensure the methods work on deleted fields. - $field->delete(); - $this->assertIdentical($field->hasdata(), TRUE, 'There are entities with deleted field data.'); - $this->assertEqual($this->storage->countFieldData($field), 12, 'There are 12 entities with deleted field data.'); + $field_storage->delete(); + $this->assertIdentical($field_storage->hasdata(), TRUE, 'There are entities with deleted field data.'); + $this->assertEqual($this->storage->countFieldData($field_storage), 12, 'There are 12 entities with deleted field data.'); field_purge_batch(6); - $this->assertIdentical($field->hasdata(), TRUE, 'There are entities with deleted field data.'); - $this->assertEqual($this->storage->countFieldData($field), 6, 'There are 6 entities with deleted field data.'); + $this->assertIdentical($field_storage->hasdata(), TRUE, 'There are entities with deleted field data.'); + $this->assertEqual($this->storage->countFieldData($field_storage), 6, 'There are 6 entities with deleted field data.'); } } diff --git a/core/modules/field/src/Tests/FieldImportCreateTest.php b/core/modules/field/src/Tests/FieldImportCreateTest.php index 80a4abd7b4ad..4c5608716278 100644 --- a/core/modules/field/src/Tests/FieldImportCreateTest.php +++ b/core/modules/field/src/Tests/FieldImportCreateTest.php @@ -27,9 +27,9 @@ function testImportCreateDefault() { $instance_id_2b = "entity_test.test_bundle.$field_name_2"; // Check that the fields and instances do not exist yet. - $this->assertFalse(entity_load('field_config', $field_id)); + $this->assertFalse(entity_load('field_storage_config', $field_id)); $this->assertFalse(entity_load('field_instance_config', $instance_id)); - $this->assertFalse(entity_load('field_config', $field_id_2)); + $this->assertFalse(entity_load('field_storage_config', $field_id_2)); $this->assertFalse(entity_load('field_instance_config', $instance_id_2a)); $this->assertFalse(entity_load('field_instance_config', $instance_id_2b)); @@ -41,14 +41,14 @@ function testImportCreateDefault() { \Drupal::moduleHandler()->install(array('field_test_config')); // A field with one instance. - $field = entity_load('field_config', $field_id); - $this->assertTrue($field, 'The field was created.'); + $field_storage = entity_load('field_storage_config', $field_id); + $this->assertTrue($field_storage, 'The field was created.'); $instance = entity_load('field_instance_config', $instance_id); $this->assertTrue($instance, 'The field instance was deleted.'); // A field with multiple instances. - $field_2 = entity_load('field_config', $field_id_2); - $this->assertTrue($field_2, 'The second field was created.'); + $field_storage_2 = entity_load('field_storage_config', $field_id_2); + $this->assertTrue($field_storage_2, 'The second field was created.'); $this->assertTrue($instance->bundle, 'test_bundle', 'The second field instance was created on bundle test_bundle.'); $this->assertTrue($instance->bundle, 'test_bundle_2', 'The second field instance was created on bundle test_bundle_2.'); @@ -76,7 +76,7 @@ function testImportCreate() { $field_name = 'field_test_import_staging'; $field_id = "entity_test.$field_name"; $instance_id = "entity_test.entity_test.$field_name"; - $field_config_name = "field.field.$field_id"; + $field_storage_config_name = "field.storage.$field_id"; $instance_config_name = "field.instance.$instance_id"; // One field with two field instances. @@ -84,7 +84,7 @@ function testImportCreate() { $field_id_2 = "entity_test.$field_name_2"; $instance_id_2a = "entity_test.test_bundle.$field_name_2"; $instance_id_2b = "entity_test.test_bundle_2.$field_name_2"; - $field_config_name_2 = "field.field.$field_id_2"; + $field_storage_config_name_2 = "field.storage.$field_id_2"; $instance_config_name_2a = "field.instance.$instance_id_2a"; $instance_config_name_2b = "field.instance.$instance_id_2b"; @@ -95,9 +95,9 @@ function testImportCreate() { // Add the new files to the staging directory. $src_dir = drupal_get_path('module', 'field_test_config') . '/staging'; $target_dir = $this->configDirectories[CONFIG_STAGING_DIRECTORY]; - $this->assertTrue(file_unmanaged_copy("$src_dir/$field_config_name.yml", "$target_dir/$field_config_name.yml")); + $this->assertTrue(file_unmanaged_copy("$src_dir/$field_storage_config_name.yml", "$target_dir/$field_storage_config_name.yml")); $this->assertTrue(file_unmanaged_copy("$src_dir/$instance_config_name.yml", "$target_dir/$instance_config_name.yml")); - $this->assertTrue(file_unmanaged_copy("$src_dir/$field_config_name_2.yml", "$target_dir/$field_config_name_2.yml")); + $this->assertTrue(file_unmanaged_copy("$src_dir/$field_storage_config_name_2.yml", "$target_dir/$field_storage_config_name_2.yml")); $this->assertTrue(file_unmanaged_copy("$src_dir/$instance_config_name_2a.yml", "$target_dir/$instance_config_name_2a.yml")); $this->assertTrue(file_unmanaged_copy("$src_dir/$instance_config_name_2b.yml", "$target_dir/$instance_config_name_2b.yml")); @@ -105,12 +105,12 @@ function testImportCreate() { $this->configImporter()->import(); // Check that the field and instance were created. - $field = entity_load('field_config', $field_id); - $this->assertTrue($field, 'Test import field from staging exists'); + $field_storage = entity_load('field_storage_config', $field_id); + $this->assertTrue($field_storage, 'Test import field from staging exists'); $instance = entity_load('field_instance_config', $instance_id); $this->assertTrue($instance, 'Test import field instance from staging exists'); - $field = entity_load('field_config', $field_id_2); - $this->assertTrue($field, 'Test import field 2 from staging exists'); + $field_storage = entity_load('field_storage_config', $field_id_2); + $this->assertTrue($field_storage, 'Test import field 2 from staging exists'); $instance = entity_load('field_instance_config', $instance_id_2a); $this->assertTrue($instance, 'Test import field instance 2a from staging exists'); $instance = entity_load('field_instance_config', $instance_id_2b); diff --git a/core/modules/field/src/Tests/FieldImportDeleteTest.php b/core/modules/field/src/Tests/FieldImportDeleteTest.php index 4358a4fac0f3..4b077d39adde 100644 --- a/core/modules/field/src/Tests/FieldImportDeleteTest.php +++ b/core/modules/field/src/Tests/FieldImportDeleteTest.php @@ -29,21 +29,21 @@ class FieldImportDeleteTest extends FieldUnitTestBase { public function testImportDelete() { // At this point there are 5 field configuration objects in the active // storage. - // - field.field.entity_test.field_test_import - // - field.field.entity_test.field_test_import_2 + // - field.storage.entity_test.field_test_import + // - field.storage.entity_test.field_test_import_2 // - field.instance.entity_test.entity_test.field_test_import // - field.instance.entity_test.entity_test.field_test_import_2 // - field.instance.entity_test.test_bundle.field_test_import_2 $field_name = 'field_test_import'; - $field_id = "entity_test.$field_name"; + $field_storage_id = "entity_test.$field_name"; $field_name_2 = 'field_test_import_2'; - $field_id_2 = "entity_test.$field_name_2"; + $field_storage_id_2 = "entity_test.$field_name_2"; $instance_id = "entity_test.entity_test.$field_name"; $instance_id_2a = "entity_test.entity_test.$field_name_2"; $instance_id_2b = "entity_test.test_bundle.$field_name_2"; - $field_config_name = "field.field.$field_id"; - $field_config_name_2 = "field.field.$field_id_2"; + $field_storage_config_name = "field.storage.$field_storage_id"; + $field_storage_config_name_2 = "field.storage.$field_storage_id_2"; $instance_config_name = "field.instance.$instance_id"; $instance_config_name_2a = "field.instance.$instance_id_2a"; $instance_config_name_2b = "field.instance.$instance_id_2b"; @@ -54,15 +54,15 @@ public function testImportDelete() { // Import default config. $this->installConfig(array('field_test_config')); - // Get the uuid's for the fields. - $field_uuid = entity_load('field_config', $field_id)->uuid(); - $field_uuid_2 = entity_load('field_config', $field_id_2)->uuid(); + // Get the uuid's for the field storages. + $field_storage_uuid = entity_load('field_storage_config', $field_storage_id)->uuid(); + $field_storage_uuid_2 = entity_load('field_storage_config', $field_storage_id_2)->uuid(); $active = $this->container->get('config.storage'); $staging = $this->container->get('config.storage.staging'); $this->copyConfig($active, $staging); - $this->assertTrue($staging->delete($field_config_name), String::format('Deleted field: !field', array('!field' => $field_config_name))); - $this->assertTrue($staging->delete($field_config_name_2), String::format('Deleted field: !field', array('!field' => $field_config_name_2))); + $this->assertTrue($staging->delete($field_storage_config_name), String::format('Deleted field: !field', array('!field' => $field_storage_config_name))); + $this->assertTrue($staging->delete($field_storage_config_name_2), String::format('Deleted field: !field', array('!field' => $field_storage_config_name_2))); $this->assertTrue($staging->delete($instance_config_name), String::format('Deleted field instance: !field_instance', array('!field_instance' => $instance_config_name))); $this->assertTrue($staging->delete($instance_config_name_2a), String::format('Deleted field instance: !field_instance', array('!field_instance' => $instance_config_name_2a))); $this->assertTrue($staging->delete($instance_config_name_2b), String::format('Deleted field instance: !field_instance', array('!field_instance' => $instance_config_name_2b))); @@ -74,10 +74,10 @@ public function testImportDelete() { $this->configImporter()->import(); // Check that the fields and instances are gone. - $field = entity_load('field_config', $field_id, TRUE); - $this->assertFalse($field, 'The field was deleted.'); - $field_2 = entity_load('field_config', $field_id_2, TRUE); - $this->assertFalse($field_2, 'The second field was deleted.'); + $field_storage = entity_load('field_storage_config', $field_storage_id, TRUE); + $this->assertFalse($field_storage, 'The field was deleted.'); + $field_storage_2 = entity_load('field_storage_config', $field_storage_id_2, TRUE); + $this->assertFalse($field_storage_2, 'The second field was deleted.'); $instance = entity_load('field_instance_config', $instance_id, TRUE); $this->assertFalse($instance, 'The field instance was deleted.'); $instance_2a = entity_load('field_instance_config', $instance_id_2a, TRUE); @@ -87,22 +87,22 @@ public function testImportDelete() { // Check that all config files are gone. $active = $this->container->get('config.storage'); - $this->assertIdentical($active->listAll($field_config_name), array()); - $this->assertIdentical($active->listAll($field_config_name_2), array()); + $this->assertIdentical($active->listAll($field_storage_config_name), array()); + $this->assertIdentical($active->listAll($field_storage_config_name_2), array()); $this->assertIdentical($active->listAll($instance_config_name), array()); $this->assertIdentical($active->listAll($instance_config_name_2a), array()); $this->assertIdentical($active->listAll($instance_config_name_2b), array()); - // Check that the field definition is preserved in state. - $deleted_fields = \Drupal::state()->get('field.field.deleted') ?: array(); - $this->assertTrue(isset($deleted_fields[$field_uuid])); - $this->assertTrue(isset($deleted_fields[$field_uuid_2])); + // Check that the storage definition is preserved in state. + $deleted_storages = \Drupal::state()->get('field.storage.deleted') ?: array(); + $this->assertTrue(isset($deleted_storages[$field_storage_uuid])); + $this->assertTrue(isset($deleted_storages[$field_storage_uuid_2])); - // Purge field data, and check that the field definition has been completely - // removed once the data is purged. + // Purge field data, and check that the storage definition has been + // completely removed once the data is purged. field_purge_batch(10); - $deleted_fields = \Drupal::state()->get('field.field.deleted') ?: array(); - $this->assertTrue(empty($deleted_fields), 'Fields are deleted'); + $deleted_storages = \Drupal::state()->get('field.storage.deleted') ?: array(); + $this->assertTrue(empty($deleted_storages), 'Fields are deleted'); } } diff --git a/core/modules/field/src/Tests/FieldImportDeleteUninstallTest.php b/core/modules/field/src/Tests/FieldImportDeleteUninstallTest.php index 05d2d6f6ef21..56ce852d0c74 100644 --- a/core/modules/field/src/Tests/FieldImportDeleteUninstallTest.php +++ b/core/modules/field/src/Tests/FieldImportDeleteUninstallTest.php @@ -40,28 +40,26 @@ public function testImportDeleteUninstall() { // Create a field to delete to prove that // \Drupal\field\ConfigImporterFieldPurger does not purge fields that are // not related to the configuration synchronization. - $unrelated_field = entity_create('field_config', array( + $unrelated_field_storage = entity_create('field_storage_config', array( 'name' => 'field_int', 'entity_type' => 'entity_test', 'type' => 'integer', )); - $unrelated_field->save(); - $unrelated_field_uuid = $unrelated_field->uuid(); + $unrelated_field_storage->save(); entity_create('field_instance_config', array( - 'field' => $unrelated_field, + 'field_storage' => $unrelated_field_storage, 'bundle' => 'entity_test', ))->save(); // Create a telephone field and instance for validation. - $field = entity_create('field_config', array( + $field_storage = entity_create('field_storage_config', array( 'name' => 'field_test', 'entity_type' => 'entity_test', 'type' => 'telephone', )); - $field->save(); - $field_uuid = $field->uuid(); + $field_storage->save(); entity_create('field_instance_config', array( - 'field' => $field, + 'field_storage' => $field_storage, 'bundle' => 'entity_test', ))->save(); @@ -81,7 +79,7 @@ public function testImportDeleteUninstall() { // Delete unrelated field before copying configuration and running the // synchronization. - $unrelated_field->delete(); + $unrelated_field_storage->delete(); $active = $this->container->get('config.storage'); $staging = $this->container->get('config.storage.staging'); @@ -93,7 +91,7 @@ public function testImportDeleteUninstall() { $staging->write('core.extension', $core_extension); // Stage the field deletion - $staging->delete('field.field.entity_test.field_test'); + $staging->delete('field.storage.entity_test.field_test'); $staging->delete('field.instance.entity_test.entity_test.field_test'); $steps = $this->configImporter()->initialize(); @@ -104,10 +102,10 @@ public function testImportDeleteUninstall() { $this->configImporter()->import(); $this->assertFalse(\Drupal::moduleHandler()->moduleExists('telephone')); - $this->assertFalse(entity_load_by_uuid('field_config', $field_uuid), 'The test field has been deleted by the configuration synchronization'); - $deleted_fields = \Drupal::state()->get('field.field.deleted') ?: array(); - $this->assertFalse(isset($deleted_fields[$field_uuid]), 'Telephone field has been completed removed from the system.'); - $this->assertTrue(isset($deleted_fields[$unrelated_field_uuid]), 'Unrelated field not purged by configuration synchronization.'); + $this->assertFalse(entity_load_by_uuid('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.'); } /** @@ -115,15 +113,15 @@ public function testImportDeleteUninstall() { */ public function testImportAlreadyDeletedUninstall() { // Create a telephone field and instance for validation. - $field = entity_create('field_config', array( + $field_storage = entity_create('field_storage_config', array( 'name' => 'field_test', 'entity_type' => 'entity_test', 'type' => 'telephone', )); - $field->save(); - $field_uuid = $field->uuid(); + $field_storage->save(); + $field_storage_uuid = $field_storage->uuid(); entity_create('field_instance_config', array( - 'field' => $field, + 'field_storage' => $field_storage, 'bundle' => 'entity_test', ))->save(); @@ -142,7 +140,7 @@ public function testImportAlreadyDeletedUninstall() { } // Delete the field. - $field->delete(); + $field_storage->delete(); $active = $this->container->get('config.storage'); $staging = $this->container->get('config.storage.staging'); @@ -153,8 +151,8 @@ public function testImportAlreadyDeletedUninstall() { unset($core_extension['module']['telephone']); $staging->write('core.extension', $core_extension); - $deleted_fields = \Drupal::state()->get('field.field.deleted') ?: array(); - $this->assertTrue(isset($deleted_fields[$field_uuid]), 'Field has been deleted and needs purging before configuration synchronization.'); + $deleted_storages = \Drupal::state()->get('field.storage.deleted') ?: array(); + $this->assertTrue(isset($deleted_storages[$field_storage_uuid]), 'Field has been deleted and needs purging before configuration synchronization.'); $steps = $this->configImporter()->initialize(); $this->assertIdentical($steps[0], array('\Drupal\field\ConfigImporterFieldPurger', 'process'), 'The additional process configuration synchronization step has been added.'); @@ -164,8 +162,8 @@ public function testImportAlreadyDeletedUninstall() { $this->configImporter()->import(); $this->assertFalse(\Drupal::moduleHandler()->moduleExists('telephone')); - $deleted_fields = \Drupal::state()->get('field.field.deleted') ?: array(); - $this->assertFalse(isset($deleted_fields[$field_uuid]), 'Field has been completed removed from the system.'); + $deleted_storages = \Drupal::state()->get('field.storage.deleted') ?: array(); + $this->assertFalse(isset($deleted_storages[$field_storage_uuid]), 'Field has been completed removed from the system.'); } } diff --git a/core/modules/field/src/Tests/FieldImportDeleteUninstallUiTest.php b/core/modules/field/src/Tests/FieldImportDeleteUninstallUiTest.php index e4512a7b9dc1..2de434827e8c 100644 --- a/core/modules/field/src/Tests/FieldImportDeleteUninstallUiTest.php +++ b/core/modules/field/src/Tests/FieldImportDeleteUninstallUiTest.php @@ -37,28 +37,26 @@ function setUp() { */ public function testImportDeleteUninstall() { // Create a telephone field and instance. - $field = entity_create('field_config', array( + $field_storage = entity_create('field_storage_config', array( 'name' => 'field_tel', 'entity_type' => 'entity_test', 'type' => 'telephone', )); - $field->save(); - $tel_field_uuid = $field->uuid(); + $field_storage->save(); entity_create('field_instance_config', array( - 'field' => $field, + 'field_storage' => $field_storage, 'bundle' => 'entity_test', ))->save(); // Create a text field and instance. - $text_field = entity_create('field_config', array( + $text_field_storage = entity_create('field_storage_config', array( 'name' => 'field_text', 'entity_type' => 'entity_test', 'type' => 'text', )); - $text_field->save(); - $text_field_uuid = $field->uuid(); + $text_field_storage->save(); entity_create('field_instance_config', array( - 'field' => $text_field, + 'field_storage' => $text_field_storage, 'bundle' => 'entity_test', ))->save(); @@ -73,7 +71,7 @@ public function testImportDeleteUninstall() { // Delete the text field before exporting configuration so that we can test // that deleted fields that are provided by modules that will be uninstalled // are also purged and that the UI message includes such fields. - $text_field->delete(); + $text_field_storage->delete(); // Verify entity has been created properly. $id = $entity->id(); @@ -91,7 +89,7 @@ public function testImportDeleteUninstall() { $staging->write('core.extension', $core_extension); // Stage the field deletion - $staging->delete('field.field.entity_test.field_tel'); + $staging->delete('field.storage.entity_test.field_tel'); $staging->delete('field.instance.entity_test.entity_test.field_tel'); $this->drupalGet('admin/config/development/configuration'); // Test that the message for one field being purged during a configuration @@ -111,10 +109,10 @@ public function testImportDeleteUninstall() { $this->assertNoText('Field data will be deleted by this synchronization.'); $this->rebuildContainer(); $this->assertFalse(\Drupal::moduleHandler()->moduleExists('telephone')); - $this->assertFalse(entity_load_by_uuid('field_config', $tel_field_uuid), 'The telephone field has been deleted by the configuration synchronization'); - $deleted_fields = \Drupal::state()->get('field.field.deleted') ?: array(); - $this->assertFalse(isset($deleted_fields[$tel_field_uuid]), 'Telephone field has been completed removed from the system.'); - $this->assertFalse(isset($deleted_fields[$text_field_uuid]), 'Text field has been completed removed from the system.'); + $this->assertFalse(entity_load_by_uuid('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/FieldInstanceCrudTest.php b/core/modules/field/src/Tests/FieldInstanceCrudTest.php index f5f847f2e256..5af3b2181f94 100644 --- a/core/modules/field/src/Tests/FieldInstanceCrudTest.php +++ b/core/modules/field/src/Tests/FieldInstanceCrudTest.php @@ -8,7 +8,7 @@ namespace Drupal\field\Tests; use Drupal\Core\Entity\EntityStorageException; -use Drupal\field\Entity\FieldConfig; +use Drupal\field\Entity\FieldStorageConfig; use Drupal\field\Entity\FieldInstanceConfig; use Drupal\field\FieldException; @@ -20,38 +20,38 @@ class FieldInstanceCrudTest extends FieldUnitTestBase { /** - * The field entity. + * The field storage entity. * - * @var \Drupal\field\Entity\FieldConfig + * @var \Drupal\field\Entity\FieldStorageConfig */ - protected $field; + protected $fieldStorage; /** * The field entity definition. * * @var array */ - protected $field_definition; + protected $fieldStorageDefinition; /** * The field instance entity definition. * * @var array */ - protected $instance_definition; + protected $instanceDefinition; function setUp() { parent::setUp(); - $this->field_definition = array( + $this->fieldStorageDefinition = array( 'name' => drupal_strtolower($this->randomName()), 'entity_type' => 'entity_test', 'type' => 'test_field', ); - $this->field = entity_create('field_config', $this->field_definition); - $this->field->save(); - $this->instance_definition = array( - 'field_name' => $this->field->getName(), + $this->fieldStorage = entity_create('field_storage_config', $this->fieldStorageDefinition); + $this->fieldStorage->save(); + $this->instanceDefinition = array( + 'field_name' => $this->fieldStorage->getName(), 'entity_type' => 'entity_test', 'bundle' => 'entity_test', ); @@ -67,7 +67,7 @@ function setUp() { * Test the creation of a field instance. */ function testCreateFieldInstance() { - $instance = entity_create('field_instance_config', $this->instance_definition); + $instance = entity_create('field_instance_config', $this->instanceDefinition); $instance->save(); // Read the configuration. Check against raw configuration data rather than @@ -78,18 +78,18 @@ function testCreateFieldInstance() { // Check that default values are set. $this->assertEqual($config['required'], FALSE, 'Required defaults to false.'); - $this->assertIdentical($config['label'], $this->instance_definition['field_name'], 'Label defaults to field name.'); + $this->assertIdentical($config['label'], $this->instanceDefinition['field_name'], 'Label defaults to field name.'); $this->assertIdentical($config['description'], '', 'Description defaults to empty string.'); // Check that default settings are set. - $this->assertEqual($config['settings'], $field_type_manager->getDefaultInstanceSettings($this->field_definition['type']) , 'Default instance settings have been written.'); + $this->assertEqual($config['settings'], $field_type_manager->getDefaultInstanceSettings($this->fieldStorageDefinition['type']) , 'Default instance settings have been written.'); // Check that the denormalized 'field_type' was properly written. - $this->assertEqual($config['field_type'], $this->field_definition['type']); + $this->assertEqual($config['field_type'], $this->fieldStorageDefinition['type']); // Guarantee that the field/bundle combination is unique. try { - entity_create('field_instance_config', $this->instance_definition)->save(); + entity_create('field_instance_config', $this->instanceDefinition)->save(); $this->fail(t('Cannot create two instances with the same field / bundle combination.')); } catch (EntityStorageException $e) { @@ -98,8 +98,8 @@ function testCreateFieldInstance() { // Check that the specified field exists. try { - $this->instance_definition['field_name'] = $this->randomName(); - entity_create('field_instance_config', $this->instance_definition)->save(); + $this->instanceDefinition['field_name'] = $this->randomName(); + entity_create('field_instance_config', $this->instanceDefinition)->save(); $this->fail(t('Cannot create an instance of a non-existing field.')); } catch (FieldException $e) { @@ -113,30 +113,30 @@ function testCreateFieldInstance() { * Test reading back an instance definition. */ function testReadFieldInstance() { - entity_create('field_instance_config', $this->instance_definition)->save(); + entity_create('field_instance_config', $this->instanceDefinition)->save(); // Read the instance back. - $instance = entity_load('field_instance_config', 'entity_test.' . $this->instance_definition['bundle'] . '.' . $this->instance_definition['field_name']); - $this->assertTrue($this->instance_definition['field_name'] == $instance->getName(), 'The field was properly read.'); - $this->assertTrue($this->instance_definition['entity_type'] == $instance->entity_type, 'The field was properly read.'); - $this->assertTrue($this->instance_definition['bundle'] == $instance->bundle, 'The field was properly read.'); + $instance = entity_load('field_instance_config', 'entity_test.' . $this->instanceDefinition['bundle'] . '.' . $this->instanceDefinition['field_name']); + $this->assertTrue($this->instanceDefinition['field_name'] == $instance->getName(), 'The field was properly read.'); + $this->assertTrue($this->instanceDefinition['entity_type'] == $instance->entity_type, 'The field was properly read.'); + $this->assertTrue($this->instanceDefinition['bundle'] == $instance->bundle, 'The field was properly read.'); } /** * Test the update of a field instance. */ function testUpdateFieldInstance() { - entity_create('field_instance_config', $this->instance_definition)->save(); + entity_create('field_instance_config', $this->instanceDefinition)->save(); // Check that basic changes are saved. - $instance = entity_load('field_instance_config', 'entity_test.' . $this->instance_definition['bundle'] . '.' . $this->instance_definition['field_name']); + $instance = entity_load('field_instance_config', 'entity_test.' . $this->instanceDefinition['bundle'] . '.' . $this->instanceDefinition['field_name']); $instance->required = !$instance->isRequired(); $instance->label = $this->randomName(); $instance->description = $this->randomName(); $instance->settings['test_instance_setting'] = $this->randomName(); $instance->save(); - $instance_new = entity_load('field_instance_config', 'entity_test.' . $this->instance_definition['bundle'] . '.' . $this->instance_definition['field_name']); + $instance_new = entity_load('field_instance_config', 'entity_test.' . $this->instanceDefinition['bundle'] . '.' . $this->instanceDefinition['field_name']); $this->assertEqual($instance->isRequired(), $instance_new->isRequired(), '"required" change is saved'); $this->assertEqual($instance->getLabel(), $instance_new->getLabel(), '"label" change is saved'); $this->assertEqual($instance->getDescription(), $instance_new->getDescription(), '"description" change is saved'); @@ -154,24 +154,24 @@ function testDeleteFieldInstance() { // Create two instances for the same field so we can test that only one // is deleted. - entity_create('field_instance_config', $this->instance_definition)->save(); - $another_instance_definition = $this->instance_definition; + entity_create('field_instance_config', $this->instanceDefinition)->save(); + $another_instance_definition = $this->instanceDefinition; $another_instance_definition['bundle'] .= '_another_bundle'; entity_test_create_bundle($another_instance_definition['bundle']); entity_create('field_instance_config', $another_instance_definition)->save(); // Test that the first instance is not deleted, and then delete it. - $instance = current(entity_load_multiple_by_properties('field_instance_config', array('entity_type' => 'entity_test', 'field_name' => $this->instance_definition['field_name'], 'bundle' => $this->instance_definition['bundle'], 'include_deleted' => TRUE))); + $instance = current(entity_load_multiple_by_properties('field_instance_config', array('entity_type' => 'entity_test', 'field_name' => $this->instanceDefinition['field_name'], 'bundle' => $this->instanceDefinition['bundle'], 'include_deleted' => TRUE))); $this->assertTrue(!empty($instance) && empty($instance->deleted), 'A new field instance is not marked for deletion.'); $instance->delete(); // Make sure the instance is marked as deleted when the instance is // specifically loaded. - $instance = current(entity_load_multiple_by_properties('field_instance_config', array('entity_type' => 'entity_test', 'field_name' => $this->instance_definition['field_name'], 'bundle' => $this->instance_definition['bundle'], 'include_deleted' => TRUE))); + $instance = current(entity_load_multiple_by_properties('field_instance_config', array('entity_type' => 'entity_test', 'field_name' => $this->instanceDefinition['field_name'], 'bundle' => $this->instanceDefinition['bundle'], 'include_deleted' => TRUE))); $this->assertTrue(!empty($instance->deleted), 'A deleted field instance is marked for deletion.'); // Try to load the instance normally and make sure it does not show up. - $instance = entity_load('field_instance_config', 'entity_test.' . '.' . $this->instance_definition['bundle'] . '.' . $this->instance_definition['field_name']); + $instance = entity_load('field_instance_config', 'entity_test.' . '.' . $this->instanceDefinition['bundle'] . '.' . $this->instanceDefinition['field_name']); $this->assertTrue(empty($instance), 'A deleted field instance is not loaded by default.'); // Make sure the other field instance is not deleted. @@ -183,41 +183,40 @@ function testDeleteFieldInstance() { * Tests the cross deletion behavior between fields and instances. */ function testDeleteFieldInstanceCrossDeletion() { - $instance_definition_2 = $this->instance_definition; + $instance_definition_2 = $this->instanceDefinition; $instance_definition_2['bundle'] .= '_another_bundle'; entity_test_create_bundle($instance_definition_2['bundle']); // Check that deletion of a field deletes its instances. - $field = $this->field; - entity_create('field_instance_config', $this->instance_definition)->save(); + $field_storage = $this->fieldStorage; + entity_create('field_instance_config', $this->instanceDefinition)->save(); entity_create('field_instance_config', $instance_definition_2)->save(); - $field->delete(); - $this->assertFalse(FieldInstanceConfig::loadByName('entity_test', $this->instance_definition['bundle'], $field->name)); - $this->assertFalse(FieldInstanceConfig::loadByName('entity_test', $instance_definition_2['bundle'], $field->name)); + $field_storage->delete(); + $this->assertFalse(FieldInstanceConfig::loadByName('entity_test', $this->instanceDefinition['bundle'], $field_storage->name)); + $this->assertFalse(FieldInstanceConfig::loadByName('entity_test', $instance_definition_2['bundle'], $field_storage->name)); // Chack that deletion of the last instance deletes the field. - $field = entity_create('field_config', $this->field_definition); - $field->save(); - $instance = entity_create('field_instance_config', $this->instance_definition); + $field_storage = entity_create('field_storage_config', $this->fieldStorageDefinition); + $field_storage->save(); + $instance = entity_create('field_instance_config', $this->instanceDefinition); $instance->save(); $instance_2 = entity_create('field_instance_config', $instance_definition_2); $instance_2->save(); $instance->delete(); - $this->assertTrue(FieldConfig::loadByName('entity_test', $field->name)); + $this->assertTrue(FieldStorageConfig::loadByName('entity_test', $field_storage->name)); $instance_2->delete(); - $this->assertFalse(FieldConfig::loadByName('entity_test', $field->name)); + $this->assertFalse(FieldStorageConfig::loadByName('entity_test', $field_storage->name)); // Check that deletion of all instances of the same field simultaneously // deletes the field. - $field = entity_create('field_config', $this->field_definition); - $field->save(); - $instance = entity_create('field_instance_config', $this->instance_definition); + $field_storage = entity_create('field_storage_config', $this->fieldStorageDefinition); + $field_storage->save(); + $instance = entity_create('field_instance_config', $this->instanceDefinition); $instance->save(); $instance_2 = entity_create('field_instance_config', $instance_definition_2); $instance_2->save(); - $instance_storage = $this->container->get('entity.manager')->getStorage('field_instance_config'); - $instance_storage->delete(array($instance, $instance_2)); - $this->assertFalse(FieldConfig::loadByName('entity_test', $field->name)); + $this->container->get('entity.manager')->getStorage('field_instance_config')->delete(array($instance, $instance_2)); + $this->assertFalse(FieldStorageConfig::loadByName('entity_test', $field_storage->name)); } } diff --git a/core/modules/field/src/Tests/FieldUnitTestBase.php b/core/modules/field/src/Tests/FieldUnitTestBase.php index ecc278ab5551..9c82d59452b5 100644 --- a/core/modules/field/src/Tests/FieldUnitTestBase.php +++ b/core/modules/field/src/Tests/FieldUnitTestBase.php @@ -54,22 +54,22 @@ function createFieldWithInstance($suffix = '', $entity_type = 'entity_test', $bu $bundle = $entity_type; } $field_name = 'field_name' . $suffix; - $field = 'field' . $suffix; - $field_id = 'field_id' . $suffix; + $field_storage = 'field_storage' . $suffix; + $field_storage_uuid = 'field_storage_uuid' . $suffix; $instance = 'instance' . $suffix; $instance_definition = 'instance_definition' . $suffix; $this->$field_name = drupal_strtolower($this->randomName() . '_field_name' . $suffix); - $this->$field = entity_create('field_config', array( + $this->$field_storage = entity_create('field_storage_config', array( 'name' => $this->$field_name, 'entity_type' => $entity_type, 'type' => 'test_field', 'cardinality' => 4, )); - $this->$field->save(); - $this->$field_id = $this->{$field}->uuid(); + $this->$field_storage->save(); + $this->$field_storage_uuid = $this->{$field_storage}->uuid(); $this->$instance_definition = array( - 'field' => $this->$field, + 'field_storage' => $this->$field_storage, 'bundle' => $bundle, 'label' => $this->randomName() . '_label', 'description' => $this->randomName() . '_description', diff --git a/core/modules/field/src/Tests/FieldValidationTest.php b/core/modules/field/src/Tests/FieldValidationTest.php index fa28f81f6959..7b9cca21b390 100644 --- a/core/modules/field/src/Tests/FieldValidationTest.php +++ b/core/modules/field/src/Tests/FieldValidationTest.php @@ -35,7 +35,7 @@ public function setUp() { * Tests that the number of values is validated against the field cardinality. */ function testCardinalityConstraint() { - $cardinality = $this->field->cardinality; + $cardinality = $this->field_storage->cardinality; $entity = $this->entity; for ($delta = 0; $delta < $cardinality + 1; $delta++) { @@ -55,7 +55,7 @@ function testCardinalityConstraint() { * Tests that constraints defined by the field type are validated. */ function testFieldConstraints() { - $cardinality = $this->field->getCardinality(); + $cardinality = $this->field_storage->getCardinality(); $entity = $this->entity; // The test is only valid if the field cardinality is greater than 2. diff --git a/core/modules/field/src/Tests/FormTest.php b/core/modules/field/src/Tests/FormTest.php index 2830abecb079..2457aa72a907 100644 --- a/core/modules/field/src/Tests/FormTest.php +++ b/core/modules/field/src/Tests/FormTest.php @@ -29,21 +29,21 @@ class FormTest extends FieldTestBase { * * @var array */ - protected $field_single; + protected $fieldStorageSingle; /** * An array of values defining a field multiple. * * @var array */ - protected $field_multiple; + protected $fieldStorageMultiple; /** * An array of values defining a field with unlimited cardinality. * * @var array */ - protected $field_unlimited; + protected $fieldStorageUnlimited; /** * An array of values defining a field instance. @@ -58,18 +58,18 @@ function setUp() { $web_user = $this->drupalCreateUser(array('view test entity', 'administer entity_test content')); $this->drupalLogin($web_user); - $this->field_single = array( + $this->fieldStorageSingle = array( 'name' => 'field_single', 'entity_type' => 'entity_test', 'type' => 'test_field', ); - $this->field_multiple = array( + $this->fieldStorageMultiple = array( 'name' => 'field_multiple', 'entity_type' => 'entity_test', 'type' => 'test_field', 'cardinality' => 4, ); - $this->field_unlimited = array( + $this->fieldStorageUnlimited = array( 'name' => 'field_unlimited', 'entity_type' => 'entity_test', 'type' => 'test_field', @@ -89,10 +89,10 @@ function setUp() { } function testFieldFormSingle() { - $field = $this->field_single; - $field_name = $field['name']; + $field_storage = $this->fieldStorageSingle; + $field_name = $field_storage['name']; $this->instance['field_name'] = $field_name; - entity_create('field_config', $field)->save(); + entity_create('field_storage_config', $field_storage)->save(); entity_create('field_instance_config', $this->instance)->save(); entity_get_form_display($this->instance['entity_type'], $this->instance['bundle'], 'default') ->setComponent($field_name) @@ -171,12 +171,12 @@ function testFieldFormSingle() { * Tests field widget default values on entity forms. */ function testFieldFormDefaultValue() { - $field = $this->field_single; - $field_name = $field['name']; + $field_storage = $this->fieldStorageSingle; + $field_name = $field_storage['name']; $this->instance['field_name'] = $field_name; $default = rand(1, 127); $this->instance['default_value'] = array(array('value' => $default)); - entity_create('field_config', $field)->save(); + entity_create('field_storage_config', $field_storage)->save(); entity_create('field_instance_config', $this->instance)->save(); entity_get_form_display($this->instance['entity_type'], $this->instance['bundle'], 'default') ->setComponent($field_name) @@ -202,11 +202,11 @@ function testFieldFormDefaultValue() { } function testFieldFormSingleRequired() { - $field = $this->field_single; - $field_name = $field['name']; + $field_storage = $this->fieldStorageSingle; + $field_name = $field_storage['name']; $this->instance['field_name'] = $field_name; $this->instance['required'] = TRUE; - entity_create('field_config', $field)->save(); + entity_create('field_storage_config', $field_storage)->save(); entity_create('field_instance_config', $this->instance)->save(); entity_get_form_display($this->instance['entity_type'], $this->instance['bundle'], 'default') ->setComponent($field_name) @@ -246,15 +246,15 @@ function testFieldFormSingleRequired() { // $this->field = $this->field_multiple; // $field_name = $this->field['field_name']; // $this->instance['field_name'] = $field_name; -// entity_create('field_config', $this->field)->save(); +// entity_create('field_storage_config', $this->field)->save(); // entity_create('field_instance_config', $this->instance)->save(); // } function testFieldFormUnlimited() { - $field = $this->field_unlimited; - $field_name = $field['name']; + $field_storage = $this->fieldStorageUnlimited; + $field_name = $field_storage['name']; $this->instance['field_name'] = $field_name; - entity_create('field_config', $field)->save(); + entity_create('field_storage_config', $field_storage)->save(); entity_create('field_instance_config', $this->instance)->save(); entity_get_form_display($this->instance['entity_type'], $this->instance['bundle'], 'default') ->setComponent($field_name) @@ -337,17 +337,17 @@ function testFieldFormUnlimited() { */ function testFieldFormMultivalueWithRequiredRadio() { // Create a multivalue test field. - $field = $this->field_unlimited; - $field_name = $field['name']; + $field_storage = $this->fieldStorageUnlimited; + $field_name = $field_storage['name']; $this->instance['field_name'] = $field_name; - entity_create('field_config', $field)->save(); + entity_create('field_storage_config', $field_storage)->save(); entity_create('field_instance_config', $this->instance)->save(); entity_get_form_display($this->instance['entity_type'], $this->instance['bundle'], 'default') ->setComponent($field_name) ->save(); // Add a required radio field. - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => 'required_radio_test', 'entity_type' => 'entity_test', 'type' => 'list_text', @@ -384,10 +384,10 @@ function testFieldFormMultivalueWithRequiredRadio() { } function testFieldFormJSAddMore() { - $field = $this->field_unlimited; - $field_name = $field['name']; + $field_storage = $this->fieldStorageUnlimited; + $field_name = $field_storage['name']; $this->instance['field_name'] = $field_name; - entity_create('field_config', $field)->save(); + entity_create('field_storage_config', $field_storage)->save(); entity_create('field_instance_config', $this->instance)->save(); entity_get_form_display($this->instance['entity_type'], $this->instance['bundle'], 'default') ->setComponent($field_name) @@ -445,10 +445,10 @@ function testFieldFormJSAddMore() { function testFieldFormMultipleWidget() { // Create a field with fixed cardinality and an instance using a multiple // widget. - $field = $this->field_multiple; - $field_name = $field['name']; + $field_storage = $this->fieldStorageMultiple; + $field_name = $field_storage['name']; $this->instance['field_name'] = $field_name; - entity_create('field_config', $field)->save(); + entity_create('field_storage_config', $field_storage)->save(); entity_create('field_instance_config', $this->instance)->save(); entity_get_form_display($this->instance['entity_type'], $this->instance['bundle'], 'default') ->setComponent($field_name, array( @@ -492,14 +492,14 @@ function testFieldFormMultipleWidget() { function testFieldFormAccess() { $entity_type = 'entity_test_rev'; // Create a "regular" field. - $field = $this->field_single; - $field['entity_type'] = $entity_type; - $field_name = $field['name']; + $field_storage = $this->fieldStorageSingle; + $field_storage['entity_type'] = $entity_type; + $field_name = $field_storage['name']; $instance = $this->instance; $instance['field_name'] = $field_name; $instance['entity_type'] = $entity_type; $instance['bundle'] = $entity_type; - entity_create('field_config', $field)->save(); + entity_create('field_storage_config', $field_storage)->save(); entity_create('field_instance_config', $instance)->save(); entity_get_form_display($entity_type, $entity_type, 'default') ->setComponent($field_name) @@ -507,19 +507,19 @@ function testFieldFormAccess() { // Create a field with no edit access. See // field_test_entity_field_access(). - $field_no_access = array( + $field_storage_no_access = array( 'name' => 'field_no_edit_access', 'entity_type' => $entity_type, 'type' => 'test_field', ); - $field_name_no_access = $field_no_access['name']; + $field_name_no_access = $field_storage_no_access['name']; $instance_no_access = array( 'field_name' => $field_name_no_access, 'entity_type' => $entity_type, 'bundle' => $entity_type, 'default_value' => array(0 => array('value' => 99)), ); - entity_create('field_config', $field_no_access)->save(); + entity_create('field_storage_config', $field_storage_no_access)->save(); entity_create('field_instance_config', $instance_no_access)->save(); entity_get_form_display($instance_no_access['entity_type'], $instance_no_access['bundle'], 'default') ->setComponent($field_name_no_access) @@ -581,14 +581,14 @@ function testFieldFormAccess() { */ function testHiddenField() { $entity_type = 'entity_test_rev'; - $field = $this->field_single; - $field['entity_type'] = $entity_type; - $field_name = $field['name']; + $field_storage = $this->fieldStorageSingle; + $field_storage['entity_type'] = $entity_type; + $field_name = $field_storage['name']; $this->instance['field_name'] = $field_name; $this->instance['default_value'] = array(0 => array('value' => 99)); $this->instance['entity_type'] = $entity_type; $this->instance['bundle'] = $entity_type; - entity_create('field_config', $field)->save(); + entity_create('field_storage_config', $field_storage)->save(); $this->instance = entity_create('field_instance_config', $this->instance); $this->instance->save(); // We explicitly do not assign a widget in a form display, so the field diff --git a/core/modules/field/src/Tests/NestedFormTest.php b/core/modules/field/src/Tests/NestedFormTest.php index 1a4659c286c1..fc0c9b656285 100644 --- a/core/modules/field/src/Tests/NestedFormTest.php +++ b/core/modules/field/src/Tests/NestedFormTest.php @@ -28,12 +28,12 @@ public function setUp() { $web_user = $this->drupalCreateUser(array('view test entity', 'administer entity_test content')); $this->drupalLogin($web_user); - $this->field_single = array( + $this->fieldStorageSingle = array( 'name' => 'field_single', 'entity_type' => 'entity_test', 'type' => 'test_field', ); - $this->field_unlimited = array( + $this->fieldStorageUnlimited = array( 'name' => 'field_unlimited', 'entity_type' => 'entity_test', 'type' => 'test_field', @@ -57,8 +57,8 @@ public function setUp() { */ function testNestedFieldForm() { // Add two instances on the 'entity_test' - entity_create('field_config', $this->field_single)->save(); - entity_create('field_config', $this->field_unlimited)->save(); + entity_create('field_storage_config', $this->fieldStorageSingle)->save(); + entity_create('field_storage_config', $this->fieldStorageUnlimited)->save(); $this->instance['field_name'] = 'field_single'; $this->instance['label'] = 'Single field'; entity_create('field_instance_config', $this->instance)->save(); diff --git a/core/modules/field/src/Tests/Number/NumberFieldTest.php b/core/modules/field/src/Tests/Number/NumberFieldTest.php index 574d2bf8b69c..80cbe9497407 100644 --- a/core/modules/field/src/Tests/Number/NumberFieldTest.php +++ b/core/modules/field/src/Tests/Number/NumberFieldTest.php @@ -23,20 +23,6 @@ class NumberFieldTest extends WebTestBase { */ public static $modules = array('node', 'entity_test', 'field_ui'); - /** - * A field to use in this class. - * - * @var \Drupal\field\Entity\FieldConfig - */ - protected $field; - - /** - * A field instance to use in this test class. - * - * @var \Drupal\field\Entity\FieldInstanceConfig - */ - protected $instance; - /** * A user with permission to view and manage entities and content types. * @@ -57,7 +43,7 @@ function setUp() { function testNumberDecimalField() { // Create a field with settings to validate. $field_name = drupal_strtolower($this->randomName()); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => $field_name, 'entity_type' => 'entity_test', 'type' => 'decimal', @@ -149,7 +135,7 @@ function testNumberIntegerField() { // Create a field with settings to validate. $field_name = drupal_strtolower($this->randomName()); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => $field_name, 'entity_type' => 'entity_test', 'type' => 'integer', @@ -253,7 +239,7 @@ function testNumberIntegerField() { function testNumberFloatField() { // Create a field with settings to validate. $field_name = drupal_strtolower($this->randomName()); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => $field_name, 'entity_type' => 'entity_test', 'type' => 'float', @@ -352,13 +338,13 @@ function testNumberFormatter() { // Create a content type containing float and integer fields. $this->drupalCreateContentType(array('type' => $type)); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => $float_field, 'entity_type' => 'node', 'type' => 'float', ))->save(); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => $integer_field, 'entity_type' => 'node', 'type' => 'integer', diff --git a/core/modules/field/src/Tests/Number/NumberItemTest.php b/core/modules/field/src/Tests/Number/NumberItemTest.php index ff1b2745242b..645b8d1b01eb 100644 --- a/core/modules/field/src/Tests/Number/NumberItemTest.php +++ b/core/modules/field/src/Tests/Number/NumberItemTest.php @@ -30,7 +30,7 @@ public function setUp() { // Create number fields and instances for validation. foreach (array('integer', 'float', 'decimal') as $type) { - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => 'field_' . $type, 'entity_type' => 'entity_test', 'type' => $type, diff --git a/core/modules/field/src/Tests/ShapeItemTest.php b/core/modules/field/src/Tests/ShapeItemTest.php index 2f83ab0061d6..771bc67b55b3 100644 --- a/core/modules/field/src/Tests/ShapeItemTest.php +++ b/core/modules/field/src/Tests/ShapeItemTest.php @@ -35,18 +35,16 @@ public function setUp() { parent::setUp(); // Create an field field and instance for validation. - $field = array( + entity_create('field_storage_config', array( 'name' => $this->field_name, 'entity_type' => 'entity_test', 'type' => 'shape', - ); - entity_create('field_config', $field)->save(); - $instance = array( + ))->save(); + entity_create('field_instance_config', array( 'entity_type' => 'entity_test', 'field_name' => $this->field_name, 'bundle' => 'entity_test', - ); - entity_create('field_instance_config', $instance)->save(); + ))->save(); } /** diff --git a/core/modules/field/src/Tests/TestItemTest.php b/core/modules/field/src/Tests/TestItemTest.php index b7978bc9eb54..742bc6b90aec 100644 --- a/core/modules/field/src/Tests/TestItemTest.php +++ b/core/modules/field/src/Tests/TestItemTest.php @@ -36,18 +36,16 @@ public function setUp() { parent::setUp(); // Create an field field and instance for validation. - $field = array( + entity_create('field_storage_config', array( 'name' => $this->field_name, 'entity_type' => 'entity_test', 'type' => 'test_field', - ); - entity_create('field_config', $field)->save(); - $instance = array( + ))->save(); + entity_create('field_instance_config', array( 'entity_type' => 'entity_test', 'field_name' => $this->field_name, 'bundle' => 'entity_test', - ); - entity_create('field_instance_config', $instance)->save(); + ))->save(); } /** diff --git a/core/modules/field/src/Tests/TranslationTest.php b/core/modules/field/src/Tests/TranslationTest.php index b45e6161c6eb..6a5f0457e36a 100644 --- a/core/modules/field/src/Tests/TranslationTest.php +++ b/core/modules/field/src/Tests/TranslationTest.php @@ -57,11 +57,11 @@ class TranslationTest extends FieldUnitTestBase { protected $instance_definition; /** - * The field to use in this test. + * The field storage to use in this test. * - * @var \Drupal\field\Entity\FieldConfig + * @var \Drupal\field\Entity\FieldStorageConfig */ - protected $field; + protected $fieldStorage; /** * The field instance to use in this test. @@ -86,11 +86,11 @@ function setUp() { 'cardinality' => 4, 'translatable' => TRUE, ); - $this->field = entity_create('field_config', $this->field_definition); - $this->field->save(); + $this->fieldStorage = entity_create('field_storage_config', $this->field_definition); + $this->fieldStorage->save(); $this->instance_definition = array( - 'field' => $this->field, + 'field_storage' => $this->fieldStorage, 'bundle' => 'entity_test', ); $this->instance = entity_create('field_instance_config', $this->instance_definition); @@ -122,7 +122,7 @@ function testTranslatableFieldSaveLoad() { $available_langcodes = array_keys($this->container->get('language_manager')->getLanguages()); $entity->langcode->value = reset($available_langcodes); foreach ($available_langcodes as $langcode) { - $field_translations[$langcode] = $this->_generateTestFieldValues($this->field->getCardinality()); + $field_translations[$langcode] = $this->_generateTestFieldValues($this->fieldStorage->getCardinality()); $entity->getTranslation($langcode)->{$this->field_name}->setValue($field_translations[$langcode]); } @@ -142,11 +142,11 @@ function testTranslatableFieldSaveLoad() { $field_name_default = drupal_strtolower($this->randomName() . '_field_name'); $field_definition = $this->field_definition; $field_definition['name'] = $field_name_default; - $field = entity_create('field_config', $field_definition); - $field->save(); + $field_storage = entity_create('field_storage_config', $field_definition); + $field_storage->save(); $instance_definition = $this->instance_definition; - $instance_definition['field'] = $field; + $instance_definition['field_storage'] = $field_storage; $instance_definition['default_value'] = array(array('value' => rand(1, 127))); $instance = entity_create('field_instance_config', $instance_definition); $instance->save(); @@ -158,7 +158,7 @@ function testTranslatableFieldSaveLoad() { $values = array('type' => $instance->bundle, 'langcode' => $translation_langcodes[0]); $entity = entity_create($entity_type_id, $values); foreach ($translation_langcodes as $langcode) { - $values[$this->field_name][$langcode] = $this->_generateTestFieldValues($this->field->getCardinality()); + $values[$this->field_name][$langcode] = $this->_generateTestFieldValues($this->fieldStorage->getCardinality()); $entity->getTranslation($langcode, FALSE)->{$this->field_name}->setValue($values[$this->field_name][$langcode]); } @@ -176,7 +176,7 @@ function testTranslatableFieldSaveLoad() { $values = array('type' => $instance->bundle, 'langcode' => $translation_langcodes[0]); $entity = entity_create($entity_type_id, $values); foreach ($translation_langcodes as $langcode) { - $values[$this->field_name][$langcode] = $this->_generateTestFieldValues($this->field->getCardinality()); + $values[$this->field_name][$langcode] = $this->_generateTestFieldValues($this->fieldStorage->getCardinality()); $entity->getTranslation($langcode)->{$this->field_name}->setValue($values[$this->field_name][$langcode]); $entity->getTranslation($langcode)->{$field_name_default}->setValue($empty_items); $values[$field_name_default][$langcode] = $empty_items; diff --git a/core/modules/field/src/Tests/TranslationWebTest.php b/core/modules/field/src/Tests/TranslationWebTest.php index 27f1e2917a36..752a8a46b5ec 100644 --- a/core/modules/field/src/Tests/TranslationWebTest.php +++ b/core/modules/field/src/Tests/TranslationWebTest.php @@ -38,11 +38,11 @@ class TranslationWebTest extends FieldTestBase { protected $entity_type = 'entity_test_mulrev'; /** - * The field to use in this test. + * The field storage to use in this test. * - * @var \Drupal\field\Entity\FieldConfig + * @var \Drupal\field\Entity\FieldStorageConfig */ - protected $field; + protected $fieldStorage; /** * The field instance to use in this test. @@ -63,11 +63,11 @@ function setUp() { 'cardinality' => 4, 'translatable' => TRUE, ); - entity_create('field_config', $field)->save(); - $this->field = entity_load('field_config', $this->entity_type . '.' . $this->field_name); + entity_create('field_storage_config', $field)->save(); + $this->fieldStorage = entity_load('field_storage_config', $this->entity_type . '.' . $this->field_name); $instance = array( - 'field' => $this->field, + 'field_storage' => $this->fieldStorage, 'bundle' => $this->entity_type, ); entity_create('field_instance_config', $instance)->save(); @@ -97,7 +97,7 @@ function testFieldFormTranslationRevisions() { field_test_entity_info_translatable($this->entity_type, TRUE); $entity = entity_create($this->entity_type); $available_langcodes = array_flip(array_keys($this->container->get('language_manager')->getLanguages())); - $field_name = $this->field->getName(); + $field_name = $this->fieldStorage->getName(); // Store the field translations. ksort($available_langcodes); @@ -126,7 +126,7 @@ function testFieldFormTranslationRevisions() { * by the passed arguments were correctly stored. */ private function checkTranslationRevisions($id, $revision_id, $available_langcodes) { - $field_name = $this->field->getName(); + $field_name = $this->fieldStorage->getName(); $entity = entity_revision_load($this->entity_type, $revision_id); foreach ($available_langcodes as $langcode => $value) { $passed = $entity->getTranslation($langcode)->{$field_name}->value == $value + 1; diff --git a/core/modules/field/src/Tests/Views/ApiDataTest.php b/core/modules/field/src/Tests/Views/ApiDataTest.php index b424480e421c..86763c2c8c25 100644 --- a/core/modules/field/src/Tests/Views/ApiDataTest.php +++ b/core/modules/field/src/Tests/Views/ApiDataTest.php @@ -15,11 +15,6 @@ */ class ApiDataTest extends FieldTestBase { - /** - * Stores the fields for this test case. - */ - var $fields; - function setUp() { parent::setUp(); @@ -55,9 +50,9 @@ function testViewsData() { // Check the table and the joins of the first field. // Attached to node only. - $field = $this->fields[0]; - $current_table = ContentEntityDatabaseStorage::_fieldTableName($field); - $revision_table = ContentEntityDatabaseStorage::_fieldRevisionTableName($field); + $field_storage = $this->fieldStorages[0]; + $current_table = ContentEntityDatabaseStorage::_fieldTableName($field_storage); + $revision_table = ContentEntityDatabaseStorage::_fieldRevisionTableName($field_storage); $data[$current_table] = $views_data->get($current_table); $data[$revision_table] = $views_data->get($revision_table); diff --git a/core/modules/field/src/Tests/Views/FieldTestBase.php b/core/modules/field/src/Tests/Views/FieldTestBase.php index e5af4abb00d6..43222e04bde9 100644 --- a/core/modules/field/src/Tests/Views/FieldTestBase.php +++ b/core/modules/field/src/Tests/Views/FieldTestBase.php @@ -39,7 +39,7 @@ abstract class FieldTestBase extends ViewTestBase { * * @var array */ - public $fields; + public $fieldStorages; /** * Stores the instances of the fields. They have @@ -66,25 +66,22 @@ function setUpFields($amount = 3) { $field_names = array(); for ($i = 0; $i < $amount; $i++) { $field_names[$i] = 'field_name_' . $i; - $field = array( + $this->fieldStorages[$i] = entity_create('field_storage_config', array( 'name' => $field_names[$i], 'entity_type' => 'node', 'type' => 'text', - ); - - $this->fields[$i] = $field = entity_create('field_config', $field); - $field->save(); + )); + $this->fieldStorages[$i]->save(); } return $field_names; } function setUpInstances($bundle = 'page') { - foreach ($this->fields as $key => $field) { - $instance = array( - 'field' => $field, - 'bundle' => 'page', - ); - $this->instances[$key] = entity_create('field_instance_config', $instance); + foreach ($this->fieldStorages as $key => $field_storage) { + $this->instances[$key] = entity_create('field_instance_config', array( + 'field_storage' => $field_storage, + 'bundle' => $bundle, + )); $this->instances[$key]->save(); } } diff --git a/core/modules/field/src/Tests/Views/HandlerFieldFieldTest.php b/core/modules/field/src/Tests/Views/HandlerFieldFieldTest.php index 5524a7065229..e3f53fa7d795 100644 --- a/core/modules/field/src/Tests/Views/HandlerFieldFieldTest.php +++ b/core/modules/field/src/Tests/Views/HandlerFieldFieldTest.php @@ -42,21 +42,21 @@ protected function setUp() { $this->setUpFields(3); // Setup a field with cardinality > 1. - $this->fields[3] = $field = entity_create('field_config', array( + $this->fieldStorages[3] = entity_create('field_storage_config', array( 'name' => 'field_name_3', 'entity_type' => 'node', 'type' => 'text', 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED, )); - $field->save(); + $this->fieldStorages[3]->save(); // Setup a field that will have no value. - $this->fields[4] = $field = entity_create('field_config', array( + $this->fieldStorages[4] = entity_create('field_storage_config', array( 'name' => 'field_name_4', 'entity_type' => 'node', 'type' => 'text', 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED, )); - $field->save(); + $this->fieldStorages[4]->save(); $this->setUpInstances(); @@ -66,14 +66,14 @@ protected function setUp() { $edit = array('type' => 'page'); for ($key = 0; $key < 3; $key++) { - $field = $this->fields[$key]; - $edit[$field->getName()][0]['value'] = $this->randomName(8); + $field_storage = $this->fieldStorages[$key]; + $edit[$field_storage->getName()][0]['value'] = $this->randomName(8); } for ($j = 0; $j < 5; $j++) { - $edit[$this->fields[3]->getName()][$j]['value'] = $this->randomName(8); + $edit[$this->fieldStorages[3]->getName()][$j]['value'] = $this->randomName(8); } // Set this field to be empty. - $edit[$this->fields[4]->getName()] = array(array('value' => NULL)); + $edit[$this->fieldStorages[4]->getName()] = array(array('value' => NULL)); $this->nodes[$i] = $this->drupalCreateNode($edit); } @@ -89,8 +89,8 @@ protected function setUp() { */ protected function prepareView(ViewExecutable $view) { $view->initDisplay(); - foreach ($this->fields as $field) { - $field_name = $field->getName(); + foreach ($this->fieldStorages as $field_storage) { + $field_name = $field_storage->getName(); $view->display_handler->options['fields'][$field_name]['id'] = $field_name; $view->display_handler->options['fields'][$field_name]['table'] = 'node__' . $field_name; $view->display_handler->options['fields'][$field_name]['field'] = $field_name; @@ -111,7 +111,7 @@ public function _testSimpleFieldRender() { // Tests that the rendered fields match the actual value of the fields. for ($i = 0; $i < 3; $i++) { for ($key = 0; $key < 2; $key++) { - $field_name = $this->fields[$key]->getName(); + $field_name = $this->fieldStorages[$key]->getName(); $rendered_field = $view->style_plugin->getField($i, $field_name); $expected_field = $this->nodes[$i]->$field_name->value; $this->assertEqual($rendered_field, $expected_field); @@ -125,8 +125,8 @@ public function _testSimpleFieldRender() { public function _testFormatterSimpleFieldRender() { $view = Views::getView('test_view_fieldapi'); $this->prepareView($view); - $view->displayHandlers->get('default')->options['fields'][$this->fields[0]->getName()]['type'] = 'text_trimmed'; - $view->displayHandlers->get('default')->options['fields'][$this->fields[0]->getName()]['settings'] = array( + $view->displayHandlers->get('default')->options['fields'][$this->fieldStorages[0]->getName()]['type'] = 'text_trimmed'; + $view->displayHandlers->get('default')->options['fields'][$this->fieldStorages[0]->getName()]['settings'] = array( 'trim_length' => 3, ); $this->executeView($view); @@ -134,14 +134,14 @@ public function _testFormatterSimpleFieldRender() { // Make sure that the formatter works as expected. // @TODO: actually there should be a specific formatter. for ($i = 0; $i < 2; $i++) { - $rendered_field = $view->style_plugin->getField($i, $this->fields[0]->getName()); + $rendered_field = $view->style_plugin->getField($i, $this->fieldStorages[0]->getName()); $this->assertEqual(strlen($rendered_field), 3); } } public function _testMultipleFieldRender() { $view = Views::getView('test_view_fieldapi'); - $field_name = $this->fields[3]->getName(); + $field_name = $this->fieldStorages[3]->getName(); // Test delta limit. $this->prepareView($view); @@ -161,7 +161,7 @@ public function _testMultipleFieldRender() { } // Test that an empty field is rendered without error. - $view->style_plugin->getField(4, $this->fields[4]->getName()); + $view->style_plugin->getField(4, $this->fieldStorages[4]->getName()); $view->destroy(); // Test delta limit + offset diff --git a/core/modules/field/src/Tests/reEnableModuleFieldTest.php b/core/modules/field/src/Tests/reEnableModuleFieldTest.php index 486c6b3d064d..954353591a07 100644 --- a/core/modules/field/src/Tests/reEnableModuleFieldTest.php +++ b/core/modules/field/src/Tests/reEnableModuleFieldTest.php @@ -43,14 +43,14 @@ function setUp() { function testReEnabledField() { // Add a telephone field to the article content type. - $field = entity_create('field_config', array( + $field_storage = entity_create('field_storage_config', array( 'name' => 'field_telephone', 'entity_type' => 'node', 'type' => 'telephone', )); - $field->save(); + $field_storage->save(); entity_create('field_instance_config', array( - 'field' => $field, + 'field_storage' => $field_storage, 'bundle' => 'article', 'label' => 'Telephone Number', ))->save(); @@ -90,7 +90,7 @@ function testReEnabledField() { $this->drupalLogin($admin_user); $this->drupalGet('admin/modules'); $this->assertText('Fields type(s) in use'); - $field->delete(); + $field_storage->delete(); $this->drupalGet('admin/modules'); $this->assertText('Fields pending deletion'); $this->cronRun(); diff --git a/core/modules/field/tests/modules/field_test/field_test.field.inc b/core/modules/field/tests/modules/field_test/field_test.field.inc index 93e090bd566c..6ebda87c18fe 100644 --- a/core/modules/field/tests/modules/field_test/field_test.field.inc +++ b/core/modules/field/tests/modules/field_test/field_test.field.inc @@ -6,11 +6,11 @@ */ use Drupal\Core\Entity\ContentEntityInterface; +use Drupal\Core\Entity\Exception\FieldStorageDefinitionUpdateForbiddenException; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Session\AccountInterface; -use Drupal\field\FieldConfigInterface; -use Drupal\Core\Entity\Exception\FieldStorageDefinitionUpdateForbiddenException; +use Drupal\field\FieldStorageConfigInterface; /** * Implements hook_field_widget_info_alter(). @@ -20,10 +20,10 @@ function field_test_field_widget_info_alter(&$info) { } /** - * Implements hook_field_config_update_forbid(). + * Implements hook_field_storage_config_update_forbid(). */ -function field_test_field_config_update_forbid(FieldConfigInterface $field, FieldConfigInterface $prior_field) { - if ($field->getType() == 'test_field' && $field->getSetting('unchangeable') != $prior_field->getSetting('unchangeable')) { +function field_test_field_storage_config_update_forbid(FieldStorageConfigInterface $field_storage, FieldStorageConfigInterface $prior_field_storage) { + if ($field_storage->getType() == 'test_field' && $field_storage->getSetting('unchangeable') != $prior_field_storage->getSetting('unchangeable')) { throw new FieldStorageDefinitionUpdateForbiddenException("field_test 'unchangeable' setting cannot be changed'"); } } diff --git a/core/modules/field/tests/modules/field_test/field_test.module b/core/modules/field/tests/modules/field_test/field_test.module index 6c9b7d4b2e6e..13c846dbbf89 100644 --- a/core/modules/field/tests/modules/field_test/field_test.module +++ b/core/modules/field/tests/modules/field_test/field_test.module @@ -1,7 +1,7 @@ <?php use Drupal\Core\Entity\EntityInterface; -use Drupal\field\FieldConfigInterface; +use Drupal\field\FieldStorageConfigInterface; /** * @file @@ -59,14 +59,14 @@ function field_test_permission() { * field_test_memorize(); * * // call some Field API functions that invoke field_test hooks - * entity_create('field_config', $field_definition)->save(); + * entity_create('field_storage_config', $field_definition)->save(); * * // retrieve and reset the memorized hook call data * $mem = field_test_memorize(); * - * // make sure hook_field_config_create() is invoked correctly - * assertEqual(count($mem['field_test_field_config_create']), 1); - * assertEqual($mem['field_test_field_config_create'][0], array($field)); + * // make sure hook_field_storage_config_create() is invoked correctly + * assertEqual(count($mem['field_test_field_storage_config_create']), 1); + * assertEqual($mem['field_test_field_storage_config_create'][0], array($field)); * @endcode * * @param $key @@ -91,9 +91,9 @@ function field_test_memorize($key = NULL, $value = NULL) { } /** - * Memorize calls to field_test_field_config_create() for field creation. + * Memorize calls to field_test_field_storage_config_create(). */ -function field_test_field_config_create(FieldConfigInterface $field) { +function field_test_field_storage_config_create(FieldStorageConfigInterface $field_storage) { $args = func_get_args(); field_test_memorize(__FUNCTION__, $args); } diff --git a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItem.php b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItem.php index e21b180de2ff..45302e39c359 100644 --- a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItem.php +++ b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItem.php @@ -29,9 +29,9 @@ class TestItem extends FieldItemBase { */ public static function defaultSettings() { return array( - 'test_field_setting' => 'dummy test string', - 'changeable' => 'a changeable field setting', - 'unchangeable' => 'an unchangeable field setting', + 'test_field_storage_setting' => 'dummy test string', + 'changeable' => 'a changeable field storage setting', + 'unchangeable' => 'an unchangeable field storage setting', ) + parent::defaultSettings(); } @@ -77,12 +77,12 @@ public static function schema(FieldStorageDefinitionInterface $field_definition) * {@inheritdoc} */ public function settingsForm(array &$form, array &$form_state, $has_data) { - $form['test_field_setting'] = array( + $form['test_field_storage_setting'] = array( '#type' => 'textfield', - '#title' => t('Field test field setting'), - '#default_value' => $this->getSetting('test_field_setting'), + '#title' => t('Field test field storage setting'), + '#default_value' => $this->getSetting('test_field_storage_setting'), '#required' => FALSE, - '#description' => t('A dummy form element to simulate field setting.'), + '#description' => t('A dummy form element to simulate field storage setting.'), ); return $form; diff --git a/core/modules/field/tests/modules/field_test_config/config/install/field.instance.entity_test.entity_test.field_test_import.yml b/core/modules/field/tests/modules/field_test_config/config/install/field.instance.entity_test.entity_test.field_test_import.yml index c1537bf2ac32..b5df1dc1f190 100644 --- a/core/modules/field/tests/modules/field_test_config/config/install/field.instance.entity_test.entity_test.field_test_import.yml +++ b/core/modules/field/tests/modules/field_test_config/config/install/field.instance.entity_test.entity_test.field_test_import.yml @@ -11,3 +11,6 @@ default_value_function: '' settings: text_processing: 0 field_type: text +dependencies: + entity: + - field.storage.entity_test.field_test_import diff --git a/core/modules/field/tests/modules/field_test_config/config/install/field.instance.entity_test.entity_test.field_test_import_2.yml b/core/modules/field/tests/modules/field_test_config/config/install/field.instance.entity_test.entity_test.field_test_import_2.yml index 35d694ab52a3..2d482a52e321 100644 --- a/core/modules/field/tests/modules/field_test_config/config/install/field.instance.entity_test.entity_test.field_test_import_2.yml +++ b/core/modules/field/tests/modules/field_test_config/config/install/field.instance.entity_test.entity_test.field_test_import_2.yml @@ -11,3 +11,6 @@ default_value_function: '' settings: text_processing: 0 field_type: text +dependencies: + entity: + - field.storage.entity_test.field_test_import_2 diff --git a/core/modules/field/tests/modules/field_test_config/config/install/field.instance.entity_test.test_bundle.field_test_import_2.yml b/core/modules/field/tests/modules/field_test_config/config/install/field.instance.entity_test.test_bundle.field_test_import_2.yml index 440536e2c554..50f76c152075 100644 --- a/core/modules/field/tests/modules/field_test_config/config/install/field.instance.entity_test.test_bundle.field_test_import_2.yml +++ b/core/modules/field/tests/modules/field_test_config/config/install/field.instance.entity_test.test_bundle.field_test_import_2.yml @@ -11,3 +11,6 @@ default_value_function: '' settings: text_processing: 0 field_type: text +dependencies: + entity: + - field.storage.entity_test.field_test_import_2 diff --git a/core/modules/field/tests/modules/field_test_config/config/install/field.field.entity_test.field_test_import.yml b/core/modules/field/tests/modules/field_test_config/config/install/field.storage.entity_test.field_test_import.yml similarity index 100% rename from core/modules/field/tests/modules/field_test_config/config/install/field.field.entity_test.field_test_import.yml rename to core/modules/field/tests/modules/field_test_config/config/install/field.storage.entity_test.field_test_import.yml diff --git a/core/modules/field/tests/modules/field_test_config/config/install/field.field.entity_test.field_test_import_2.yml b/core/modules/field/tests/modules/field_test_config/config/install/field.storage.entity_test.field_test_import_2.yml similarity index 100% rename from core/modules/field/tests/modules/field_test_config/config/install/field.field.entity_test.field_test_import_2.yml rename to core/modules/field/tests/modules/field_test_config/config/install/field.storage.entity_test.field_test_import_2.yml diff --git a/core/modules/field/tests/modules/field_test_config/staging/field.instance.entity_test.entity_test.field_test_import_staging.yml b/core/modules/field/tests/modules/field_test_config/staging/field.instance.entity_test.entity_test.field_test_import_staging.yml index faf3e18525c8..c69e8bab8c5b 100644 --- a/core/modules/field/tests/modules/field_test_config/staging/field.instance.entity_test.entity_test.field_test_import_staging.yml +++ b/core/modules/field/tests/modules/field_test_config/staging/field.instance.entity_test.entity_test.field_test_import_staging.yml @@ -12,3 +12,6 @@ default_value_function: '' settings: text_processing: '0' field_type: text +dependencies: + entity: + - field.storage.entity_test.field_test_import_staging diff --git a/core/modules/field/tests/modules/field_test_config/staging/field.instance.entity_test.test_bundle.field_test_import_staging_2.yml b/core/modules/field/tests/modules/field_test_config/staging/field.instance.entity_test.test_bundle.field_test_import_staging_2.yml index dbe30a7c67a4..2bf3bb7fbb4e 100644 --- a/core/modules/field/tests/modules/field_test_config/staging/field.instance.entity_test.test_bundle.field_test_import_staging_2.yml +++ b/core/modules/field/tests/modules/field_test_config/staging/field.instance.entity_test.test_bundle.field_test_import_staging_2.yml @@ -12,3 +12,6 @@ default_value_function: '' settings: text_processing: '0' field_type: text +dependencies: + entity: + - field.storage.entity_test.field_test_import_staging_2 diff --git a/core/modules/field/tests/modules/field_test_config/staging/field.instance.entity_test.test_bundle_2.field_test_import_staging_2.yml b/core/modules/field/tests/modules/field_test_config/staging/field.instance.entity_test.test_bundle_2.field_test_import_staging_2.yml index ccc0c13fa9d2..9e04777c1310 100644 --- a/core/modules/field/tests/modules/field_test_config/staging/field.instance.entity_test.test_bundle_2.field_test_import_staging_2.yml +++ b/core/modules/field/tests/modules/field_test_config/staging/field.instance.entity_test.test_bundle_2.field_test_import_staging_2.yml @@ -12,3 +12,6 @@ default_value_function: '' settings: text_processing: '0' field_type: text +dependencies: + entity: + - field.storage.entity_test.field_test_import_staging_2 diff --git a/core/modules/field/tests/modules/field_test_config/staging/field.field.entity_test.field_test_import_staging.yml b/core/modules/field/tests/modules/field_test_config/staging/field.storage.entity_test.field_test_import_staging.yml similarity index 100% rename from core/modules/field/tests/modules/field_test_config/staging/field.field.entity_test.field_test_import_staging.yml rename to core/modules/field/tests/modules/field_test_config/staging/field.storage.entity_test.field_test_import_staging.yml diff --git a/core/modules/field/tests/modules/field_test_config/staging/field.field.entity_test.field_test_import_staging_2.yml b/core/modules/field/tests/modules/field_test_config/staging/field.storage.entity_test.field_test_import_staging_2.yml similarity index 100% rename from core/modules/field/tests/modules/field_test_config/staging/field.field.entity_test.field_test_import_staging_2.yml rename to core/modules/field/tests/modules/field_test_config/staging/field.storage.entity_test.field_test_import_staging_2.yml diff --git a/core/modules/field/tests/src/FieldInstanceConfigEntityUnitTest.php b/core/modules/field/tests/src/FieldInstanceConfigEntityUnitTest.php index 7cd3a068f696..2d3b67fda2db 100644 --- a/core/modules/field/tests/src/FieldInstanceConfigEntityUnitTest.php +++ b/core/modules/field/tests/src/FieldInstanceConfigEntityUnitTest.php @@ -46,6 +46,13 @@ class FieldInstanceConfigEntityUnitTest extends UnitTestCase { */ protected $uuid; + /** + * The mock field storage. + * + * @var \Drupal\field\FieldStorageConfigInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $fieldStorage; + /** * {@inheritdoc} */ @@ -65,12 +72,12 @@ public function setUp() { $container->set('config.typed', $this->typedConfigManager); \Drupal::setContainer($container); - // Create a mock FieldConfig object. - $this->field = $this->getMock('\Drupal\field\FieldConfigInterface'); - $this->field->expects($this->any()) + // Create a mock FieldStorageConfig object. + $this->fieldStorage = $this->getMock('\Drupal\field\FieldStorageConfigInterface'); + $this->fieldStorage->expects($this->any()) ->method('getType') ->will($this->returnValue('test_field')); - $this->field->expects($this->any()) + $this->fieldStorage->expects($this->any()) ->method('getName') ->will($this->returnValue('field_test')); @@ -79,7 +86,7 @@ public function setUp() { ->method('getFieldStorageDefinitions') ->with('test_entity_type') ->will($this->returnValue(array( - $this->field->getName() => $this->field, + $this->fieldStorage->getName() => $this->fieldStorage, ))); } @@ -114,14 +121,14 @@ public function testCalculateDependencies() { ->with('test_entity_type') ->will($this->returnValue($target_entity_type)); - $this->field->expects($this->once()) + $this->fieldStorage->expects($this->once()) ->method('getConfigDependencyName') - ->will($this->returnValue('field.field.test_entity_type.test_field')); + ->will($this->returnValue('field.storage.test_entity_type.test_field')); - $values = array('field_name' => $this->field->getName(), 'entity_type' => 'test_entity_type', 'bundle' => 'test_bundle'); + $values = array('field_name' => $this->fieldStorage->getName(), 'entity_type' => 'test_entity_type', 'bundle' => 'test_bundle'); $entity = new FieldInstanceConfig($values, $this->entityTypeId); $dependencies = $entity->calculateDependencies(); - $this->assertContains('field.field.test_entity_type.test_field', $dependencies['entity']); + $this->assertContains('field.storage.test_entity_type.test_field', $dependencies['entity']); $this->assertContains('test.test_entity_type.id', $dependencies['entity']); } @@ -129,7 +136,7 @@ public function testCalculateDependencies() { * @covers ::toArray() */ public function testToArray() { - $values = array('field_name' => $this->field->getName(), 'entity_type' => 'test_entity_type', 'bundle' => 'test_bundle'); + $values = array('field_name' => $this->fieldStorage->getName(), 'entity_type' => 'test_entity_type', 'bundle' => 'test_bundle'); $instance = new FieldInstanceConfig($values, $this->entityTypeId); $expected = array( diff --git a/core/modules/field/tests/src/FieldConfigEntityUnitTest.php b/core/modules/field/tests/src/FieldStorageConfigEntityUnitTest.php similarity index 73% rename from core/modules/field/tests/src/FieldConfigEntityUnitTest.php rename to core/modules/field/tests/src/FieldStorageConfigEntityUnitTest.php index d9a66e5ffd63..b33951238ca8 100644 --- a/core/modules/field/tests/src/FieldConfigEntityUnitTest.php +++ b/core/modules/field/tests/src/FieldStorageConfigEntityUnitTest.php @@ -2,20 +2,21 @@ /** * @file - * Contains \Drupal\field\Tests\FieldConfigEntityUnitTest. + * Contains \Drupal\field\Tests\FieldStorageConfigEntityUnitTest. */ namespace Drupal\field\Tests; use Drupal\Core\DependencyInjection\ContainerBuilder; -use Drupal\field\Entity\FieldConfig; +use Drupal\field\Entity\FieldStorageConfig; use Drupal\Tests\UnitTestCase; /** - * @coversDefaultClass \Drupal\field\Entity\FieldConfig + * @coversDefaultClass \Drupal\field\Entity\FieldStorageConfig + * * @group field */ -class FieldConfigEntityUnitTest extends UnitTestCase { +class FieldStorageConfigEntityUnitTest extends UnitTestCase { /** * The entity type used for testing. @@ -62,9 +63,9 @@ public function setUp() { * @covers ::calculateDependencies */ public function testCalculateDependencies() { - // Create a mock entity type for fieldConfig. - $fieldConfigentityType = $this->getMock('\Drupal\Core\Entity\EntityTypeInterface'); - $fieldConfigentityType->expects($this->any()) + // Create a mock entity type for FieldStorageConfig. + $fieldStorageConfigentityType = $this->getMock('\Drupal\Core\Entity\EntityTypeInterface'); + $fieldStorageConfigentityType->expects($this->any()) ->method('getProvider') ->will($this->returnValue('field')); @@ -77,25 +78,25 @@ public function testCalculateDependencies() { // Get definition is called three times. Twice in // ConfigEntityBase::addDependency() to get the provider of the field config - // entity type and once in FieldConfig::calculateDependencies() to get the - // provider of the entity type that field is attached to. + // entity type and once in FieldStorageConfig::calculateDependencies() to + // get the provider of the entity type that field is attached to. $this->entityManager->expects($this->at(0)) ->method('getDefinition') - ->with('fieldConfig') - ->will($this->returnValue($fieldConfigentityType)); + ->with('field_storage_config') + ->will($this->returnValue($fieldStorageConfigentityType)); $this->entityManager->expects($this->at(1)) ->method('getDefinition') ->with($attached_entity_type_id) ->will($this->returnValue($attached_entity_type)); $this->entityManager->expects($this->at(2)) ->method('getDefinition') - ->with('fieldConfig') - ->will($this->returnValue($fieldConfigentityType)); + ->with('field_storage_config') + ->will($this->returnValue($fieldStorageConfigentityType)); $values = array('name' => 'test_field', 'type' => 'test_field_type', 'entity_type' => $attached_entity_type_id, 'module' => 'test_module'); - $field = new FieldConfig($values, 'fieldConfig'); + $field_storage = new FieldStorageConfig($values); - $dependencies = $field->calculateDependencies(); + $dependencies = $field_storage->calculateDependencies(); $this->assertContains('test_module', $dependencies['module']); $this->assertContains('entity_provider_module', $dependencies['module']); } diff --git a/core/modules/field_ui/field_ui.module b/core/modules/field_ui/field_ui.module index 4fe550ccd3a5..4d475b4051b7 100644 --- a/core/modules/field_ui/field_ui.module +++ b/core/modules/field_ui/field_ui.module @@ -110,7 +110,7 @@ function field_ui_entity_type_build(array &$entity_types) { /** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */ $entity_types['field_instance_config']->setFormClass('delete', 'Drupal\field_ui\Form\FieldInstanceConfigDeleteForm'); $entity_types['field_instance_config']->setListBuilderClass('Drupal\field_ui\FieldInstanceConfigListBuilder'); - $entity_types['field_config']->setListBuilderClass('Drupal\field_ui\FieldConfigListBuilder'); + $entity_types['field_storage_config']->setListBuilderClass('Drupal\field_ui\FieldStorageConfigListBuilder'); foreach ($entity_types as $entity_type) { if ($bundle = $entity_type->getBundleOf()) { diff --git a/core/modules/field_ui/field_ui.routing.yml b/core/modules/field_ui/field_ui.routing.yml index 826150b9113b..2b3672f79aa6 100644 --- a/core/modules/field_ui/field_ui.routing.yml +++ b/core/modules/field_ui/field_ui.routing.yml @@ -1,7 +1,7 @@ field_ui.list: path: '/admin/reports/fields' defaults: - _entity_list: 'field_config' + _entity_list: 'field_storage_config' _title: 'Field list' requirements: _permission: 'administer content types' diff --git a/core/modules/field_ui/src/FieldInstanceConfigListBuilder.php b/core/modules/field_ui/src/FieldInstanceConfigListBuilder.php index b801f4c066ea..74252e007f2d 100644 --- a/core/modules/field_ui/src/FieldInstanceConfigListBuilder.php +++ b/core/modules/field_ui/src/FieldInstanceConfigListBuilder.php @@ -62,11 +62,11 @@ public function getDefaultOperations(EntityInterface $entity) { /** @var \Drupal\field\FieldInstanceConfigInterface $entity */ $operations = parent::getDefaultOperations($entity); - $operations['field-settings'] = array( + $operations['storage-settings'] = array( 'title' => $this->t('Field settings'), 'weight' => 20, 'attributes' => array('title' => $this->t('Edit field settings.')), - ) + $entity->urlInfo('field-settings-form')->toArray(); + ) + $entity->urlInfo('storage-edit-form')->toArray(); $operations['edit']['attributes']['title'] = $this->t('Edit instance settings.'); $operations['delete']['attributes']['title'] = $this->t('Delete instance.'); diff --git a/core/modules/field_ui/src/FieldOverview.php b/core/modules/field_ui/src/FieldOverview.php index 300b31710ae3..c962dc9ca9f4 100644 --- a/core/modules/field_ui/src/FieldOverview.php +++ b/core/modules/field_ui/src/FieldOverview.php @@ -15,7 +15,7 @@ use Drupal\Core\Render\Element; use Drupal\field_ui\OverviewBase; use Symfony\Component\DependencyInjection\ContainerInterface; -use Drupal\field\Entity\FieldConfig; +use Drupal\field\Entity\FieldStorageConfig; use Drupal\field\FieldInstanceConfigInterface; /** @@ -116,7 +116,7 @@ public function buildForm(array $form, array &$form_state, $entity_type_id = NUL // Fields. foreach ($instances as $name => $instance) { - $field = $instance->getFieldStorageDefinition(); + $field_storage = $instance->getFieldStorageDefinition(); $route_parameters = array( $this->bundleEntityType => $this->bundle, 'field_instance_config' => $instance->id(), @@ -133,8 +133,8 @@ public function buildForm(array $form, array &$form_state, $entity_type_id = NUL ), 'type' => array( '#type' => 'link', - '#title' => $field_types[$field->getType()]['label'], - '#route_name' => 'field_ui.field_edit_' . $this->entity_type, + '#title' => $field_types[$field_storage->getType()]['label'], + '#route_name' => 'field_ui.storage_edit_' . $this->entity_type, '#route_parameters' => $route_parameters, '#options' => array('attributes' => array('title' => $this->t('Edit field settings.'))), ), @@ -145,7 +145,7 @@ public function buildForm(array $form, array &$form_state, $entity_type_id = NUL '#links' => $this->entityManager->getListBuilder('field_instance_config')->getOperations($instance), ); - if (!empty($field->locked)) { + if (!empty($field_storage->locked)) { $table[$name]['operations'] = array('#markup' => $this->t('Locked')); $table[$name]['#attributes']['class'][] = 'menu-disabled'; } @@ -186,7 +186,7 @@ public function buildForm(array $form, array &$form_state, $entity_type_id = NUL '#description' => $this->t('A unique machine-readable name containing letters, numbers, and underscores.'), // Calculate characters depending on the length of the field prefix // setting. Maximum length is 32. - '#maxlength' => FieldConfig::NAME_MAX_LENGTH - strlen($field_prefix), + '#maxlength' => FieldStorageConfig::NAME_MAX_LENGTH - strlen($field_prefix), '#prefix' => '<div class="add-new-placeholder"> </div>', '#machine_name' => array( 'source' => array('fields', $name, 'label'), @@ -370,7 +370,7 @@ public function submitForm(array &$form, array &$form_state) { if (!empty($form_values['_add_new_field']['field_name'])) { $values = $form_values['_add_new_field']; - $field = array( + $field_storage = array( 'name' => $values['field_name'], 'entity_type' => $this->entity_type, 'type' => $values['type'], @@ -387,7 +387,7 @@ public function submitForm(array &$form, array &$form_state) { // Create the field and instance. try { - $this->entityManager->getStorage('field_config')->create($field)->save(); + $this->entityManager->getStorage('field_storage_config')->create($field_storage)->save(); $new_instance = $this->entityManager->getStorage('field_instance_config')->create($instance); $new_instance->save(); @@ -411,7 +411,7 @@ public function submitForm(array &$form, array &$form_state) { $this->bundleEntityType => $this->bundle, 'field_instance_config' => $new_instance->id(), ); - $destinations[] = array('route_name' => 'field_ui.field_edit_' . $this->entity_type, 'route_parameters' => $route_parameters); + $destinations[] = array('route_name' => 'field_ui.storage_edit_' . $this->entity_type, 'route_parameters' => $route_parameters); $destinations[] = array('route_name' => 'field_ui.instance_edit_' . $this->entity_type, 'route_parameters' => $route_parameters); // Store new field information for any additional submit handlers. @@ -427,8 +427,8 @@ public function submitForm(array &$form, array &$form_state) { if (!empty($form_values['_add_existing_field']['field_name'])) { $values = $form_values['_add_existing_field']; $field_name = $values['field_name']; - $field = FieldConfig::loadByName($this->entity_type, $field_name); - if (!empty($field->locked)) { + $field_storage = FieldStorageConfig::loadByName($this->entity_type, $field_name); + if (!empty($field_storage->locked)) { drupal_set_message($this->t('The field %label cannot be added because it is locked.', array('%label' => $values['label'])), 'error'); } else { @@ -515,8 +515,8 @@ protected function getExistingFieldOptions() { // - locked fields, // - fields that should not be added via user interface. $field_type = $instance->getType(); - $field = $instance->getFieldStorageDefinition(); - if (empty($field->locked) && empty($field_types[$field_type]['no_ui'])) { + $field_storage = $instance->getFieldStorageDefinition(); + if (empty($field_storage->locked) && empty($field_types[$field_type]['no_ui'])) { $options[$instance->getName()] = array( 'type' => $field_type, 'type_label' => $field_types[$field_type]['label'], diff --git a/core/modules/field_ui/src/FieldConfigListBuilder.php b/core/modules/field_ui/src/FieldStorageConfigListBuilder.php similarity index 94% rename from core/modules/field_ui/src/FieldConfigListBuilder.php rename to core/modules/field_ui/src/FieldStorageConfigListBuilder.php index 4a0022928b2a..1eef291afb42 100644 --- a/core/modules/field_ui/src/FieldConfigListBuilder.php +++ b/core/modules/field_ui/src/FieldStorageConfigListBuilder.php @@ -2,7 +2,7 @@ /** * @file - * Contains \Drupal\field_ui\FieldConfigListBuilder. + * Contains \Drupal\field_ui\FieldStorageConfigListBuilder. */ namespace Drupal\field_ui; @@ -21,7 +21,7 @@ * @see \Drupal\field\Entity\Field * @see field_ui_entity_info() */ -class FieldConfigListBuilder extends ConfigEntityListBuilder { +class FieldStorageConfigListBuilder extends ConfigEntityListBuilder { /** * An array of information about field types. @@ -52,7 +52,7 @@ class FieldConfigListBuilder extends ConfigEntityListBuilder { protected $fieldTypeManager; /** - * Constructs a new FieldConfigListBuilder object. + * Constructs a new FieldStorageConfigListBuilder object. * * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type * The entity type definition. diff --git a/core/modules/field_ui/src/Form/FieldInstanceConfigDeleteForm.php b/core/modules/field_ui/src/Form/FieldInstanceConfigDeleteForm.php index 3dd54c02de1a..3eb8f7424fb0 100644 --- a/core/modules/field_ui/src/Form/FieldInstanceConfigDeleteForm.php +++ b/core/modules/field_ui/src/Form/FieldInstanceConfigDeleteForm.php @@ -68,11 +68,11 @@ public function getCancelRoute() { * {@inheritdoc} */ public function submit(array $form, array &$form_state) { - $field = $this->entity->getFieldStorageDefinition(); + $field_storage = $this->entity->getFieldStorageDefinition(); $bundles = entity_get_bundles(); $bundle_label = $bundles[$this->entity->entity_type][$this->entity->bundle]['label']; - if ($field && !$field->locked) { + if ($field_storage && !$field_storage->locked) { $this->entity->delete(); drupal_set_message($this->t('The field %field has been deleted from the %type content type.', array('%field' => $this->entity->label(), '%type' => $bundle_label))); } diff --git a/core/modules/field_ui/src/Form/FieldInstanceEditForm.php b/core/modules/field_ui/src/Form/FieldInstanceEditForm.php index 7ac1affb4b9c..12f881dffc0a 100644 --- a/core/modules/field_ui/src/Form/FieldInstanceEditForm.php +++ b/core/modules/field_ui/src/Form/FieldInstanceEditForm.php @@ -67,7 +67,7 @@ public function buildForm(array $form, array &$form_state, FieldInstanceConfigIn $bundle = $this->instance->bundle; $entity_type = $this->instance->entity_type; - $field = $this->instance->getFieldStorageDefinition(); + $field_storage = $this->instance->getFieldStorageDefinition(); $bundles = entity_get_bundles(); $form_title = $this->t('%instance settings for %bundle', array( @@ -76,13 +76,13 @@ public function buildForm(array $form, array &$form_state, FieldInstanceConfigIn )); $form['#title'] = $form_title; - $form['#field'] = $field; + $form['#field'] = $field_storage; // Create an arbitrary entity object (used by the 'default value' widget). $ids = (object) array('entity_type' => $this->instance->entity_type, 'bundle' => $this->instance->bundle, 'entity_id' => NULL); $form['#entity'] = _field_create_entity_from_ids($ids); $items = $form['#entity']->get($this->instance->getName()); - if (!empty($field->locked)) { + if (!empty($field_storage->locked)) { $form['locked'] = array( '#markup' => $this->t('The field %field is locked and cannot be edited.', array('%field' => $this->instance->getLabel())), ); @@ -112,7 +112,7 @@ public function buildForm(array $form, array &$form_state, FieldInstanceConfigIn $form['instance']['label'] = array( '#type' => 'textfield', '#title' => $this->t('Label'), - '#default_value' => $this->instance->getLabel() ?: $field->getName(), + '#default_value' => $this->instance->getLabel() ?: $field_storage->getName(), '#required' => TRUE, '#weight' => -20, ); diff --git a/core/modules/field_ui/src/Form/FieldEditForm.php b/core/modules/field_ui/src/Form/FieldStorageEditForm.php similarity index 88% rename from core/modules/field_ui/src/Form/FieldEditForm.php rename to core/modules/field_ui/src/Form/FieldStorageEditForm.php index 9d79cf45609b..7fb581942772 100644 --- a/core/modules/field_ui/src/Form/FieldEditForm.php +++ b/core/modules/field_ui/src/Form/FieldStorageEditForm.php @@ -2,7 +2,7 @@ /** * @file - * Contains \Drupal\field_ui\Form\FieldEditForm. + * Contains \Drupal\field_ui\Form\FieldStorageEditForm. */ namespace Drupal\field_ui\Form; @@ -16,9 +16,9 @@ use Symfony\Component\DependencyInjection\ContainerInterface; /** - * Provides a form for the field settings edit page. + * Provides a form for the "field storage" edit page. */ -class FieldEditForm extends FormBase { +class FieldStorageEditForm extends FormBase { /** * The field instance being edited. @@ -45,11 +45,11 @@ class FieldEditForm extends FormBase { * {@inheritdoc} */ public function getFormId() { - return 'field_ui_field_edit_form'; + return 'field_ui_field_storage_edit_form'; } /** - * Constructs a new FieldEditForm object. + * Constructs a new FieldStorageEditForm object. * * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager. @@ -78,8 +78,8 @@ public function buildForm(array $form, array &$form_state, FieldInstanceConfigIn $this->instance = $form_state['instance'] = $field_instance_config; $form['#title'] = $this->instance->label(); - $field = $this->instance->getFieldStorageDefinition(); - $form['#field'] = $field; + $field_storage = $this->instance->getFieldStorageDefinition(); + $form['#field'] = $field_storage; $form['#bundle'] = $this->instance->bundle; $description = '<p>' . $this->t('These settings apply to the %field field everywhere it is used. These settings impact the way that data is stored in the database and cannot be changed once data has been created.', array('%field' => $this->instance->label())) . '</p>'; @@ -92,12 +92,12 @@ public function buildForm(array $form, array &$form_state, FieldInstanceConfigIn // See if data already exists for this field. // If so, prevent changes to the field settings. - if ($field->hasData()) { + if ($field_storage->hasData()) { $form['field']['#prefix'] = '<div class="messages messages--error">' . $this->t('There is data for this field in the database. The field settings can no longer be changed.') . '</div>' . $form['field']['#prefix']; } // Build the configurable field values. - $cardinality = $field->getCardinality(); + $cardinality = $field_storage->getCardinality(); $form['field']['cardinality_container'] = array( // Reset #parents to 'field', so the additional container does not appear. '#parents' => array('field'), @@ -134,10 +134,10 @@ public function buildForm(array $form, array &$form_state, FieldInstanceConfigIn ); // Build the non-configurable field values. - $form['field']['field_name'] = array('#type' => 'value', '#value' => $field->getName()); - $form['field']['type'] = array('#type' => 'value', '#value' => $field->getType()); - $form['field']['module'] = array('#type' => 'value', '#value' => $field->module); - $form['field']['translatable'] = array('#type' => 'value', '#value' => $field->isTranslatable()); + $form['field']['field_name'] = array('#type' => 'value', '#value' => $field_storage->getName()); + $form['field']['type'] = array('#type' => 'value', '#value' => $field_storage->getType()); + $form['field']['module'] = array('#type' => 'value', '#value' => $field_storage->module); + $form['field']['translatable'] = array('#type' => 'value', '#value' => $field_storage->isTranslatable()); // Add settings provided by the field module. The field module is // responsible for not returning settings that cannot be changed if @@ -149,7 +149,7 @@ public function buildForm(array $form, array &$form_state, FieldInstanceConfigIn // FieldItem. $ids = (object) array('entity_type' => $this->instance->entity_type, 'bundle' => $this->instance->bundle, 'entity_id' => NULL); $entity = _field_create_entity_from_ids($ids); - $form['field']['settings'] += $entity->get($field->getName())->first()->settingsForm($form, $form_state, $field->hasData()); + $form['field']['settings'] += $entity->get($field_storage->getName())->first()->settingsForm($form, $form_state, $field_storage->hasData()); $form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Save field settings')); @@ -185,14 +185,14 @@ public function submitForm(array &$form, array &$form_state) { unset($field_values['container']); // Merge incoming form values into the existing field. - $field = $this->instance->getFieldStorageDefinition(); + $field_storage = $this->instance->getFieldStorageDefinition(); foreach ($field_values as $key => $value) { - $field->{$key} = $value; + $field_storage->{$key} = $value; } // Update the field. try { - $field->save(); + $field_storage->save(); drupal_set_message($this->t('Updated field %label field settings.', array('%label' => $this->instance->label()))); $request = $this->getRequest(); if (($destinations = $request->query->get('destinations')) && $next_destination = FieldUI::getNextDestination($destinations)) { diff --git a/core/modules/field_ui/src/Plugin/Derivative/FieldUiLocalTask.php b/core/modules/field_ui/src/Plugin/Derivative/FieldUiLocalTask.php index 1238afd72d7a..35d021802dff 100644 --- a/core/modules/field_ui/src/Plugin/Derivative/FieldUiLocalTask.php +++ b/core/modules/field_ui/src/Plugin/Derivative/FieldUiLocalTask.php @@ -102,7 +102,7 @@ public function getDerivativeDefinitions($base_plugin_definition) { // Field settings tab. $this->derivatives["field_edit_$entity_type_id"] = array( - 'route_name' => "field_ui.field_edit_$entity_type_id", + 'route_name' => "field_ui.storage_edit_$entity_type_id", 'title' => $this->t('Field settings'), 'base_route' => "field_ui.instance_edit_$entity_type_id", ); diff --git a/core/modules/field_ui/src/Routing/RouteSubscriber.php b/core/modules/field_ui/src/Routing/RouteSubscriber.php index 57f7efdf4205..982043805a62 100644 --- a/core/modules/field_ui/src/Routing/RouteSubscriber.php +++ b/core/modules/field_ui/src/Routing/RouteSubscriber.php @@ -67,12 +67,12 @@ protected function alterRoutes(RouteCollection $collection) { $collection->add("field_ui.instance_edit_$entity_type_id", $route); $route = new Route( - "$path/fields/{field_instance_config}/field", - array('_form' => '\Drupal\field_ui\Form\FieldEditForm'), + "$path/fields/{field_instance_config}/storage", + array('_form' => '\Drupal\field_ui\Form\FieldStorageEditForm'), array('_entity_access' => 'field_instance_config.update'), $options ); - $collection->add("field_ui.field_edit_$entity_type_id", $route); + $collection->add("field_ui.storage_edit_$entity_type_id", $route); $route = new Route( "$path/fields/{field_instance_config}/delete", diff --git a/core/modules/field_ui/src/Tests/FieldUiTestBase.php b/core/modules/field_ui/src/Tests/FieldUiTestBase.php index 3e54cea688f2..1196bb804392 100644 --- a/core/modules/field_ui/src/Tests/FieldUiTestBase.php +++ b/core/modules/field_ui/src/Tests/FieldUiTestBase.php @@ -72,9 +72,9 @@ function fieldUIAddNewField($bundle_path, $initial_edit, $field_edit = array(), // First step : 'Add new field' on the 'Manage fields' page. $this->drupalPostForm("$bundle_path/fields", $initial_edit, t('Save')); - $this->assertRaw(t('These settings apply to the %label field everywhere it is used.', array('%label' => $label)), 'Field settings page was displayed.'); + $this->assertRaw(t('These settings apply to the %label field everywhere it is used.', array('%label' => $label)), 'Storage settings page was displayed.'); // Test Breadcrumbs. - $this->assertLink($label, 0, 'Field label is correct in the breadcrumb of the field settings page.'); + $this->assertLink($label, 0, 'Field label is correct in the breadcrumb of the storage settings page.'); // Second step : 'Field settings' form. $this->drupalPostForm(NULL, $field_edit, t('Save field settings')); diff --git a/core/modules/field_ui/src/Tests/ManageFieldsTest.php b/core/modules/field_ui/src/Tests/ManageFieldsTest.php index a1627a175e62..f3c1a1121f92 100644 --- a/core/modules/field_ui/src/Tests/ManageFieldsTest.php +++ b/core/modules/field_ui/src/Tests/ManageFieldsTest.php @@ -10,8 +10,8 @@ use Drupal\Component\Utility\String; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Language\LanguageInterface; -use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldInstanceConfig; +use Drupal\field\Entity\FieldStorageConfig; /** * Tests the Field UI "Manage fields" screen. @@ -40,20 +40,18 @@ function setUp() { )); $vocabulary->save(); - $field = array( + entity_create('field_storage_config', array( 'name' => 'field_' . $vocabulary->id(), 'entity_type' => 'node', 'type' => 'taxonomy_term_reference', - ); - entity_create('field_config', $field)->save(); + ))->save(); - $instance = array( + entity_create('field_instance_config', array( 'field_name' => 'field_' . $vocabulary->id(), 'entity_type' => 'node', 'label' => 'Tags', 'bundle' => 'article', - ); - entity_create('field_instance_config', $instance)->save(); + ))->save(); entity_get_form_display('node', 'article', 'default') ->setComponent('field_' . $vocabulary->id()) @@ -107,7 +105,7 @@ function manageFieldsPage($type = '') { $result = $this->xpath('//ul[@class = "dropbutton"]/li/a'); $url = base_path() . "admin/structure/types/manage/$type/fields/node.$type.body"; $this->assertIdentical($url, (string) $result[0]['href']); - $this->assertIdentical("$url/field", (string) $result[1]['href']); + $this->assertIdentical("$url/storage", (string) $result[1]['href']); $this->assertIdentical("$url/delete", (string) $result[3]['href']); } @@ -132,12 +130,12 @@ function createField() { function updateField() { $instance_id = 'node.' . $this->type . '.' . $this->field_name; // Go to the field edit page. - $this->drupalGet('admin/structure/types/manage/' . $this->type . '/fields/' . $instance_id . '/field'); + $this->drupalGet('admin/structure/types/manage/' . $this->type . '/fields/' . $instance_id . '/storage'); // Populate the field settings with new settings. $string = 'updated dummy test string'; $edit = array( - 'field[settings][test_field_setting]' => $string, + 'field[settings][test_field_storage_setting]' => $string, ); $this->drupalPostForm(NULL, $edit, t('Save field settings')); @@ -182,7 +180,7 @@ function addExistingField() { * numeric value. That is tested already in FormTest::testNumber(). */ function cardinalitySettings() { - $field_edit_path = 'admin/structure/types/manage/article/fields/node.article.body/field'; + $field_edit_path = 'admin/structure/types/manage/article/fields/node.article.body/storage'; // Assert the cardinality other field cannot be empty when cardinality is // set to 'number'. @@ -239,9 +237,9 @@ protected function deleteFieldInstance() { * The entity type for the instance. */ function assertFieldSettings($bundle, $field_name, $string = 'dummy test string', $entity_type = 'node') { - // Assert field settings. - $field = FieldConfig::loadByName($entity_type, $field_name); - $this->assertTrue($field->getSetting('test_field_setting') == $string, 'Field settings were found.'); + // Assert field storage settings. + $field_storage = FieldStorageConfig::loadByName($entity_type, $field_name); + $this->assertTrue($field_storage->getSetting('test_field_storage_setting') == $string, 'Field storage settings were found.'); // Assert instance settings. $instance = FieldInstanceConfig::loadByName($entity_type, $bundle, $field_name); @@ -284,7 +282,7 @@ function testFieldPrefix() { function testDefaultValue() { // Create a test field and instance. $field_name = 'test'; - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => $field_name, 'entity_type' => 'node', 'type' => 'test_field' @@ -366,16 +364,16 @@ function testDeleteField() { // Check that the field instance was deleted. $this->assertNull(FieldInstanceConfig::loadByName('node', $this->type, $this->field_name), 'Field instance was deleted.'); - // Check that the field was not deleted - $this->assertNotNull(FieldConfig::loadByName('node', $this->field_name), 'Field was not deleted.'); + // Check that the field storage was not deleted + $this->assertNotNull(FieldStorageConfig::loadByName('node', $this->field_name), 'Field storage was not deleted.'); // Delete the second instance. $this->fieldUIDeleteField($bundle_path2, "node.$type_name2.$this->field_name", $this->field_label, $type_name2); // Check that the field instance was deleted. $this->assertNull(FieldInstanceConfig::loadByName('node', $type_name2, $this->field_name), 'Field instance was deleted.'); - // Check that the field was deleted too. - $this->assertNull(FieldConfig::loadByName('node', $this->field_name), 'Field was deleted.'); + // Check that the field storage was deleted too. + $this->assertNull(FieldStorageConfig::loadByName('node', $this->field_name), 'Field storage was deleted.'); } /** @@ -410,33 +408,34 @@ function testDisallowedFieldNames() { function testLockedField() { // Create a locked field and attach it to a bundle. We need to do this // programatically as there's no way to create a locked field through UI. - $field = entity_create('field_config', array( - 'name' => strtolower($this->randomName(8)), + $field_name = strtolower($this->randomName(8)); + $field_storage = entity_create('field_storage_config', array( + 'name' => $field_name, 'entity_type' => 'node', 'type' => 'test_field', 'cardinality' => 1, 'locked' => TRUE )); - $field->save(); + $field_storage->save(); entity_create('field_instance_config', array( - 'field' => $field, + 'field_storage' => $field_storage, 'bundle' => $this->type, ))->save(); entity_get_form_display('node', $this->type, 'default') - ->setComponent($field->name, array( + ->setComponent($field_storage->name, array( 'type' => 'test_field_widget', )) ->save(); // Check that the links for edit and delete are not present. $this->drupalGet('admin/structure/types/manage/' . $this->type . '/fields'); - $locked = $this->xpath('//tr[@id=:field_name]/td[4]', array(':field_name' => $field->name)); + $locked = $this->xpath('//tr[@id=:field_name]/td[4]', array(':field_name' => $field_name)); $this->assertTrue(in_array('Locked', $locked), 'Field is marked as Locked in the UI'); - $edit_link = $this->xpath('//tr[@id=:field_name]/td[4]', array(':field_name' => $field->name)); + $edit_link = $this->xpath('//tr[@id=:field_name]/td[4]', array(':field_name' => $field_name)); $this->assertFalse(in_array('edit', $edit_link), 'Edit option for locked field is not present the UI'); - $delete_link = $this->xpath('//tr[@id=:field_name]/td[4]', array(':field_name' => $field->name)); + $delete_link = $this->xpath('//tr[@id=:field_name]/td[4]', array(':field_name' => $field_name)); $this->assertFalse(in_array('delete', $delete_link), 'Delete option for locked field is not present the UI'); - $this->drupalGet('admin/structure/types/manage/' . $this->type . '/fields/node.' . $this->type . '.' . $field->name . '/delete'); + $this->drupalGet('admin/structure/types/manage/' . $this->type . '/fields/node.' . $this->type . '.' . $field_name . '/delete'); $this->assertResponse(403); } @@ -452,7 +451,7 @@ function testHiddenFields() { // Create a field and an instance programmatically. $field_name = 'hidden_test_field'; - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => $field_name, 'entity_type' => 'node', 'type' => $field_name, @@ -540,8 +539,8 @@ function testDeleteTaxonomyField() { // Check that the field instance was deleted. $this->assertNull(FieldInstanceConfig::loadByName('taxonomy_term', 'tags', $this->field_name), 'Field instance was deleted.'); - // Check that the field was deleted too. - $this->assertNull(FieldConfig::loadByName('taxonomy_term', $this->field_name), 'Field was deleted.'); + // Check that the field storage was deleted too. + $this->assertNull(FieldStorageConfig::loadByName('taxonomy_term', $this->field_name), 'Field storage was deleted.'); } /** @@ -549,7 +548,7 @@ function testDeleteTaxonomyField() { */ function testHelpDescriptions() { // Create an image field - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => 'field_image', 'entity_type' => 'node', 'type' => 'image', diff --git a/core/modules/file/file.module b/core/modules/file/file.module index a0091d84ca97..ce6348430d24 100644 --- a/core/modules/file/file.module +++ b/core/modules/file/file.module @@ -651,7 +651,7 @@ function file_file_download($uri, $field_type = 'file') { foreach ($references as $field_name => $field_references) { foreach ($field_references as $entity_type => $entities) { $field_storage_definitions = \Drupal::entityManager()->getFieldStorageDefinitions($entity_type); - $field = $field_storage_definitions[$field_name]; + $field_storage = $field_storage_definitions[$field_name]; foreach ($entities as $entity) { // Check if access to this field is not disallowed. if (!$entity->get($field_name)->access('view')) { @@ -663,12 +663,12 @@ function file_file_download($uri, $field_type = 'file') { // Default to FALSE and let entities overrule this ruling. $grants = array('system' => FALSE); foreach (\Drupal::moduleHandler()->getImplementations('file_download_access') as $module) { - $grants = array_merge($grants, array($module => \Drupal::moduleHandler()->invoke($module, 'file_download_access', array($field, $entity, $file)))); + $grants = array_merge($grants, array($module => \Drupal::moduleHandler()->invoke($module, 'file_download_access', array($field_storage, $entity, $file)))); } // Allow other modules to alter the returned grants/denies. $context = array( 'entity' => $entity, - 'field' => $field, + 'field' => $field_storage, 'file' => $file, ); \Drupal::moduleHandler()->alter('file_download_access', $grants, $context); diff --git a/core/modules/file/file.views.inc b/core/modules/file/file.views.inc index e1029d517f61..09fc3ad25f8e 100644 --- a/core/modules/file/file.views.inc +++ b/core/modules/file/file.views.inc @@ -6,7 +6,7 @@ */ use Drupal\Core\Entity\ContentEntityDatabaseStorage; -use Drupal\field\FieldConfigInterface; +use Drupal\field\FieldStorageConfigInterface; /** * Implements hook_views_data(). @@ -497,16 +497,16 @@ function file_views_data() { * * @see field_views_field_default_views_data() */ -function file_field_views_data(FieldConfigInterface $field) { - $data = field_views_field_default_views_data($field); +function file_field_views_data(FieldStorageConfigInterface $field_storage) { + $data = field_views_field_default_views_data($field_storage); foreach ($data as $table_name => $table_data) { // Add the relationship only on the fid field. - $data[$table_name][$field->getName() . '_target_id']['relationship'] = array( + $data[$table_name][$field_storage->getName() . '_target_id']['relationship'] = array( 'id' => 'standard', 'base' => 'file_managed', 'entity type' => 'file', 'base field' => 'target_id', - 'label' => t('file from !field_name', array('!field_name' => $field->getName())), + 'label' => t('file from !field_name', array('!field_name' => $field_storage->getName())), ); } @@ -518,10 +518,10 @@ function file_field_views_data(FieldConfigInterface $field) { * * Views integration to provide reverse relationships on file fields. */ -function file_field_views_data_views_data_alter(array &$data, FieldConfigInterface $field) { - $entity_type_id = $field->entity_type; +function file_field_views_data_views_data_alter(array &$data, FieldStorageConfigInterface $field_storage) { + $entity_type_id = $field_storage->entity_type; $entity_type = \Drupal::entityManager()->getDefinition($entity_type_id); - $field_name = $field->getName(); + $field_name = $field_storage->getName(); $pseudo_field_name = 'reverse_' . $field_name . '_' . $entity_type_id; list($label) = field_views_field_label($entity_type_id, $field_name); @@ -532,7 +532,7 @@ function file_field_views_data_views_data_alter(array &$data, FieldConfigInterfa 'id' => 'entity_reverse', 'field_name' => $field_name, 'entity_type' => $entity_type_id, - 'field table' => ContentEntityDatabaseStorage::_fieldTableName($field), + 'field table' => ContentEntityDatabaseStorage::_fieldTableName($field_storage), 'field field' => $field_name . '_target_id', 'base' => $entity_type->getBaseTable(), 'base field' => $entity_type->getKey('id'), diff --git a/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php b/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php index 8f7fb02f4d45..5f71e9a38cd3 100644 --- a/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php +++ b/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php @@ -314,18 +314,18 @@ public static function validateMultipleCount($element, &$form_state, $form) { $current = count(Element::children(NestedArray::getValue($form, $parents))) - 1; $field_storage_definitions = \Drupal::entityManager()->getFieldStorageDefinitions($element['#entity_type']); - $field = $field_storage_definitions[$element['#field_name']]; + $field_storage = $field_storage_definitions[$element['#field_name']]; $uploaded = count($values['fids']); $count = $uploaded + $current; - if ($count > $field->getCardinality()) { - $keep = $uploaded - $count + $field->getCardinality(); + if ($count > $field_storage->getCardinality()) { + $keep = $uploaded - $count + $field_storage->getCardinality(); $removed_files = array_slice($values['fids'], $keep); $removed_names = array(); foreach ($removed_files as $fid) { $file = file_load($fid); $removed_names[] = $file->getFilename(); } - $args = array('%field' => $field->getFieldName(), '@max' => $field->getCardinality(), '@count' => $keep, '%list' => implode(', ', $removed_names)); + $args = array('%field' => $field_storage->getFieldName(), '@max' => $field_storage->getCardinality(), '@count' => $keep, '%list' => implode(', ', $removed_names)); $message = t('Field %field can only hold @max values but there were @count uploaded. The following files have been omitted as a result: %list.', $args); drupal_set_message($message, 'warning'); $values['fids'] = array_slice($values['fids'], 0, $keep); diff --git a/core/modules/file/src/Tests/FileFieldTestBase.php b/core/modules/file/src/Tests/FileFieldTestBase.php index 644f6f9675bc..78f39c9a11f8 100644 --- a/core/modules/file/src/Tests/FileFieldTestBase.php +++ b/core/modules/file/src/Tests/FileFieldTestBase.php @@ -7,7 +7,7 @@ namespace Drupal\file\Tests; -use Drupal\field\Entity\FieldConfig; +use Drupal\field\Entity\FieldStorageConfig; use Drupal\field\Entity\FieldInstanceConfig; use Drupal\file\FileInterface; use Drupal\simpletest\WebTestBase; @@ -54,7 +54,7 @@ function getLastFileId() { } /** - * Creates a new file field. + * Creates a new file field (storage and instance). * * @param $name * The name of the new field (all lowercase), exclude the "field_" prefix. @@ -62,27 +62,25 @@ function getLastFileId() { * The entity type. * @param $bundle * The bundle that this field will be added to. - * @param $field_settings - * A list of field settings that will be added to the defaults. + * @param $storage_settings + * A list of field storage settings that will be added to the defaults. * @param $instance_settings * A list of instance settings that will be added to the instance defaults. * @param $widget_settings * A list of widget settings that will be added to the widget defaults. */ - function createFileField($name, $entity_type, $bundle, $field_settings = array(), $instance_settings = array(), $widget_settings = array()) { - $field_definition = array( + function createFileField($name, $entity_type, $bundle, $storage_settings = array(), $instance_settings = array(), $widget_settings = array()) { + $field_storage = entity_create('field_storage_config', array( 'entity_type' => $entity_type, 'name' => $name, 'type' => 'file', - 'settings' => array(), - 'cardinality' => !empty($field_settings['cardinality']) ? $field_settings['cardinality'] : 1, - ); - $field_definition['settings'] = array_merge($field_definition['settings'], $field_settings); - $field = entity_create('field_config', $field_definition); - $field->save(); + 'settings' => $storage_settings, + 'cardinality' => !empty($storage_settings['cardinality']) ? $storage_settings['cardinality'] : 1, + )); + $field_storage->save(); $this->attachFileField($name, $entity_type, $bundle, $instance_settings, $widget_settings); - return $field; + return $field_storage; } /** @@ -161,9 +159,9 @@ function uploadNodeFile($file, $field_name, $nid_or_type, $new_revision = TRUE, } // Attach a file to the node. - $field = FieldConfig::loadByName('node', $field_name); + $field_storage = FieldStorageConfig::loadByName('node', $field_name); $name = 'files[' . $field_name . '_0]'; - if ($field->getCardinality() != 1) { + if ($field_storage->getCardinality() != 1) { $name .= '[]'; } $edit[$name] = drupal_realpath($file->getFileUri()); diff --git a/core/modules/file/src/Tests/FileFieldWidgetTest.php b/core/modules/file/src/Tests/FileFieldWidgetTest.php index 0c92b64819f2..5c4f0f659deb 100644 --- a/core/modules/file/src/Tests/FileFieldWidgetTest.php +++ b/core/modules/file/src/Tests/FileFieldWidgetTest.php @@ -212,7 +212,7 @@ function testPrivateFileSetting() { // Change the field setting to make its files private, and upload a file. $edit = array('field[settings][uri_scheme]' => 'private'); - $this->drupalPostForm("admin/structure/types/manage/$type_name/fields/$instance->id/field", $edit, t('Save field settings')); + $this->drupalPostForm("admin/structure/types/manage/$type_name/fields/$instance->id/storage", $edit, t('Save field settings')); $nid = $this->uploadNodeFile($test_file, $field_name, $type_name); $node = node_load($nid, TRUE); $node_file = file_load($node->{$field_name}->target_id); @@ -224,12 +224,12 @@ function testPrivateFileSetting() { // Ensure we can't change 'uri_scheme' field settings while there are some // entities with uploaded files. - $this->drupalGet("admin/structure/types/manage/$type_name/fields/$instance->id/field"); + $this->drupalGet("admin/structure/types/manage/$type_name/fields/$instance->id/storage"); $this->assertFieldByXpath('//input[@id="edit-field-settings-uri-scheme-public" and @disabled="disabled"]', 'public', 'Upload destination setting disabled.'); // Delete node and confirm that setting could be changed. $node->delete(); - $this->drupalGet("admin/structure/types/manage/$type_name/fields/$instance->id/field"); + $this->drupalGet("admin/structure/types/manage/$type_name/fields/$instance->id/storage"); $this->assertFieldByXpath('//input[@id="edit-field-settings-uri-scheme-public" and not(@disabled)]', 'public', 'Upload destination setting enabled.'); } diff --git a/core/modules/file/src/Tests/FileItemTest.php b/core/modules/file/src/Tests/FileItemTest.php index 4e5816c5e6ee..34749061f401 100644 --- a/core/modules/file/src/Tests/FileItemTest.php +++ b/core/modules/file/src/Tests/FileItemTest.php @@ -39,7 +39,7 @@ public function setUp() { $this->installEntitySchema('file'); $this->installSchema('file', array('file_usage')); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => 'file_test', 'entity_type' => 'entity_test', 'type' => 'file', diff --git a/core/modules/file/tests/file_module_test/file_module_test.module b/core/modules/file/tests/file_module_test/file_module_test.module index 16520f56a5bf..d84eddc949fa 100644 --- a/core/modules/file/tests/file_module_test/file_module_test.module +++ b/core/modules/file/tests/file_module_test/file_module_test.module @@ -7,15 +7,15 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\file\Entity\File; -use Drupal\field\FieldConfigInterface; +use Drupal\field\FieldStorageConfigInterface; /** * Implements hook_file_download_access(). */ -function file_module_test_file_download_access(FieldConfigInterface $field, EntityInterface $entity, File $file) { +function file_module_test_file_download_access(FieldStorageConfigInterface $field_storage, EntityInterface $entity, File $file) { $field_definitions = \Drupal::entityManager()->getFieldDefinitions($entity->getEntityTypeId(), $entity->bundle()); // Allow the file to be downloaded only if the given arguments are correct. - if (empty($field_definitions[$field->getName()])) { + if (empty($field_definitions[$field_storage->getName()])) { return FALSE; } } diff --git a/core/modules/forum/config/install/field.instance.taxonomy_term.forums.forum_container.yml b/core/modules/forum/config/install/field.instance.taxonomy_term.forums.forum_container.yml index 3561d56433bf..b1c47ea20d17 100644 --- a/core/modules/forum/config/install/field.instance.taxonomy_term.forums.forum_container.yml +++ b/core/modules/forum/config/install/field.instance.taxonomy_term.forums.forum_container.yml @@ -15,5 +15,5 @@ settings: { } field_type: boolean dependencies: entity: - - field.field.taxonomy_term.forum_container + - field.storage.taxonomy_term.forum_container - taxonomy.vocabulary.forums diff --git a/core/modules/forum/config/install/field.field.taxonomy_term.forum_container.yml b/core/modules/forum/config/install/field.storage.taxonomy_term.forum_container.yml similarity index 100% rename from core/modules/forum/config/install/field.field.taxonomy_term.forum_container.yml rename to core/modules/forum/config/install/field.storage.taxonomy_term.forum_container.yml diff --git a/core/modules/forum/forum.install b/core/modules/forum/forum.install index 2b3d14f293f4..8aacf3949a3c 100644 --- a/core/modules/forum/forum.install +++ b/core/modules/forum/forum.install @@ -6,7 +6,7 @@ */ use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; -use Drupal\field\Entity\FieldConfig; +use Drupal\field\Entity\FieldStorageConfig; /** * Implements hook_install(). @@ -23,8 +23,8 @@ function forum_install() { // Create the 'taxonomy_forums' field if it doesn't already exist. If forum // is being enabled at the same time as taxonomy after both modules have been // enabled, the field might exist but still be marked inactive. - if (!FieldConfig::loadByName('node', 'taxonomy_forums')) { - entity_create('field_config', array( + if (!FieldStorageConfig::loadByName('node', 'taxonomy_forums')) { + entity_create('field_storage_config', array( 'name' => 'taxonomy_forums', 'entity_type' => 'node', 'type' => 'taxonomy_term_reference', @@ -80,12 +80,12 @@ function forum_install() { ->save(); } // Add the comment field to the forum node type. - $fields = entity_load_multiple_by_properties('field_config', array( + $field_storages = entity_load_multiple_by_properties('field_storage_config', array( 'type' => 'comment', 'name' => 'comment_forum', 'include_deleted' => FALSE, )); - if (empty($fields)) { + if (empty($field_storages)) { Drupal::service('comment.manager')->addDefaultField('node', 'forum', 'comment_forum', CommentItemInterface::OPEN, 'comment_forum'); } } @@ -95,16 +95,16 @@ function forum_install() { * Implements hook_uninstall(). */ function forum_uninstall() { - if ($field = FieldConfig::loadByName('node', 'taxonomy_forums')) { - $field->delete(); + if ($field_storage = FieldStorageConfig::loadByName('node', 'taxonomy_forums')) { + $field_storage->delete(); } - if ($field = FieldConfig::loadByName('node', 'comment_forum')) { - $field->delete(); + if ($field_storage = FieldStorageConfig::loadByName('node', 'comment_forum')) { + $field_storage->delete(); } - if ($field = FieldConfig::loadByName('taxonomy_term', 'forum_container')) { - $field->delete(); + if ($field_storage = FieldStorageConfig::loadByName('taxonomy_term', 'forum_container')) { + $field_storage->delete(); } // Purge field data now to allow taxonomy and options module to be uninstalled diff --git a/core/modules/forum/src/Tests/ForumUninstallTest.php b/core/modules/forum/src/Tests/ForumUninstallTest.php index 914099ffd9fd..8b6fca13f283 100644 --- a/core/modules/forum/src/Tests/ForumUninstallTest.php +++ b/core/modules/forum/src/Tests/ForumUninstallTest.php @@ -9,7 +9,7 @@ use Drupal\comment\CommentInterface; use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; -use Drupal\field\Entity\FieldConfig; +use Drupal\field\Entity\FieldStorageConfig; use Drupal\simpletest\WebTestBase; /** @@ -31,8 +31,8 @@ class ForumUninstallTest extends WebTestBase { */ function testForumUninstallWithField() { // Ensure that the field exists before uninstallation. - $field = FieldConfig::loadByName('node', 'taxonomy_forums'); - $this->assertNotNull($field, 'The taxonomy_forums field exists.'); + $field_storage = FieldStorageConfig::loadByName('node', 'taxonomy_forums'); + $this->assertNotNull($field_storage, 'The taxonomy_forums field storage exists.'); // Create a taxonomy term. $term = entity_create('taxonomy_term', array( @@ -77,23 +77,23 @@ function testForumUninstallWithField() { $this->assertResponse(200); // Check that the field is now deleted. - $field = FieldConfig::loadByName('node', 'taxonomy_forums'); - $this->assertNull($field, 'The taxonomy_forums field has been deleted.'); + $field_storage = FieldStorageConfig::loadByName('node', 'taxonomy_forums'); + $this->assertNull($field_storage, 'The taxonomy_forums field storage has been deleted.'); } /** - * Tests if uninstallation succeeds if the field has been deleted beforehand. + * Tests uninstallation if the field storage has been deleted beforehand. */ - function testForumUninstallWithoutField() { + function testForumUninstallWithoutFieldStorage() { // Manually delete the taxonomy_forums field before module uninstallation. - $field = FieldConfig::loadByName('node', 'taxonomy_forums'); - $this->assertNotNull($field, 'The taxonomy_forums field exists.'); - $field->delete(); + $field_storage = FieldStorageConfig::loadByName('node', 'taxonomy_forums'); + $this->assertNotNull($field_storage, 'The taxonomy_forums field storage exists.'); + $field_storage->delete(); // Check that the field is now deleted. - $field = FieldConfig::loadByName('node', 'taxonomy_forums'); - $this->assertNull($field, 'The taxonomy_forums field has been deleted.'); + $field_storage = FieldStorageConfig::loadByName('node', 'taxonomy_forums'); + $this->assertNull($field_storage, 'The taxonomy_forums field storage has been deleted.'); // Ensure that uninstallation succeeds even if the field has already been // deleted manually beforehand. diff --git a/core/modules/hal/src/Tests/NormalizerTestBase.php b/core/modules/hal/src/Tests/NormalizerTestBase.php index 8bb477726b0b..2ebff7468dc9 100644 --- a/core/modules/hal/src/Tests/NormalizerTestBase.php +++ b/core/modules/hal/src/Tests/NormalizerTestBase.php @@ -81,7 +81,7 @@ function setUp() { language_save($german); // Create the test text field. - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => 'field_test_text', 'entity_type' => 'entity_test', 'type' => 'text', @@ -94,7 +94,7 @@ function setUp() { ))->save(); // Create the test translatable field. - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => 'field_test_translatable_text', 'entity_type' => 'entity_test', 'type' => 'text', @@ -107,7 +107,7 @@ function setUp() { ))->save(); // Create the test entity reference field. - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => 'field_test_entity_reference', 'entity_type' => 'entity_test', 'type' => 'entity_reference', diff --git a/core/modules/image/image.module b/core/modules/image/image.module index 2ff2ecb7b143..86c878f03163 100644 --- a/core/modules/image/image.module +++ b/core/modules/image/image.module @@ -6,10 +6,9 @@ */ use Drupal\Core\Entity\EntityInterface; -use Drupal\Component\Plugin\Exception\PluginNotFoundException; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\file\Entity\File; -use Drupal\field\FieldConfigInterface; +use Drupal\field\FieldStorageConfigInterface; use Drupal\field\FieldInstanceConfigInterface; /** @@ -358,22 +357,22 @@ function image_filter_keyword($value, $current_pixels, $new_pixels) { * Transforms default image of image field from array into single value at save. */ function image_entity_presave(EntityInterface $entity) { - $field = FALSE; + $field_storage = FALSE; $entity_type_id = $entity->getEntityTypeId(); if ($entity_type_id == 'field_instance_config') { - $field = $entity->getFieldStorageDefinition(); + $field_storage = $entity->getFieldStorageDefinition(); $default_settings = \Drupal::service('plugin.manager.field.field_type')->getDefaultInstanceSettings('image'); } - elseif ($entity_type_id == 'field_config') { - $field = $entity; + elseif ($entity_type_id == 'field_storage_config') { + $field_storage = $entity; $default_settings = \Drupal::service('plugin.manager.field.field_type')->getDefaultSettings('image'); } // Exit, if not saving an image field or image field instance entity. - if (!$field || $field->type != 'image') { + if (!$field_storage || $field_storage->type != 'image') { return; } - if ($field->isSyncing()) { + if ($field_storage->isSyncing()) { return; } @@ -397,19 +396,19 @@ function image_entity_presave(EntityInterface $entity) { } /** - * Implements hook_ENTITY_TYPE_update() for 'field_config'. + * Implements hook_ENTITY_TYPE_update() for 'field_storage_config'. */ -function image_field_config_update(FieldConfigInterface $field) { - if ($field->type != 'image') { +function image_field_storage_config_update(FieldStorageConfigInterface $field_storage) { + if ($field_storage->type != 'image') { // Only act on image fields. return; } - $prior_field = $field->original; + $prior_field_storage = $field_storage->original; // The value of a managed_file element can be an array if #extended == TRUE. - $fid_new = $field->settings['default_image']['fid']; - $fid_old = $prior_field->settings['default_image']['fid']; + $fid_new = $field_storage->settings['default_image']['fid']; + $fid_old = $prior_field_storage->settings['default_image']['fid']; $file_new = $fid_new ? file_load($fid_new) : FALSE; @@ -419,18 +418,18 @@ function image_field_config_update(FieldConfigInterface $field) { if ($file_new) { $file_new->status = FILE_STATUS_PERMANENT; $file_new->save(); - \Drupal::service('file.usage')->add($file_new, 'image', 'default_image', $field->uuid()); + \Drupal::service('file.usage')->add($file_new, 'image', 'default_image', $field_storage->uuid()); } // Is there an old file? if ($fid_old && ($file_old = file_load($fid_old))) { - \Drupal::service('file.usage')->delete($file_old, 'image', 'default_image', $field->uuid()); + \Drupal::service('file.usage')->delete($file_old, 'image', 'default_image', $field_storage->uuid()); } } // If the upload destination changed, then move the file. - if ($file_new && (file_uri_scheme($file_new->getFileUri()) != $field->settings['uri_scheme'])) { - $directory = $field->settings['uri_scheme'] . '://default_images/'; + if ($file_new && (file_uri_scheme($file_new->getFileUri()) != $field_storage->settings['uri_scheme'])) { + $directory = $field_storage->settings['uri_scheme'] . '://default_images/'; file_prepare_directory($directory, FILE_CREATE_DIRECTORY); file_move($file_new, $directory . $file_new->filename); } @@ -440,8 +439,8 @@ function image_field_config_update(FieldConfigInterface $field) { * Implements hook_ENTITY_TYPE_update() for 'field_instance_config'. */ function image_field_instance_config_update(FieldInstanceConfigInterface $field_instance) { - $field = $field_instance->getFieldStorageDefinition(); - if ($field->type != 'image') { + $field_storage = $field_instance->getFieldStorageDefinition(); + if ($field_storage->type != 'image') { // Only act on image fields. return; } @@ -467,17 +466,17 @@ function image_field_instance_config_update(FieldInstanceConfigInterface $field_ } // If the upload destination changed, then move the file. - if ($file_new && (file_uri_scheme($file_new->getFileUri()) != $field->settings['uri_scheme'])) { - $directory = $field->settings['uri_scheme'] . '://default_images/'; + if ($file_new && (file_uri_scheme($file_new->getFileUri()) != $field_storage->settings['uri_scheme'])) { + $directory = $field_storage->settings['uri_scheme'] . '://default_images/'; file_prepare_directory($directory, FILE_CREATE_DIRECTORY); file_move($file_new, $directory . $file_new->filename); } } /** - * Implements hook_ENTITY_TYPE_delete() for 'field_config'. + * Implements hook_ENTITY_TYPE_delete() for 'field_storage_config'. */ -function image_field_config_delete(FieldConfigInterface $field) { +function image_field_storage_config_delete(FieldStorageConfigInterface $field) { if ($field->type != 'image') { // Only act on image fields. return; @@ -494,8 +493,8 @@ function image_field_config_delete(FieldConfigInterface $field) { * Implements hook_ENTITY_TYPE_delete() for 'field_instance_config'. */ function image_field_instance_config_delete(FieldInstanceConfigInterface $field_instance) { - $field = $field_instance->getFieldStorageDefinition(); - if ($field->type != 'image') { + $field_storage = $field_instance->getFieldStorageDefinition(); + if ($field_storage->type != 'image') { // Only act on image fields. return; } diff --git a/core/modules/image/image.views.inc b/core/modules/image/image.views.inc index fe2d59aea970..512035061340 100644 --- a/core/modules/image/image.views.inc +++ b/core/modules/image/image.views.inc @@ -6,7 +6,7 @@ */ use Drupal\Core\Entity\ContentEntityDatabaseStorage; -use Drupal\field\FieldConfigInterface; +use Drupal\field\FieldStorageConfigInterface; /** * Implements hook_field_views_data(). @@ -16,15 +16,15 @@ * * @see field_views_field_default_views_data() */ -function image_field_views_data(FieldConfigInterface $field) { - $data = field_views_field_default_views_data($field); +function image_field_views_data(FieldStorageConfigInterface $field_storage) { + $data = field_views_field_default_views_data($field_storage); foreach ($data as $table_name => $table_data) { // Add the relationship only on the target_id field. - $data[$table_name][$field->getName() . '_target_id']['relationship'] = array( + $data[$table_name][$field_storage->getName() . '_target_id']['relationship'] = array( 'id' => 'standard', 'base' => 'file_managed', 'base field' => 'target_id', - 'label' => t('image from !field_name', array('!field_name' => $field->getName())), + 'label' => t('image from !field_name', array('!field_name' => $field_storage->getName())), ); } @@ -36,9 +36,9 @@ function image_field_views_data(FieldConfigInterface $field) { * * Views integration to provide reverse relationships on image fields. */ -function image_field_views_data_views_data_alter(array &$data, FieldConfigInterface $field) { - $entity_type_id = $field->entity_type; - $field_name = $field->getName(); +function image_field_views_data_views_data_alter(array &$data, FieldStorageConfigInterface $field_storage) { + $entity_type_id = $field_storage->entity_type; + $field_name = $field_storage->getName(); $entity_type = \Drupal::entityManager()->getDefinition($entity_type_id); $pseudo_field_name = 'reverse_' . $field_name . '_' . $entity_type_id; @@ -50,7 +50,7 @@ function image_field_views_data_views_data_alter(array &$data, FieldConfigInterf 'id' => 'entity_reverse', 'field_name' => $field_name, 'entity_type' => $entity_type_id, - 'field table' => ContentEntityDatabaseStorage::_fieldTableName($field), + 'field table' => ContentEntityDatabaseStorage::_fieldTableName($field_storage), 'field field' => $field_name . '_target_id', 'base' => $entity_type->getBaseTable(), 'base field' => $entity_type->getKey('id'), diff --git a/core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php b/core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php index cbb9202ce1a1..978adf5eb266 100644 --- a/core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php +++ b/core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php @@ -44,7 +44,7 @@ public function testDefaultImages() { // Create an image field and add an instance to the article content type. $field_name = strtolower($this->randomName()); - $field_settings['default_image'] = array( + $storage_settings['default_image'] = array( 'fid' => $default_images['field']->id(), 'alt' => '', 'title' => '', @@ -61,30 +61,25 @@ public function testDefaultImages() { $widget_settings = array( 'preview_image_style' => 'medium', ); - $instance = $this->createImageField($field_name, 'article', $field_settings, $instance_settings, $widget_settings); + $instance = $this->createImageField($field_name, 'article', $storage_settings, $instance_settings, $widget_settings); // The instance default image id should be 2. - $default_image = $instance->getSetting('default_image'); - $this->assertEqual($default_image['fid'], $default_images['instance']->id()); + $this->assertEqual($instance->getSetting('default_image')['fid'], $default_images['instance']->id()); // Also test \Drupal\field\Entity\FieldInstanceConfig::getSetting(). - $instance_field_settings = $instance->getSettings(); - $this->assertEqual($instance_field_settings['default_image']['fid'], $default_images['instance']->id()); + $this->assertEqual($instance->getSettings()['default_image']['fid'], $default_images['instance']->id()); - $field = $instance->getFieldStorageDefinition(); + $field_storage = $instance->getFieldStorageDefinition(); // The field default image id should be 1. - $default_image = $field->getSetting('default_image'); - $this->assertEqual($default_image['fid'], $default_images['field']->id()); + $this->assertEqual($field_storage->getSetting('default_image')['fid'], $default_images['field']->id()); - // Also test \Drupal\field\Entity\FieldConfig::getSettings(). - $field_field_settings = $field->getSettings(); - $this->assertEqual($field_field_settings['default_image']['fid'], $default_images['field']->id()); + // Also test \Drupal\field\Entity\FieldStorageConfig::getSettings(). + $this->assertEqual($field_storage->getSettings()['default_image']['fid'], $default_images['field']->id()); // Add another instance with another default image to the page content type. $instance2 = entity_create('field_instance_config', array( - 'field_name' => $field->name, - 'entity_type' => 'node', + 'field_storage' => $field_storage, 'bundle' => 'page', 'label' => $instance->label(), 'required' => $instance->required, @@ -110,7 +105,7 @@ public function testDefaultImages() { // Confirm the defaults are present on the article field settings form. $instance_id = $instance->id(); - $this->drupalGet("admin/structure/types/manage/article/fields/$instance_id/field"); + $this->drupalGet("admin/structure/types/manage/article/fields/$instance_id/storage"); $this->assertFieldByXpath( '//input[@name="field[settings][default_image][fid][fids]"]', $default_images['field']->id(), @@ -131,7 +126,7 @@ public function testDefaultImages() { ); // Confirm the defaults are present on the page field settings form. - $this->drupalGet("admin/structure/types/manage/page/fields/$instance_id/field"); + $this->drupalGet("admin/structure/types/manage/page/fields/$instance_id/storage"); $this->assertFieldByXpath( '//input[@name="field[settings][default_image][fid][fids]"]', $default_images['field']->id(), @@ -176,12 +171,12 @@ public function testDefaultImages() { ) ); - // Upload a new default for the field. - $field->settings['default_image']['fid'] = $default_images['field_new']->id(); - $field->save(); + // Upload a new default for the field storage. + $field_storage->settings['default_image']['fid'] = $default_images['field_new']->id(); + $field_storage->save(); // Confirm that the new default is used on the article field settings form. - $this->drupalGet("admin/structure/types/manage/article/fields/$instance_id/field"); + $this->drupalGet("admin/structure/types/manage/article/fields/$instance_id/storage"); $this->assertFieldByXpath( '//input[@name="field[settings][default_image][fid][fids]"]', $default_images['field_new']->id(), @@ -288,8 +283,8 @@ public function testDefaultImages() { /** * Tests image field and instance having an invalid default image. */ - public function testInvalidDefaultImage() { - $field = array( + public function testInvalidDefaultImage() { + $field_storage = entity_create('field_storage_config', array( 'name' => drupal_strtolower($this->randomName()), 'entity_type' => 'node', 'type' => 'image', @@ -298,30 +293,26 @@ public function testInvalidDefaultImage() { 'fid' => 100000, ) ), - ); - $instance = array( - 'field_name' => $field['name'], - 'label' => $this->randomName(), - 'entity_type' => 'node', + )); + $field_storage->save(); + $settings = $field_storage->getSettings(); + // The non-existent default image should not be saved. + $this->assertNull($settings['default_image']['fid']); + + $field_instance = entity_create('field_instance_config', array( + 'field_storage' => $field_storage, 'bundle' => 'page', + 'label' => $this->randomName(), 'settings' => array( 'default_image' => array( 'fid' => 100000, ) ), - ); - $field_config = entity_create('field_config', $field); - $field_config->save(); - $settings = $field_config->getSettings(); - // The non-existent default image should not be saved. - $this->assertNull($settings['default_image']['fid']); - - $field_instance_config = entity_create('field_instance_config', $instance); - $field_instance_config->save(); - $settings = $field_instance_config->getSettings(); + )); + $field_instance->save(); + $settings = $field_instance->getSettings(); // The non-existent default image should not be saved. $this->assertNull($settings['default_image']['fid']); - } } diff --git a/core/modules/image/src/Tests/ImageFieldDisplayTest.php b/core/modules/image/src/Tests/ImageFieldDisplayTest.php index fd768c0d8bf2..465a580a4a10 100644 --- a/core/modules/image/src/Tests/ImageFieldDisplayTest.php +++ b/core/modules/image/src/Tests/ImageFieldDisplayTest.php @@ -8,7 +8,7 @@ namespace Drupal\image\Tests; use Drupal\Core\Field\FieldStorageDefinitionInterface; -use Drupal\field\Entity\FieldConfig; +use Drupal\field\Entity\FieldStorageConfig; /** * Tests the display of image fields. @@ -247,7 +247,7 @@ function testImageFieldSettings() { // 1, so we need to make sure the file widget prevents these notices by // providing all settings, even if they are not used. // @see FileWidget::formMultipleElements(). - $this->drupalPostForm('admin/structure/types/manage/article/fields/node.article.' . $field_name . '/field', array('field[cardinality]' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED), t('Save field settings')); + $this->drupalPostForm('admin/structure/types/manage/article/fields/node.article.' . $field_name . '/storage', array('field[cardinality]' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED), t('Save field settings')); $edit = array(); $edit['files[' . $field_name . '_1][]'] = drupal_realpath($test_image->uri); $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save and keep published')); @@ -289,11 +289,11 @@ function testImageFieldDefaultImage() { 'field[settings][default_image][alt]' => $alt, 'field[settings][default_image][title]' => $title, ); - $this->drupalPostForm("admin/structure/types/manage/article/fields/node.article.$field_name/field", $edit, t('Save field settings')); + $this->drupalPostForm("admin/structure/types/manage/article/fields/node.article.$field_name/storage", $edit, t('Save field settings')); // Clear field definition cache so the new default image is detected. \Drupal::entityManager()->clearCachedFieldDefinitions(); - $field = FieldConfig::loadByName('node', $field_name); - $default_image = $field->getSetting('default_image'); + $field_storage = FieldStorageConfig::loadByName('node', $field_name); + $default_image = $field_storage->getSetting('default_image'); $file = file_load($default_image['fid']); $this->assertTrue($file->isPermanent(), 'The default image status is permanent.'); $image = array( @@ -331,11 +331,11 @@ function testImageFieldDefaultImage() { $edit = array( 'field[settings][default_image][fid][fids]' => 0, ); - $this->drupalPostForm("admin/structure/types/manage/article/fields/node.article.$field_name/field", $edit, t('Save field settings')); + $this->drupalPostForm("admin/structure/types/manage/article/fields/node.article.$field_name/storage", $edit, t('Save field settings')); // Clear field definition cache so the new default image is detected. \Drupal::entityManager()->clearCachedFieldDefinitions(); - $field = FieldConfig::loadByName('node', $field_name); - $default_image = $field->getSetting('default_image'); + $field_storage = FieldStorageConfig::loadByName('node', $field_name); + $default_image = $field_storage->getSetting('default_image'); $this->assertFalse($default_image['fid'], 'Default image removed from field.'); // Create an image field that uses the private:// scheme and test that the // default image works as expected. @@ -347,12 +347,12 @@ function testImageFieldDefaultImage() { 'field[settings][default_image][alt]' => $alt, 'field[settings][default_image][title]' => $title, ); - $this->drupalPostForm('admin/structure/types/manage/article/fields/node.article.' . $private_field_name . '/field', $edit, t('Save field settings')); + $this->drupalPostForm('admin/structure/types/manage/article/fields/node.article.' . $private_field_name . '/storage', $edit, t('Save field settings')); // Clear field definition cache so the new default image is detected. \Drupal::entityManager()->clearCachedFieldDefinitions(); - $private_field = FieldConfig::loadByName('node', $private_field_name); - $default_image = $private_field->getSetting('default_image'); + $private_field_storage = FieldStorageConfig::loadByName('node', $private_field_name); + $default_image = $private_field_storage->getSetting('default_image'); $file = file_load($default_image['fid']); $this->assertEqual('private', file_uri_scheme($file->getFileUri()), 'Default image uses private:// scheme.'); $this->assertTrue($file->isPermanent(), 'The default image status is permanent.'); diff --git a/core/modules/image/src/Tests/ImageFieldTestBase.php b/core/modules/image/src/Tests/ImageFieldTestBase.php index f4e102140adb..48b69f1735e3 100644 --- a/core/modules/image/src/Tests/ImageFieldTestBase.php +++ b/core/modules/image/src/Tests/ImageFieldTestBase.php @@ -56,20 +56,20 @@ function setUp() { * The name of the new field (all lowercase), exclude the "field_" prefix. * @param $type_name * The node type that this field will be added to. - * @param $field_settings - * A list of field settings that will be added to the defaults. + * @param $storage_settings + * A list of field storage settings that will be added to the defaults. * @param $instance_settings * A list of instance settings that will be added to the instance defaults. * @param $widget_settings * A list of widget settings that will be added to the widget defaults. */ - function createImageField($name, $type_name, $field_settings = array(), $instance_settings = array(), $widget_settings = array()) { - entity_create('field_config', array( + function createImageField($name, $type_name, $storage_settings = array(), $instance_settings = array(), $widget_settings = array()) { + entity_create('field_storage_config', array( 'name' => $name, 'entity_type' => 'node', 'type' => 'image', - 'settings' => $field_settings, - 'cardinality' => !empty($field_settings['cardinality']) ? $field_settings['cardinality'] : 1, + 'settings' => $storage_settings, + 'cardinality' => !empty($storage_settings['cardinality']) ? $storage_settings['cardinality'] : 1, ))->save(); $field_instance_config = entity_create('field_instance_config', array( diff --git a/core/modules/image/src/Tests/ImageItemTest.php b/core/modules/image/src/Tests/ImageItemTest.php index 8f59e06585cd..5b8426665599 100644 --- a/core/modules/image/src/Tests/ImageItemTest.php +++ b/core/modules/image/src/Tests/ImageItemTest.php @@ -44,7 +44,7 @@ public function setUp() { $this->installEntitySchema('file'); $this->installSchema('file', array('file_usage')); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => 'image_test', 'entity_type' => 'entity_test', 'type' => 'image', diff --git a/core/modules/image/src/Tests/ImageThemeFunctionTest.php b/core/modules/image/src/Tests/ImageThemeFunctionTest.php index 24d20ac339a8..789cb1f8779d 100644 --- a/core/modules/image/src/Tests/ImageThemeFunctionTest.php +++ b/core/modules/image/src/Tests/ImageThemeFunctionTest.php @@ -39,7 +39,7 @@ class ImageThemeFunctionTest extends WebTestBase { public function setUp() { parent::setUp(); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => 'image_test', 'entity_type' => 'entity_test', 'type' => 'image', diff --git a/core/modules/link/src/Tests/LinkFieldTest.php b/core/modules/link/src/Tests/LinkFieldTest.php index 99401e8b3476..e2f6209812d2 100644 --- a/core/modules/link/src/Tests/LinkFieldTest.php +++ b/core/modules/link/src/Tests/LinkFieldTest.php @@ -28,9 +28,9 @@ class LinkFieldTest extends WebTestBase { /** * A field to use in this test class. * - * @var \Drupal\field\Entity\FieldConfig + * @var \Drupal\field\Entity\FieldStorageConfig */ - protected $field; + protected $fieldStorage; /** * The instance used in this test class. @@ -62,14 +62,14 @@ function setUp() { function testURLValidation() { $field_name = drupal_strtolower($this->randomName()); // Create a field with settings to validate. - $this->field = entity_create('field_config', array( + $this->fieldStorage = entity_create('field_storage_config', array( 'name' => $field_name, 'entity_type' => 'entity_test', 'type' => 'link', )); - $this->field->save(); + $this->fieldStorage->save(); $this->instance = entity_create('field_instance_config', array( - 'field' => $this->field, + 'field_storage' => $this->fieldStorage, 'bundle' => 'entity_test', 'settings' => array( 'title' => DRUPAL_DISABLED, @@ -186,14 +186,14 @@ protected function assertInvalidEntries($field_name, array $invalid_entries) { function testLinkTitle() { $field_name = drupal_strtolower($this->randomName()); // Create a field with settings to validate. - $this->field = entity_create('field_config', array( + $this->fieldStorage = entity_create('field_storage_config', array( 'name' => $field_name, 'entity_type' => 'entity_test', 'type' => 'link', )); - $this->field->save(); + $this->fieldStorage->save(); $this->instance = entity_create('field_instance_config', array( - 'field' => $this->field, + 'field_storage' => $this->fieldStorage, 'bundle' => 'entity_test', 'label' => 'Read more about this entity', 'settings' => array( @@ -304,15 +304,15 @@ function testLinkTitle() { function testLinkFormatter() { $field_name = drupal_strtolower($this->randomName()); // Create a field with settings to validate. - $this->field = entity_create('field_config', array( + $this->fieldStorage = entity_create('field_storage_config', array( 'name' => $field_name, 'entity_type' => 'entity_test', 'type' => 'link', 'cardinality' => 2, )); - $this->field->save(); + $this->fieldStorage->save(); entity_create('field_instance_config', array( - 'field' => $this->field, + 'field_storage' => $this->fieldStorage, 'label' => 'Read more about this entity', 'bundle' => 'entity_test', 'settings' => array( @@ -446,15 +446,15 @@ function testLinkFormatter() { function testLinkSeparateFormatter() { $field_name = drupal_strtolower($this->randomName()); // Create a field with settings to validate. - $this->field = entity_create('field_config', array( + $this->fieldStorage = entity_create('field_storage_config', array( 'name' => $field_name, 'entity_type' => 'entity_test', 'type' => 'link', 'cardinality' => 2, )); - $this->field->save(); + $this->fieldStorage->save(); entity_create('field_instance_config', array( - 'field' => $this->field, + 'field_storage' => $this->fieldStorage, 'bundle' => 'entity_test', 'settings' => array( 'title' => DRUPAL_OPTIONAL, diff --git a/core/modules/link/src/Tests/LinkItemTest.php b/core/modules/link/src/Tests/LinkItemTest.php index 2d81cdc40bc5..f5692d291e59 100644 --- a/core/modules/link/src/Tests/LinkItemTest.php +++ b/core/modules/link/src/Tests/LinkItemTest.php @@ -30,7 +30,7 @@ public function setUp() { parent::setUp(); // Create an link field and instance for validation. - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => 'field_test', 'entity_type' => 'entity_test', 'type' => 'link', diff --git a/core/modules/migrate/src/Plugin/migrate/destination/EntityFieldConfig.php b/core/modules/migrate/src/Plugin/migrate/destination/EntityFieldStorageConfig.php similarity index 78% rename from core/modules/migrate/src/Plugin/migrate/destination/EntityFieldConfig.php rename to core/modules/migrate/src/Plugin/migrate/destination/EntityFieldStorageConfig.php index 8d2c3128f3cf..0e5829f2ccd1 100644 --- a/core/modules/migrate/src/Plugin/migrate/destination/EntityFieldConfig.php +++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityFieldStorageConfig.php @@ -9,10 +9,10 @@ /** * @MigrateDestination( - * id = "entity:field_config" + * id = "entity:field_storage_config" * ) */ -class EntityFieldConfig extends EntityConfigBase { +class EntityFieldStorageConfig extends EntityConfigBase { /** * {@inheritdoc} diff --git a/core/modules/migrate_drupal/config/install/migrate.migration.d6_comment_field.yml b/core/modules/migrate_drupal/config/install/migrate.migration.d6_comment_field.yml index 676dc48f3c39..6a6578a52653 100644 --- a/core/modules/migrate_drupal/config/install/migrate.migration.d6_comment_field.yml +++ b/core/modules/migrate_drupal/config/install/migrate.migration.d6_comment_field.yml @@ -13,7 +13,7 @@ process: type: 'constants/type' 'settings/comment_type': comment_type destination: - plugin: entity:field_config + plugin: entity:field_storage_config migration_dependencies: required: - d6_comment_type diff --git a/core/modules/migrate_drupal/config/install/migrate.migration.d6_field.yml b/core/modules/migrate_drupal/config/install/migrate.migration.d6_field.yml index 5c7cea29a71c..39ae4219e96d 100644 --- a/core/modules/migrate_drupal/config/install/migrate.migration.d6_field.yml +++ b/core/modules/migrate_drupal/config/install/migrate.migration.d6_field.yml @@ -77,4 +77,4 @@ process: - widget_settings destination: - plugin: entity:field_config + plugin: entity:field_storage_config diff --git a/core/modules/migrate_drupal/config/install/migrate.migration.d6_upload_field.yml b/core/modules/migrate_drupal/config/install/migrate.migration.d6_upload_field.yml index eff420fe4546..8daaa4a41a91 100644 --- a/core/modules/migrate_drupal/config/install/migrate.migration.d6_upload_field.yml +++ b/core/modules/migrate_drupal/config/install/migrate.migration.d6_upload_field.yml @@ -20,4 +20,4 @@ process: cardinality: 'constants/cardinality' 'settings/display_field': 'constants/display_field' destination: - plugin: entity:field_config + plugin: entity:field_storage_config diff --git a/core/modules/migrate_drupal/config/install/migrate.migration.d6_user_picture_field.yml b/core/modules/migrate_drupal/config/install/migrate.migration.d6_user_picture_field.yml index 9fc95599e7fb..502bf0debe80 100644 --- a/core/modules/migrate_drupal/config/install/migrate.migration.d6_user_picture_field.yml +++ b/core/modules/migrate_drupal/config/install/migrate.migration.d6_user_picture_field.yml @@ -17,4 +17,4 @@ process: type: 'constants/type' cardinality: 'constants/cardinality' destination: - plugin: entity:field_config + plugin: entity:field_storage_config diff --git a/core/modules/migrate_drupal/config/install/migrate.migration.d6_user_profile_field.yml b/core/modules/migrate_drupal/config/install/migrate.migration.d6_user_profile_field.yml index 219534484f67..e9d892f19dfe 100644 --- a/core/modules/migrate_drupal/config/install/migrate.migration.d6_user_profile_field.yml +++ b/core/modules/migrate_drupal/config/install/migrate.migration.d6_user_profile_field.yml @@ -31,4 +31,4 @@ process: map: list: -1 destination: - plugin: entity:field_config + plugin: entity:field_storage_config diff --git a/core/modules/migrate_drupal/config/install/migrate.migration.d6_vocabulary_field.yml b/core/modules/migrate_drupal/config/install/migrate.migration.d6_vocabulary_field.yml index 149681ef842b..9d5e82de565d 100644 --- a/core/modules/migrate_drupal/config/install/migrate.migration.d6_vocabulary_field.yml +++ b/core/modules/migrate_drupal/config/install/migrate.migration.d6_vocabulary_field.yml @@ -20,7 +20,7 @@ process: 'settings/allowed_values/0/parent': 'constants/parent' cardinality: 'constants/cardinality' destination: - plugin: entity:field_config + plugin: entity:field_storage_config migration_dependencies: required: - d6_taxonomy_vocabulary diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateCckFieldRevisionTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateCckFieldRevisionTest.php index 9f82faf24595..7dbe18d7ab9c 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateCckFieldRevisionTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateCckFieldRevisionTest.php @@ -28,7 +28,7 @@ class MigrateCckFieldRevisionTest extends MigrateNodeTestBase { */ protected function setUp() { parent::setUp(); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'entity_type' => 'node', 'name' => 'field_test', 'type' => 'text', @@ -38,7 +38,7 @@ protected function setUp() { 'field_name' => 'field_test', 'bundle' => 'story', ))->save(); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'entity_type' => 'node', 'name' => 'field_test_two', 'type' => 'integer', diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateCckFieldValuesTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateCckFieldValuesTest.php index b68f579a671e..e245e82f33e7 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateCckFieldValuesTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateCckFieldValuesTest.php @@ -28,7 +28,7 @@ class MigrateCckFieldValuesTest extends MigrateNodeTestBase { */ protected function setUp() { parent::setUp(); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'entity_type' => 'node', 'name' => 'field_test', 'type' => 'text', @@ -38,7 +38,7 @@ protected function setUp() { 'field_name' => 'field_test', 'bundle' => 'story', ))->save(); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'entity_type' => 'node', 'name' => 'field_test_two', 'type' => 'integer', @@ -49,7 +49,7 @@ protected function setUp() { 'field_name' => 'field_test_two', 'bundle' => 'story', ))->save(); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'entity_type' => 'node', 'name' => 'field_test_three', 'type' => 'decimal', diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateCommentVariableDisplayBase.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateCommentVariableDisplayBase.php index ac5c9c7acbcb..fd38a2a3ceb0 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateCommentVariableDisplayBase.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateCommentVariableDisplayBase.php @@ -49,7 +49,7 @@ abstract class MigrateCommentVariableDisplayBase extends MigrateDrupalTestBase { */ protected function setUp() { parent::setUp(); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'entity_type' => 'node', 'name' => 'comment', 'type' => 'comment', diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateCommentVariableFieldTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateCommentVariableFieldTest.php index 2d7dc130ecd6..68beea31601a 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateCommentVariableFieldTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateCommentVariableFieldTest.php @@ -11,7 +11,7 @@ use Drupal\migrate_drupal\Tests\MigrateDrupalTestBase; /** - * Upgrade comment variables to field.field.node.comment.yml. + * Upgrade comment variables to field.storage.node.comment.yml. * * @group migrate_drupal */ @@ -55,8 +55,7 @@ public function setUp() { * Tests comment variables migrated into a field entity. */ public function testCommentField() { - $this->assertTrue(is_object(entity_load('field_config', 'node.comment'))); - $this->assertTrue(is_object(entity_load('field_config', 'node.comment_no_subject'))); + $this->assertTrue(is_object(entity_load('field_storage_config', 'node.comment'))); } } diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateCommentVariableInstanceTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateCommentVariableInstanceTest.php index e789a68a6f6f..2cc52931e6bf 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateCommentVariableInstanceTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateCommentVariableInstanceTest.php @@ -38,13 +38,13 @@ public function setUp() { foreach (array('page', 'story') as $type) { entity_create('node_type', array('type' => $type))->save(); } - entity_create('field_config', array( + entity_create('field_storage_config', array( 'entity_type' => 'node', 'name' => 'comment', 'type' => 'comment', 'translatable' => '0', ))->save(); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'entity_type' => 'node', 'name' => 'comment_no_subject', 'type' => 'comment', diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateFieldInstanceTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateFieldInstanceTest.php index 67c170a5ee0a..9399da87e50d 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateFieldInstanceTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateFieldInstanceTest.php @@ -165,7 +165,7 @@ protected function createFields() { 'field_test_datetime' => 'datetime', ); foreach ($fields as $name => $type) { - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => $name, 'entity_type' => 'node', 'type' => $type, diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateFieldTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateFieldTest.php index 11818d1aac19..f41c1096f9ab 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateFieldTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateFieldTest.php @@ -44,32 +44,32 @@ public function setUp() { */ public function testFields() { // Text field. - $field = entity_load('field_config', 'node.field_test'); + /** @var \Drupal\field\Entity\FieldStorageConfig $field_storage */ + $field_storage = entity_load('field_storage_config', 'node.field_test'); $expected = array('max_length' => 255); - $this->assertEqual($field->type, "text", "Field type is text."); - $this->assertEqual($field->status(), TRUE, "Status is TRUE"); - $this->assertEqual($field->settings, $expected, "Field type text settings are correct"); + $this->assertEqual($field_storage->type, "text", "Field type is text."); + $this->assertEqual($field_storage->status(), TRUE, "Status is TRUE"); + $this->assertEqual($field_storage->settings, $expected, "Field type text settings are correct"); // Integer field. - $field = entity_load('field_config', 'node.field_test_two'); - $this->assertEqual($field->type, "integer", "Field type is integer."); + $field_storage = entity_load('field_storage_config', 'node.field_test_two'); + $this->assertEqual($field_storage->type, "integer", "Field type is integer."); // Float field. - $field = entity_load('field_config', 'node.field_test_three'); - $this->assertEqual($field->type, "decimal", "Field type is decimal."); + $field_storage = entity_load('field_storage_config', 'node.field_test_three'); + $this->assertEqual($field_storage->type, "decimal", "Field type is decimal."); // Link field. - $field = entity_load('field_config', 'node.field_test_link'); - $this->assertEqual($field->type, "link", "Field type is link."); + $field_storage = entity_load('field_storage_config', 'node.field_test_link'); + $this->assertEqual($field_storage->type, "link", "Field type is link."); // File field. - $field = entity_load('field_config', 'node.field_test_filefield'); - $this->assertEqual($field->type, "file", "Field type is file."); + $field_storage = entity_load('field_storage_config', 'node.field_test_filefield'); + $this->assertEqual($field_storage->type, "file", "Field type is file."); - /** @var \Drupal\field\Entity\FieldConfig $field */ - $field = entity_load('field_config', 'node.field_test_imagefield'); - $this->assertEqual($field->type, "image", "Field type is image."); - $settings = $field->getSettings(); + $field_storage = entity_load('field_storage_config', 'node.field_test_imagefield'); + $this->assertEqual($field_storage->type, "image", "Field type is image."); + $settings = $field_storage->getSettings(); $this->assertEqual($settings['column_groups']['alt']['label'], 'Test alt'); $this->assertEqual($settings['column_groups']['title']['label'], 'Test title'); $this->assertEqual($settings['target_type'], 'file'); @@ -78,13 +78,13 @@ public function testFields() { $this->assertEqual(array_filter($settings['default_image']), array()); // Phone field. - $field = entity_load('field_config', 'node.field_test_phone'); - $this->assertEqual($field->type, "telephone", "Field type is telephone."); + $field_storage = entity_load('field_storage_config', 'node.field_test_phone'); + $this->assertEqual($field_storage->type, "telephone", "Field type is telephone."); // Date field. - $field = entity_load('field_config', 'node.field_test_datetime'); - $this->assertEqual($field->type, "datetime", "Field type is datetime."); - $this->assertEqual($field->status(), FALSE, "Status is FALSE"); + $field_storage = entity_load('field_storage_config', 'node.field_test_datetime'); + $this->assertEqual($field_storage->type, "datetime", "Field type is datetime."); + $this->assertEqual($field_storage->status(), FALSE, "Status is FALSE"); } } diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateProfileValuesTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateProfileValuesTest.php index 7837075034ae..158cfc97ad6b 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateProfileValuesTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateProfileValuesTest.php @@ -40,22 +40,22 @@ class MigrateProfileValuesTest extends MigrateDrupalTestBase { protected function setUp() { parent::setUp(); // Create some fields so the data gets stored. - entity_create('field_config', array( + entity_create('field_storage_config', array( 'entity_type' => 'user', 'name' => 'profile_color', 'type' => 'text', ))->save(); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'entity_type' => 'user', 'name' => 'profile_biography', 'type' => 'text_long', ))->save(); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'entity_type' => 'user', 'name' => 'profile_sell_address', 'type' => 'boolean', ))->save(); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'entity_type' => 'user', 'name' => 'profile_sold_to', 'type' => 'list_text', @@ -66,23 +66,23 @@ protected function setUp() { ) ) ))->save(); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'entity_type' => 'user', 'name' => 'profile_bands', 'type' => 'text', 'cardinality' => -1, ))->save(); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'entity_type' => 'user', 'name' => 'profile_blog', 'type' => 'link', ))->save(); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'entity_type' => 'user', 'name' => 'profile_birthdate', 'type' => 'datetime', ))->save(); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'entity_type' => 'user', 'name' => 'profile_love_migrations', 'type' => 'boolean', diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateTermNodeTestBase.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateTermNodeTestBase.php index 1d8cc9962060..47ea02e8381e 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateTermNodeTestBase.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateTermNodeTestBase.php @@ -31,7 +31,7 @@ protected function setUp() { $node_type = entity_create('node_type', array('type' => 'story')); $node_type->save(); foreach (array('vocabulary_1_i_0_', 'vocabulary_2_i_1_', 'vocabulary_3_i_2_') as $name) { - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => $name, 'entity_type' => 'node', 'type' => 'taxonomy_term_reference', diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateUploadBase.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateUploadBase.php index a1d25ba5543a..bbe19971f42f 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateUploadBase.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateUploadBase.php @@ -49,7 +49,7 @@ public function setUp() { $node_type->save(); // Add a file field. - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => 'upload', 'entity_type' => 'node', 'type' => 'file', diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateUploadFieldTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateUploadFieldTest.php index 380e7d2a51db..617f9e934ddb 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateUploadFieldTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateUploadFieldTest.php @@ -42,8 +42,8 @@ protected function setUp() { * Tests the Drupal 6 upload settings to Drupal 8 field migration. */ public function testUpload() { - $field = entity_load('field_config', 'node.upload'); - $this->assertEqual($field->id(), 'node.upload'); + $field_storage = entity_load('field_storage_config', 'node.upload'); + $this->assertEqual($field_storage->id(), 'node.upload'); $this->assertEqual(array('node', 'upload'), entity_load('migration', 'd6_upload_field')->getIdMap()->lookupDestinationID(array(''))); } diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateUploadInstanceTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateUploadInstanceTest.php index 91ee0ada71e9..708268bc51a4 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateUploadInstanceTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateUploadInstanceTest.php @@ -44,7 +44,7 @@ protected function setUp() { foreach (array('page', 'story') as $type) { entity_create('node_type', array('type' => $type))->save(); } - entity_create('field_config', array( + entity_create('field_storage_config', array( 'entity_type' => 'node', 'name' => 'upload', 'type' => 'file', diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateUserPictureFieldTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateUserPictureFieldTest.php index 025e6f800960..ca9fa3ce2100 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateUserPictureFieldTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateUserPictureFieldTest.php @@ -33,8 +33,8 @@ public function setUp() { * Test the user picture field migration. */ public function testUserPictureField() { - $field = entity_load('field_config', 'user.user_picture'); - $this->assertEqual($field->id(), 'user.user_picture'); + $field_storage = entity_load('field_storage_config', 'user.user_picture'); + $this->assertEqual($field_storage->id(), 'user.user_picture'); $this->assertEqual(array('user', 'user_picture'), entity_load('migration', 'd6_user_picture_field')->getIdMap()->lookupDestinationID(array(''))); } diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateUserPictureInstanceTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateUserPictureInstanceTest.php index ee1a69bc2af2..6e0097847f00 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateUserPictureInstanceTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateUserPictureInstanceTest.php @@ -36,7 +36,7 @@ public function setUp() { ), ); $this->prepareIdMappings($id_mappings); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'entity_type' => 'user', 'name' => 'user_picture', 'type' => 'image', diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateUserProfileEntityDisplayTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateUserProfileEntityDisplayTest.php index e0b03a1fc151..8666cfa03043 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateUserProfileEntityDisplayTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateUserProfileEntityDisplayTest.php @@ -32,43 +32,43 @@ protected function setUp() { parent::setUp(); // Create some fields so the data gets stored. - entity_create('field_config', array( + entity_create('field_storage_config', array( 'entity_type' => 'user', 'name' => 'profile_color', 'type' => 'text', ))->save(); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'entity_type' => 'user', 'name' => 'profile_biography', 'type' => 'text_long', ))->save(); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'entity_type' => 'user', 'name' => 'profile_sell_address', 'type' => 'boolean', ))->save(); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'entity_type' => 'user', 'name' => 'profile_sold_to', 'type' => 'list_text', ))->save(); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'entity_type' => 'user', 'name' => 'profile_bands', 'type' => 'text', 'cardinality' => -1, ))->save(); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'entity_type' => 'user', 'name' => 'profile_blog', 'type' => 'link', ))->save(); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'entity_type' => 'user', 'name' => 'profile_birthdate', 'type' => 'datetime', ))->save(); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'entity_type' => 'user', 'name' => 'profile_love_migrations', 'type' => 'boolean', diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateUserProfileEntityFormDisplayTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateUserProfileEntityFormDisplayTest.php index ed70bc3cea9e..82503d638f47 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateUserProfileEntityFormDisplayTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateUserProfileEntityFormDisplayTest.php @@ -27,43 +27,43 @@ protected function setUp() { parent::setUp(); // Create some fields so the data gets stored. - entity_create('field_config', array( + entity_create('field_storage_config', array( 'entity_type' => 'user', 'name' => 'profile_color', 'type' => 'text', ))->save(); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'entity_type' => 'user', 'name' => 'profile_biography', 'type' => 'text_long', ))->save(); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'entity_type' => 'user', 'name' => 'profile_sell_address', 'type' => 'boolean', ))->save(); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'entity_type' => 'user', 'name' => 'profile_sold_to', 'type' => 'list_text', ))->save(); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'entity_type' => 'user', 'name' => 'profile_bands', 'type' => 'text', 'cardinality' => -1, ))->save(); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'entity_type' => 'user', 'name' => 'profile_blog', 'type' => 'link', ))->save(); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'entity_type' => 'user', 'name' => 'profile_birthdate', 'type' => 'datetime', ))->save(); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'entity_type' => 'user', 'name' => 'profile_love_migrations', 'type' => 'boolean', diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateUserProfileFieldInstanceTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateUserProfileFieldInstanceTest.php index eef81d72477d..f1687b4b8a08 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateUserProfileFieldInstanceTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateUserProfileFieldInstanceTest.php @@ -106,7 +106,7 @@ protected function createFields() { 'profile_love_migrations' => 'boolean', ); foreach ($fields as $name => $type) { - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => $name, 'entity_type' => 'user', 'type' => $type, diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateUserProfileFieldTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateUserProfileFieldTest.php index 557acc5b4b65..94f479de5805 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateUserProfileFieldTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateUserProfileFieldTest.php @@ -39,21 +39,22 @@ protected function setUp() { */ public function testUserProfileFields() { // Migrated a text field. - $field = entity_load('field_config', 'user.profile_color'); - $this->assertEqual($field->type, 'text', 'Field type is text.'); - $this->assertEqual($field->cardinality, 1, 'Text field has correct cardinality'); + $field_storage = entity_load('field_storage_config', 'user.profile_color'); + $this->assertEqual($field_storage->type, 'text', 'Field type is text.'); + $this->assertEqual($field_storage->cardinality, 1, 'Text field has correct cardinality'); // Migrated a textarea. - $field = entity_load('field_config', 'user.profile_biography'); - $this->assertEqual($field->type, 'text_long', 'Field type is text_long.'); + $field_storage = entity_load('field_storage_config', 'user.profile_biography'); + $this->assertEqual($field_storage->type, 'text_long', 'Field type is text_long.'); // Migrated checkbox field. - $field = entity_load('field_config', 'user.profile_sell_address'); - $this->assertEqual($field->type, 'boolean', 'Field type is boolean.'); + $field_storage = entity_load('field_storage_config', 'user.profile_sell_address'); + $this->assertEqual($field_storage->type, 'boolean', 'Field type is boolean.'); // Migrated selection field. - $field = entity_load('field_config', 'user.profile_sold_to'); - $settings = $field->getSettings(); + $field_storage = entity_load('field_storage_config', 'user.profile_sold_to'); + $this->assertEqual($field_storage->type, 'list_text', 'Field type is list_text.'); + $settings = $field_storage->getSettings(); $this->assertEqual($settings['allowed_values'], array( 'Pill spammers' => 'Pill spammers', 'Spammers' => 'Spammers', @@ -61,23 +62,23 @@ public function testUserProfileFields() { 'Faithful servant' => 'Faithful servant', 'Anonymous donor' => 'Anonymous donor', )); - $this->assertEqual($field->type, 'list_text', 'Field type is list_text.'); + $this->assertEqual($field_storage->type, 'list_text', 'Field type is list_text.'); // Migrated list field. - $field = entity_load('field_config', 'user.profile_bands'); - $this->assertEqual($field->type, 'text', 'Field type is text.'); - $this->assertEqual($field->cardinality, -1, 'List field has correct cardinality'); + $field_storage = entity_load('field_storage_config', 'user.profile_bands'); + $this->assertEqual($field_storage->type, 'text', 'Field type is text.'); + $this->assertEqual($field_storage->cardinality, -1, 'List field has correct cardinality'); /* // Migrated URL field. - $field = entity_load('field_config', 'user.profile_blog'); - $this->assertEqual($field->type, 'link', 'Field type is link.'); + $field_storage = entity_load('field_storage_config', 'user.profile_blog'); + $this->assertEqual($field_storage->type, 'link', 'Field type is link.'); */ // Migrated date field. - $field = entity_load('field_config', 'user.profile_birthdate'); - $this->assertEqual($field->type, 'datetime', 'Field type is datetime.'); - $this->assertEqual($field->settings['datetime_type'], 'date'); + $field_storage = entity_load('field_storage_config', 'user.profile_birthdate'); + $this->assertEqual($field_storage->type, 'datetime', 'Field type is datetime.'); + $this->assertEqual($field_storage->settings['datetime_type'], 'date'); } } diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateUserTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateUserTest.php index 9dc19d144b47..8bdbca1ee904 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateUserTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateUserTest.php @@ -38,7 +38,7 @@ class MigrateUserTest extends MigrateDrupalTestBase { protected function setUp() { parent::setUp(); // Create the user profile field and instance. - entity_create('field_config', array( + entity_create('field_storage_config', array( 'entity_type' => 'user', 'name' => 'user_picture', 'type' => 'image', diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateVocabularyEntityDisplayTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateVocabularyEntityDisplayTest.php index b829e526eaf0..475e26dfc0ef 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateVocabularyEntityDisplayTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateVocabularyEntityDisplayTest.php @@ -30,7 +30,7 @@ class MigrateVocabularyEntityDisplayTest extends MigrateDrupalTestBase { protected function setUp() { parent::setUp(); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'entity_type' => 'node', 'name' => 'tags', 'type' => 'taxonomy_term_reference', diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateVocabularyEntityFormDisplayTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateVocabularyEntityFormDisplayTest.php index aad01868fa69..25a7c816e34f 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateVocabularyEntityFormDisplayTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateVocabularyEntityFormDisplayTest.php @@ -30,7 +30,7 @@ class MigrateVocabularyEntityFormDisplayTest extends MigrateDrupalTestBase { protected function setUp() { parent::setUp(); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'entity_type' => 'node', 'name' => 'tags', 'type' => 'taxonomy_term_reference', diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateVocabularyFieldInstanceTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateVocabularyFieldInstanceTest.php index 9001af0104ac..25a485a07b9f 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateVocabularyFieldInstanceTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateVocabularyFieldInstanceTest.php @@ -53,7 +53,7 @@ protected function setUp() { 'vid' => 'tags', ))->save(); // Create the field itself. - entity_create('field_config', array( + entity_create('field_storage_config', array( 'entity_type' => 'node', 'name' => 'tags', 'type' => 'taxonomy_term_reference', diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateVocabularyFieldTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateVocabularyFieldTest.php index ff15c540bd98..d593f97edd50 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateVocabularyFieldTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateVocabularyFieldTest.php @@ -58,10 +58,10 @@ protected function setUp() { */ public function testVocabularyField() { // Test that the field exists. - $field_id = 'node.tags'; - $field = entity_load('field_config', $field_id); - $this->assertEqual($field->id(), $field_id); - $settings = $field->getSettings(); + $field_storage_id = 'node.tags'; + $field_storage = entity_load('field_storage_config', $field_storage_id); + $this->assertEqual($field_storage->id(), $field_storage_id); + $settings = $field_storage->getSettings(); $this->assertEqual('tags', $settings['allowed_values'][0]['vocabulary'], "Vocabulary has correct settings."); $this->assertEqual(array('node', 'tags'), entity_load('migration', 'd6_vocabulary_field')->getIdMap()->lookupDestinationID(array(4)), "Test IdMap"); diff --git a/core/modules/node/node.module b/core/modules/node/node.module index f23559e533bc..262e07bb97ed 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -16,7 +16,7 @@ use Symfony\Component\HttpFoundation\Response; use Drupal\Core\Database\Query\AlterableInterface; use Drupal\Core\Database\Query\SelectInterface; -use Drupal\field\Entity\FieldConfig; +use Drupal\field\Entity\FieldStorageConfig; use Drupal\field\Entity\FieldInstanceConfig; use Drupal\node\Entity\Node; use Drupal\node\Entity\NodeType; @@ -357,19 +357,19 @@ function node_type_load($name) { */ function node_add_body_field(NodeTypeInterface $type, $label = 'Body') { // Add or remove the body field, as needed. - $field = FieldConfig::loadByName('node', 'body'); + $field_storage = FieldStorageConfig::loadByName('node', 'body'); $instance = FieldInstanceConfig::loadByName('node', $type->id(), 'body'); - if (empty($field)) { - $field = entity_create('field_config', array( + if (empty($field_storage)) { + $field_storage = entity_create('field_storage_config', array( 'name' => 'body', 'entity_type' => 'node', 'type' => 'text_with_summary', )); - $field->save(); + $field_storage->save(); } if (empty($instance)) { $instance = entity_create('field_instance_config', array( - 'field' => $field, + 'field_storage' => $field_storage, 'bundle' => $type->id(), 'label' => $label, 'settings' => array('display_summary' => TRUE), diff --git a/core/modules/node/src/Tests/MultiStepNodeFormBasicOptionsTest.php b/core/modules/node/src/Tests/MultiStepNodeFormBasicOptionsTest.php index 3baab9155b84..502692080eb7 100644 --- a/core/modules/node/src/Tests/MultiStepNodeFormBasicOptionsTest.php +++ b/core/modules/node/src/Tests/MultiStepNodeFormBasicOptionsTest.php @@ -31,7 +31,7 @@ function testMultiStepNodeFormBasicOptions() { // Create an unlimited cardinality field. $this->field_name = drupal_strtolower($this->randomName()); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => $this->field_name, 'entity_type' => 'node', 'type' => 'text', diff --git a/core/modules/node/src/Tests/NodeAccessFieldTest.php b/core/modules/node/src/Tests/NodeAccessFieldTest.php index 2815c127c3f5..04adb72e52c1 100644 --- a/core/modules/node/src/Tests/NodeAccessFieldTest.php +++ b/core/modules/node/src/Tests/NodeAccessFieldTest.php @@ -53,7 +53,7 @@ public function setUp() { // Add a custom field to the page content type. $this->field_name = drupal_strtolower($this->randomName() . '_field_name'); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => $this->field_name, 'entity_type' => 'node', 'type' => 'text' diff --git a/core/modules/node/src/Tests/NodeAccessLanguageAwareCombinationTest.php b/core/modules/node/src/Tests/NodeAccessLanguageAwareCombinationTest.php index e668c0bc2e70..cd78a809f333 100644 --- a/core/modules/node/src/Tests/NodeAccessLanguageAwareCombinationTest.php +++ b/core/modules/node/src/Tests/NodeAccessLanguageAwareCombinationTest.php @@ -52,7 +52,7 @@ public function setUp() { // Create the 'private' field, which allows the node to be marked as private // (restricted access) in a given translation. - $field_private = entity_create('field_config', array( + $field_storage = entity_create('field_storage_config', array( 'name' => 'field_private', 'entity_type' => 'node', 'type' => 'boolean', @@ -63,10 +63,10 @@ public function setUp() { 'off_label' => 'Not private', ), )); - $field_private->save(); + $field_storage->save(); entity_create('field_instance_config', array( - 'field' => $field_private, + 'field_storage' => $field_storage, 'bundle' => 'page', 'widget' => array( 'type' => 'options_buttons', diff --git a/core/modules/node/src/Tests/NodeAccessLanguageAwareTest.php b/core/modules/node/src/Tests/NodeAccessLanguageAwareTest.php index a15a04a3f71a..7a4e3e2fe88f 100644 --- a/core/modules/node/src/Tests/NodeAccessLanguageAwareTest.php +++ b/core/modules/node/src/Tests/NodeAccessLanguageAwareTest.php @@ -43,7 +43,7 @@ public function setUp() { // Create the 'private' field, which allows the node to be marked as private // (restricted access) in a given translation. - $field_private = entity_create('field_config', array( + $field_storage = entity_create('field_storage_config', array( 'name' => 'field_private', 'entity_type' => 'node', 'type' => 'boolean', @@ -54,10 +54,10 @@ public function setUp() { 'off_label' => 'Not private', ), )); - $field_private->save(); + $field_storage->save(); entity_create('field_instance_config', array( - 'field' => $field_private, + 'field_storage' => $field_storage, 'bundle' => 'page', 'widget' => array( 'type' => 'options_buttons', diff --git a/core/modules/node/src/Tests/NodeFieldMultilingualTest.php b/core/modules/node/src/Tests/NodeFieldMultilingualTest.php index b28574bb7cd8..80edda30c8ca 100644 --- a/core/modules/node/src/Tests/NodeFieldMultilingualTest.php +++ b/core/modules/node/src/Tests/NodeFieldMultilingualTest.php @@ -7,7 +7,7 @@ namespace Drupal\node\Tests; -use Drupal\field\Entity\FieldConfig; +use Drupal\field\Entity\FieldStorageConfig; use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrl; use Drupal\simpletest\WebTestBase; use Drupal\Core\Language\Language; @@ -56,9 +56,9 @@ function setUp() { $this->assertRaw(t('The content type %type has been updated.', array('%type' => 'Basic page')), 'Basic page content type has been updated.'); // Make node body translatable. - $field = FieldConfig::loadByName('node', 'body'); - $field->translatable = TRUE; - $field->save(); + $field_storage = FieldStorageConfig::loadByName('node', 'body'); + $field_storage->translatable = TRUE; + $field_storage->save(); } /** diff --git a/core/modules/node/src/Tests/PagePreviewTest.php b/core/modules/node/src/Tests/PagePreviewTest.php index b40ea57ecf01..868e752e981e 100644 --- a/core/modules/node/src/Tests/PagePreviewTest.php +++ b/core/modules/node/src/Tests/PagePreviewTest.php @@ -61,7 +61,7 @@ function setUp() { // Set up a field and instance. $this->field_name = drupal_strtolower($this->randomName()); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => $this->field_name, 'entity_type' => 'node', 'type' => 'taxonomy_term_reference', diff --git a/core/modules/node/tests/modules/node_access_test/node_access_test.module b/core/modules/node/tests/modules/node_access_test/node_access_test.module index 3d2c1ab4d219..797cf25fbbbc 100644 --- a/core/modules/node/tests/modules/node_access_test/node_access_test.module +++ b/core/modules/node/tests/modules/node_access_test/node_access_test.module @@ -19,7 +19,7 @@ * @see \Drupal\node\Tests\NodeAccessBaseTableTest */ -use Drupal\field\Entity\FieldConfig; +use Drupal\field\Entity\FieldStorageConfig; use Drupal\field\Entity\FieldInstanceConfig; use Drupal\node\NodeTypeInterface; use Drupal\node\NodeInterface; @@ -134,12 +134,12 @@ function node_access_test_permission() { * A node type entity. */ function node_access_test_add_field(NodeTypeInterface $type) { - $field = FieldConfig::create(array( + $field_storage = FieldStorageConfig::create(array( 'name' => 'private', 'entity_type' => 'node', 'type' => 'integer', )); - $field->save(); + $field_storage->save(); $instance = FieldInstanceConfig::create(array( 'field_name' => 'private', 'entity_type' => 'node', diff --git a/core/modules/options/options.module b/core/modules/options/options.module index d9a1b2487b9b..90ddc5a963f3 100644 --- a/core/modules/options/options.module +++ b/core/modules/options/options.module @@ -6,11 +6,10 @@ */ use Drupal\Core\Entity\EntityInterface; +use Drupal\Core\Entity\Exception\FieldStorageDefinitionUpdateForbiddenException; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Routing\RouteMatchInterface; -use Drupal\Core\Entity\Exception\FieldStorageDefinitionUpdateForbiddenException; -use Drupal\field\FieldConfigInterface; -use Drupal\field\FieldConfigUpdateForbiddenException; +use Drupal\field\FieldStorageConfigInterface; /** * Implements hook_help(). @@ -35,16 +34,16 @@ function options_help($route_name, RouteMatchInterface $route_match) { } /** - * Implements hook_ENTITY_TYPE_update() for 'field_config'. + * Implements hook_ENTITY_TYPE_update() for 'field_storage_config'. */ -function options_field_config_update(FieldConfigInterface $field) { +function options_field_storage_config_update(FieldStorageConfigInterface $field_storage) { drupal_static_reset('options_allowed_values'); } /** - * Implements hook_ENTITY_TYPE_delete() for 'field_config'. + * Implements hook_ENTITY_TYPE_delete() for 'field_storage_config'. */ -function options_field_config_delete(FieldConfigInterface $field) { +function options_field_storage_config_delete(FieldStorageConfigInterface $field_storage) { drupal_static_reset('options_allowed_values'); } @@ -92,16 +91,16 @@ function options_allowed_values(FieldDefinitionInterface $field_definition, Enti } /** - * Implements hook_field_config_update_forbid(). + * Implements hook_field_storage_config_update_forbid(). */ -function options_field_config_update_forbid(FieldConfigInterface $field, FieldConfigInterface $prior_field) { - if ($field->module == 'options' && $field->hasData()) { +function options_field_storage_config_update_forbid(FieldStorageConfigInterface $field_storage, FieldStorageConfigInterface $prior_field_storage) { + if ($field_storage->module == 'options' && $field_storage->hasData()) { // Forbid any update that removes allowed values with actual data. - $allowed_values = $field->getSetting('allowed_values'); - $prior_allowed_values = $prior_field->getSetting('allowed_values'); + $allowed_values = $field_storage->getSetting('allowed_values'); + $prior_allowed_values = $prior_field_storage->getSetting('allowed_values'); $lost_keys = array_diff(array_keys($prior_allowed_values), array_keys($allowed_values)); - if (_options_values_in_use($field->entity_type, $field->getName(), $lost_keys)) { - throw new FieldStorageDefinitionUpdateForbiddenException(t('A list field (@field_name) with existing data cannot have its keys changed.', array('@field_name' => $field->getName()))); + if (_options_values_in_use($field_storage->entity_type, $field_storage->getName(), $lost_keys)) { + throw new FieldStorageDefinitionUpdateForbiddenException(t('A list field (@field_name) with existing data cannot have its keys changed.', array('@field_name' => $field_storage->getName()))); } } } diff --git a/core/modules/options/src/Tests/OptionsDynamicValuesTestBase.php b/core/modules/options/src/Tests/OptionsDynamicValuesTestBase.php index b01e582e9b33..c5986d065e07 100644 --- a/core/modules/options/src/Tests/OptionsDynamicValuesTestBase.php +++ b/core/modules/options/src/Tests/OptionsDynamicValuesTestBase.php @@ -32,7 +32,7 @@ function setUp() { parent::setUp(); $this->field_name = 'test_options'; - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => $this->field_name, 'entity_type' => 'entity_test_rev', 'type' => 'list_text', diff --git a/core/modules/options/src/Tests/OptionsFieldTest.php b/core/modules/options/src/Tests/OptionsFieldTest.php index 925d5ce6ac6b..883232655286 100644 --- a/core/modules/options/src/Tests/OptionsFieldTest.php +++ b/core/modules/options/src/Tests/OptionsFieldTest.php @@ -39,21 +39,21 @@ function testUpdateAllowedValues() { $entity = entity_create('entity_test'); $entity->{$this->fieldName}->value = 1; $entity->save(); - $this->field->settings['allowed_values'] = array(2 => 'Two'); + $this->fieldStorage->settings['allowed_values'] = array(2 => 'Two'); try { - $this->field->save(); - $this->fail(t('Cannot update a list field to not include keys with existing data.')); + $this->fieldStorage->save(); + $this->fail(t('Cannot update a list field storage to not include keys with existing data.')); } catch (FieldStorageDefinitionUpdateForbiddenException $e) { - $this->pass(t('Cannot update a list field to not include keys with existing data.')); + $this->pass(t('Cannot update a list field storage to not include keys with existing data.')); } // Empty the value, so that we can actually remove the option. unset($entity->{$this->fieldName}); $entity->save(); // Removed options do not appear. - $this->field->settings['allowed_values'] = array(2 => 'Two'); - $this->field->save(); + $this->fieldStorage->settings['allowed_values'] = array(2 => 'Two'); + $this->fieldStorage->save(); $entity = entity_create('entity_test'); $form = \Drupal::service('entity.form_builder')->getForm($entity); $this->assertTrue(empty($form[$this->fieldName]['widget'][1]), 'Option 1 does not exist'); @@ -61,8 +61,8 @@ function testUpdateAllowedValues() { $this->assertTrue(empty($form[$this->fieldName]['widget'][3]), 'Option 3 does not exist'); // Completely new options appear. - $this->field->settings['allowed_values'] = array(10 => 'Update', 20 => 'Twenty'); - $this->field->save(); + $this->fieldStorage->settings['allowed_values'] = array(10 => 'Update', 20 => 'Twenty'); + $this->fieldStorage->save(); // The entity holds an outdated field object with the old allowed values // setting, so we need to reintialize the entity object. $entity = entity_create('entity_test'); @@ -74,8 +74,8 @@ function testUpdateAllowedValues() { $this->assertTrue(!empty($form[$this->fieldName]['widget'][20]), 'Option 20 exists'); // Options are reset when a new field with the same name is created. - $this->field->delete(); - entity_create('field_config', $this->fieldDefinition)->save(); + $this->fieldStorage->delete(); + entity_create('field_storage_config', $this->fieldStorageDefinition)->save(); entity_create('field_instance_config', array( 'field_name' => $this->fieldName, 'entity_type' => 'entity_test', diff --git a/core/modules/options/src/Tests/OptionsFieldUITest.php b/core/modules/options/src/Tests/OptionsFieldUITest.php index c69e797a049f..d6b70097b2d9 100644 --- a/core/modules/options/src/Tests/OptionsFieldUITest.php +++ b/core/modules/options/src/Tests/OptionsFieldUITest.php @@ -7,7 +7,7 @@ namespace Drupal\options\Tests; -use Drupal\field\Entity\FieldConfig; +use Drupal\field\Entity\FieldStorageConfig; use Drupal\field\Tests\FieldTestBase; /** @@ -222,7 +222,7 @@ function testOptionsTrimmedValuesText() { */ protected function createOptionsField($type) { // Create a test field and instance. - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => $this->field_name, 'entity_type' => 'node', 'type' => $type, @@ -235,7 +235,7 @@ protected function createOptionsField($type) { entity_get_form_display('node', $this->type, 'default')->setComponent($this->field_name)->save(); - $this->admin_path = 'admin/structure/types/manage/' . $this->type . '/fields/node.' . $this->type . '.' . $this->field_name . '/field'; + $this->admin_path = 'admin/structure/types/manage/' . $this->type . '/fields/node.' . $this->type . '.' . $this->field_name . '/storage'; } /** @@ -258,8 +258,8 @@ function assertAllowedValuesInput($input_string, $result, $message) { $this->assertText($result, $message); } else { - $field = FieldConfig::loadByName('node', $this->field_name); - $this->assertIdentical($field->getSetting('allowed_values'), $result, $message); + $field_storage = FieldStorageConfig::loadByName('node', $this->field_name); + $this->assertIdentical($field_storage->getSetting('allowed_values'), $result, $message); } } diff --git a/core/modules/options/src/Tests/OptionsFieldUnitTestBase.php b/core/modules/options/src/Tests/OptionsFieldUnitTestBase.php index 272e0268892f..ef8eb066eb49 100644 --- a/core/modules/options/src/Tests/OptionsFieldUnitTestBase.php +++ b/core/modules/options/src/Tests/OptionsFieldUnitTestBase.php @@ -30,18 +30,18 @@ abstract class OptionsFieldUnitTestBase extends FieldUnitTestBase { protected $fieldName = 'test_options'; /** - * The field definition used to created the field entity. + * The field storage definition used to created the field storage. * * @var array */ - protected $fieldDefinition; + protected $fieldStorageDefinition; /** - * The list field used in the test. + * The list field storage used in the test. * - * @var \Drupal\field\Entity\FieldConfig + * @var \Drupal\field\Entity\FieldStorageConfig */ - protected $field; + protected $fieldStorage; /** * The list field instance used in the test. @@ -57,7 +57,7 @@ public function setUp() { parent::setUp(); $this->installSchema('system', array('router')); - $this->fieldDefinition = array( + $this->fieldStorageDefinition = array( 'name' => $this->fieldName, 'entity_type' => 'entity_test', 'type' => 'list_integer', @@ -66,14 +66,13 @@ public function setUp() { 'allowed_values' => array(1 => 'One', 2 => 'Two', 3 => 'Three'), ), ); - $this->field = entity_create('field_config', $this->fieldDefinition); - $this->field->save(); + $this->fieldStorage = entity_create('field_storage_config', $this->fieldStorageDefinition); + $this->fieldStorage->save(); - $instance = array( - 'field' => $this->field, + $this->instance = entity_create('field_instance_config', array( + 'field_storage' => $this->fieldStorage, 'bundle' => 'entity_test', - ); - $this->instance = entity_create('field_instance_config', $instance); + )); $this->instance->save(); entity_get_form_display('entity_test', 'entity_test', 'default') diff --git a/core/modules/options/src/Tests/OptionsWidgetsTest.php b/core/modules/options/src/Tests/OptionsWidgetsTest.php index 4f809fcaa9fa..28cae40dba4d 100644 --- a/core/modules/options/src/Tests/OptionsWidgetsTest.php +++ b/core/modules/options/src/Tests/OptionsWidgetsTest.php @@ -24,16 +24,16 @@ class OptionsWidgetsTest extends FieldTestBase { public static $modules = array('node', 'options', 'entity_test', 'options_test', 'taxonomy', 'field_ui'); /** - * A field with cardinality 1 to use in this test class. + * A field storage with cardinality 1 to use in this test class. * - * @var \Drupal\field\Entity\FieldConfig + * @var \Drupal\field\Entity\FieldStorageConfig */ protected $card_1; /** - * A field with cardinality 2 to use in this test class. + * A field storage with cardinality 2 to use in this test class. * - * @var \Drupal\field\Entity\FieldConfig + * @var \Drupal\field\Entity\FieldStorageConfig */ protected $card_2; @@ -48,8 +48,8 @@ class OptionsWidgetsTest extends FieldTestBase { function setUp() { parent::setUp(); - // Field with cardinality 1. - $this->card_1 = entity_create('field_config', array( + // Field storage with cardinality 1. + $this->card_1 = entity_create('field_storage_config', array( 'name' => 'card_1', 'entity_type' => 'entity_test', 'type' => 'list_integer', @@ -68,8 +68,8 @@ function setUp() { )); $this->card_1->save(); - // Field with cardinality 2. - $this->card_2 = entity_create('field_config', array( + // Field storage with cardinality 2. + $this->card_2 = entity_create('field_storage_config', array( 'name' => 'card_2', 'entity_type' => 'entity_test', 'type' => 'list_integer', @@ -97,7 +97,7 @@ function setUp() { function testRadioButtons() { // Create an instance of the 'single value' field. $instance = entity_create('field_instance_config', array( - 'field' => $this->card_1, + 'field_storage' => $this->card_1, 'bundle' => 'entity_test', )); $instance->save(); @@ -154,7 +154,7 @@ function testRadioButtons() { function testCheckBoxes() { // Create an instance of the 'multiple values' field. $instance = entity_create('field_instance_config', array( - 'field' => $this->card_2, + 'field_storage' => $this->card_2, 'bundle' => 'entity_test', )); $instance->save(); @@ -243,7 +243,7 @@ function testCheckBoxes() { function testSelectListSingle() { // Create an instance of the 'single value' field. $instance = entity_create('field_instance_config', array( - 'field' => $this->card_1, + 'field_storage' => $this->card_1, 'bundle' => 'entity_test', 'required' => TRUE, )); @@ -343,7 +343,7 @@ function testSelectListSingle() { function testSelectListMultiple() { // Create an instance of the 'multiple values' field. $instance = entity_create('field_instance_config', array( - 'field' => $this->card_2, + 'field_storage' => $this->card_2, 'bundle' => 'entity_test', )); $instance->save(); diff --git a/core/modules/path/src/Tests/PathLanguageTest.php b/core/modules/path/src/Tests/PathLanguageTest.php index 6f241d750cee..2f3ba9a43825 100644 --- a/core/modules/path/src/Tests/PathLanguageTest.php +++ b/core/modules/path/src/Tests/PathLanguageTest.php @@ -7,8 +7,6 @@ namespace Drupal\path\Tests; -use Drupal\field\Entity\FieldConfig; - /** * Confirm that paths work with translated nodes. * diff --git a/core/modules/quickedit/src/Tests/EditorSelectionTest.php b/core/modules/quickedit/src/Tests/EditorSelectionTest.php index 4faa33527792..e29cd3fb8f6f 100644 --- a/core/modules/quickedit/src/Tests/EditorSelectionTest.php +++ b/core/modules/quickedit/src/Tests/EditorSelectionTest.php @@ -87,8 +87,8 @@ public function testText() { $this->assertEqual('plain_text', $this->getSelectedEditor($this->entity->id(), $field_name), "Without text processing again, cardinality 1, the 'plain_text' editor is selected."); // Editor selection without text processing, cardinality >1 - $this->field_text_field->cardinality = 2; - $this->field_text_field->save(); + $this->field_text_field_storage->cardinality = 2; + $this->field_text_field_storage->save(); $this->assertEqual('form', $this->getSelectedEditor($this->entity->id(), $field_name), "Without text processing, cardinality >1, the 'form' editor is selected."); // Editor selection with text processing, cardinality >1 @@ -136,8 +136,8 @@ public function testTextWysiwyg() { $this->assertEqual('wysiwyg', $this->getSelectedEditor($this->entity->id(), $field_name), "With cardinality 1, and the full_html text format, the 'wysiwyg' editor is selected."); // Editor selection with text processing, cardinality >1 - $this->field_textarea_field->cardinality = 2; - $this->field_textarea_field->save(); + $this->field_textarea_field_storage->cardinality = 2; + $this->field_textarea_field_storage->save(); $this->assertEqual('form', $this->getSelectedEditor($this->entity->id(), $field_name), "With cardinality >1, and both items using the full_html text format, the 'form' editor is selected."); } @@ -167,8 +167,8 @@ public function testNumber() { $this->assertEqual('form', $this->getSelectedEditor($this->entity->id(), $field_name), "With cardinality 1, the 'form' editor is selected."); // Editor selection with cardinality >1. - $this->field_nr_field->cardinality = 2; - $this->field_nr_field->save(); + $this->field_nr_field_storage->cardinality = 2; + $this->field_nr_field_storage->save(); $this->assertEqual('form', $this->getSelectedEditor($this->entity->id(), $field_name), "With cardinality >1, the 'form' editor is selected."); } diff --git a/core/modules/quickedit/src/Tests/QuickEditAutocompleteTermTest.php b/core/modules/quickedit/src/Tests/QuickEditAutocompleteTermTest.php index 94b493fa2b92..e4bdbd65d341 100644 --- a/core/modules/quickedit/src/Tests/QuickEditAutocompleteTermTest.php +++ b/core/modules/quickedit/src/Tests/QuickEditAutocompleteTermTest.php @@ -74,7 +74,7 @@ protected function setUp() { )); $this->vocabulary->save(); $this->field_name = 'field_' . $this->vocabulary->id(); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => $this->field_name, 'entity_type' => 'node', 'type' => 'taxonomy_term_reference', @@ -89,7 +89,7 @@ protected function setUp() { ), ), ))->save(); - $instance = entity_create('field_instance_config', array( + entity_create('field_instance_config', array( 'field_name' => $this->field_name, 'entity_type' => 'node', 'label' => 'Tags', diff --git a/core/modules/quickedit/src/Tests/QuickEditTestBase.php b/core/modules/quickedit/src/Tests/QuickEditTestBase.php index 08c1a86f530b..ec4d025e9d71 100644 --- a/core/modules/quickedit/src/Tests/QuickEditTestBase.php +++ b/core/modules/quickedit/src/Tests/QuickEditTestBase.php @@ -53,18 +53,18 @@ protected function setUp() { * The formatter settings. */ public function createFieldWithInstance($field_name, $type, $cardinality, $label, $instance_settings, $widget_type, $widget_settings, $formatter_type, $formatter_settings) { - $field = $field_name . '_field'; - $this->$field = entity_create('field_config', array( + $field_storage = $field_name . '_field_storage'; + $this->$field_storage = entity_create('field_storage_config', array( 'name' => $field_name, 'entity_type' => 'entity_test', 'type' => $type, 'cardinality' => $cardinality, )); - $this->$field->save(); + $this->$field_storage->save(); $instance = $field_name . '_instance'; $this->$instance = entity_create('field_instance_config', array( - 'field' => $this->$field, + 'field_storage' => $this->$field_storage, 'bundle' => 'entity_test', 'label' => $label, 'description' => $label, diff --git a/core/modules/quickedit/tests/src/Access/EditEntityFieldAccessCheckTest.php b/core/modules/quickedit/tests/src/Access/EditEntityFieldAccessCheckTest.php index f30630dcd3bd..5a97dd27095c 100644 --- a/core/modules/quickedit/tests/src/Access/EditEntityFieldAccessCheckTest.php +++ b/core/modules/quickedit/tests/src/Access/EditEntityFieldAccessCheckTest.php @@ -11,7 +11,7 @@ use Drupal\Core\Access\AccessCheckInterface; use Drupal\quickedit\Access\EditEntityFieldAccessCheck; use Drupal\Tests\UnitTestCase; -use Drupal\field\FieldConfigInterface; +use Drupal\field\FieldStorageConfigInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Language\LanguageInterface; @@ -70,24 +70,24 @@ public function providerTestAccess() { ->method('access') ->will($this->returnValue(FALSE)); - $field_with_access = $this->getMockBuilder('Drupal\field\Entity\FieldConfig') + $field_storage_with_access = $this->getMockBuilder('Drupal\field\Entity\FieldStorageConfig') ->disableOriginalConstructor() ->getMock(); - $field_with_access->expects($this->any()) + $field_storage_with_access->expects($this->any()) ->method('access') ->will($this->returnValue(TRUE)); - $field_without_access = $this->getMockBuilder('Drupal\field\Entity\FieldConfig') + $field_storage_without_access = $this->getMockBuilder('Drupal\field\Entity\FieldStorageConfig') ->disableOriginalConstructor() ->getMock(); - $field_without_access->expects($this->any()) + $field_storage_without_access->expects($this->any()) ->method('access') ->will($this->returnValue(FALSE)); $data = array(); - $data[] = array($editable_entity, $field_with_access, AccessCheckInterface::ALLOW); - $data[] = array($non_editable_entity, $field_with_access, AccessCheckInterface::DENY); - $data[] = array($editable_entity, $field_without_access, AccessCheckInterface::DENY); - $data[] = array($non_editable_entity, $field_without_access, AccessCheckInterface::DENY); + $data[] = array($editable_entity, $field_storage_with_access, AccessCheckInterface::ALLOW); + $data[] = array($non_editable_entity, $field_storage_with_access, AccessCheckInterface::DENY); + $data[] = array($editable_entity, $field_storage_without_access, AccessCheckInterface::DENY); + $data[] = array($non_editable_entity, $field_storage_without_access, AccessCheckInterface::DENY); return $data; } @@ -97,14 +97,14 @@ public function providerTestAccess() { * * @param \Drupal\Core\Entity\EntityInterface $entity * A mocked entity. - * @param \Drupal\field\FieldConfigInterface $field - * A mocked field. + * @param \Drupal\field\FieldStorageConfigInterface $field_storage + * A mocked field storage. * @param bool|null $expected_result * The expected result of the access call. * * @dataProvider providerTestAccess */ - public function testAccess(EntityInterface $entity, FieldConfigInterface $field = NULL, $expected_result) { + public function testAccess(EntityInterface $entity, FieldStorageConfigInterface $field_storage = NULL, $expected_result) { $request = new Request(); $field_name = 'valid'; @@ -112,7 +112,7 @@ public function testAccess(EntityInterface $entity, FieldConfigInterface $field $entity_with_field->expects($this->any()) ->method('get') ->with($field_name) - ->will($this->returnValue($field)); + ->will($this->returnValue($field_storage)); $entity_with_field->expects($this->once()) ->method('hasTranslation') ->with(LanguageInterface::LANGCODE_NOT_SPECIFIED) diff --git a/core/modules/rdf/src/Tests/Field/FieldRdfaTestBase.php b/core/modules/rdf/src/Tests/Field/FieldRdfaTestBase.php index 1909550c5fc1..9a26acadac8a 100644 --- a/core/modules/rdf/src/Tests/Field/FieldRdfaTestBase.php +++ b/core/modules/rdf/src/Tests/Field/FieldRdfaTestBase.php @@ -106,7 +106,7 @@ protected function assertFormatterRdfa($formatter, $property, $expected_rdf_valu * Creates the field for testing. */ protected function createTestField() { - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => $this->fieldName, 'entity_type' => 'entity_test', 'type' => $this->fieldType, diff --git a/core/modules/rdf/src/Tests/Field/TaxonomyTermReferenceRdfaTest.php b/core/modules/rdf/src/Tests/Field/TaxonomyTermReferenceRdfaTest.php index 37e270942c02..cefd98c3852f 100644 --- a/core/modules/rdf/src/Tests/Field/TaxonomyTermReferenceRdfaTest.php +++ b/core/modules/rdf/src/Tests/Field/TaxonomyTermReferenceRdfaTest.php @@ -54,7 +54,7 @@ public function setUp() { )); $vocabulary->save(); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => $this->fieldName, 'entity_type' => 'entity_test', 'type' => 'taxonomy_term_reference', diff --git a/core/modules/rdf/src/Tests/TaxonomyTermFieldAttributesTest.php b/core/modules/rdf/src/Tests/TaxonomyTermFieldAttributesTest.php index 70fcf1b98eb0..c8144607fb44 100644 --- a/core/modules/rdf/src/Tests/TaxonomyTermFieldAttributesTest.php +++ b/core/modules/rdf/src/Tests/TaxonomyTermFieldAttributesTest.php @@ -149,7 +149,7 @@ function testNodeTeaser() { * @todo Move this to TaxonomyTestBase, like the other field modules. */ protected function createTaxonomyTermReferenceField($field_name, $vocabulary) { - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => $field_name, 'entity_type' => 'node', 'type' => 'taxonomy_term_reference', diff --git a/core/modules/search/src/Tests/SearchLanguageTest.php b/core/modules/search/src/Tests/SearchLanguageTest.php index afa774b65a44..e6a158a57086 100644 --- a/core/modules/search/src/Tests/SearchLanguageTest.php +++ b/core/modules/search/src/Tests/SearchLanguageTest.php @@ -8,7 +8,7 @@ namespace Drupal\search\Tests; use Drupal\Core\Language\Language; -use Drupal\field\Entity\FieldConfig; +use Drupal\field\Entity\FieldStorageConfig; /** * Tests advanced search with different languages added. @@ -41,9 +41,9 @@ function setUp() { // Make the body field translatable. The title is already translatable by // definition. The parent class has already created the article and page // content types. - $field = FieldConfig::loadByName('node', 'body'); - $field->translatable = TRUE; - $field->save(); + $field_storage = FieldStorageConfig::loadByName('node', 'body'); + $field_storage->translatable = TRUE; + $field_storage->save(); // Create a few page nodes with multilingual body values. $default_format = filter_default_format(); diff --git a/core/modules/search/src/Tests/SearchMultilingualEntityTest.php b/core/modules/search/src/Tests/SearchMultilingualEntityTest.php index af98aedf554a..48607bd39330 100644 --- a/core/modules/search/src/Tests/SearchMultilingualEntityTest.php +++ b/core/modules/search/src/Tests/SearchMultilingualEntityTest.php @@ -8,7 +8,7 @@ namespace Drupal\search\Tests; use Drupal\Core\Language\Language; -use Drupal\field\Entity\FieldConfig; +use Drupal\field\Entity\FieldStorageConfig; /** * Tests entities with multilingual fields. @@ -52,9 +52,9 @@ function setUp() { // Make the body field translatable. The title is already translatable by // definition. The parent class has already created the article and page // content types. - $field = FieldConfig::loadByName('node', 'body'); - $field->translatable = TRUE; - $field->save(); + $field_storage = FieldStorageConfig::loadByName('node', 'body'); + $field_storage->translatable = TRUE; + $field_storage->save(); // Create a few page nodes with multilingual body values. $default_format = filter_default_format(); diff --git a/core/modules/serialization/src/Tests/EntityResolverTest.php b/core/modules/serialization/src/Tests/EntityResolverTest.php index 3162b4c294b3..db65692730ad 100644 --- a/core/modules/serialization/src/Tests/EntityResolverTest.php +++ b/core/modules/serialization/src/Tests/EntityResolverTest.php @@ -30,8 +30,8 @@ class EntityResolverTest extends NormalizerTestBase { protected function setUp() { parent::setUp(); - // Create the test field. - entity_create('field_config', array( + // Create the test field storage. + entity_create('field_storage_config', array( 'settings' => array( 'target_type' => 'entity_test_mulrev', ), diff --git a/core/modules/serialization/src/Tests/NormalizerTestBase.php b/core/modules/serialization/src/Tests/NormalizerTestBase.php index 0c1dc0395866..8d5bf5cf37af 100644 --- a/core/modules/serialization/src/Tests/NormalizerTestBase.php +++ b/core/modules/serialization/src/Tests/NormalizerTestBase.php @@ -27,7 +27,7 @@ protected function setUp() { $this->installConfig(array('field')); // Auto-create a field for testing. - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => 'field_test_text', 'entity_type' => 'entity_test_mulrev', 'type' => 'text', diff --git a/core/modules/simpletest/src/Tests/KernelTestBaseTest.php b/core/modules/simpletest/src/Tests/KernelTestBaseTest.php index 6bff4876346b..69e4235f7c43 100644 --- a/core/modules/simpletest/src/Tests/KernelTestBaseTest.php +++ b/core/modules/simpletest/src/Tests/KernelTestBaseTest.php @@ -244,20 +244,20 @@ function testEnableModulesFixedList() { // Reactivate the previously uninstalled module. $this->enableModules(array('field_test')); - // Create a field and an instance. + // Create a field storage and an instance. entity_create('entity_view_display', array( 'targetEntityType' => 'entity_test', 'bundle' => 'entity_test', 'mode' => 'default', )); - $field = entity_create('field_config', array( + $field_storage = entity_create('field_storage_config', array( 'name' => 'test_field', 'entity_type' => 'entity_test', 'type' => 'test_field' )); - $field->save(); + $field_storage->save(); entity_create('field_instance_config', array( - 'field' => $field, + 'field_storage' => $field_storage, 'bundle' => 'entity_test', ))->save(); } diff --git a/core/modules/system/entity.api.php b/core/modules/system/entity.api.php index 458f0803b5ef..f835aa9f26da 100644 --- a/core/modules/system/entity.api.php +++ b/core/modules/system/entity.api.php @@ -132,7 +132,7 @@ * * Some specific entity types invoke hooks during preSave() or postSave() * operations. Examples: - * - Field configuration preSave(): hook_field_config_update_forbid() + * - Field configuration preSave(): hook_field_storage_config_update_forbid() * - Node postSave(): hook_node_access_records() and * hook_node_access_records_alter() * - Config entities that are acting as entity bundles, in postSave(): @@ -1465,15 +1465,15 @@ function hook_entity_field_storage_info(\Drupal\Core\Entity\EntityTypeInterface if ($entity_type->isFieldable()) { // Query by filtering on the ID as this is more efficient than filtering // on the entity_type property directly. - $ids = \Drupal::entityQuery('field_config') + $ids = \Drupal::entityQuery('field_storage_config') ->condition('id', $entity_type->id() . '.', 'STARTS_WITH') ->execute(); // Fetch all fields and key them by field name. - $field_configs = entity_load_multiple('field_config', $ids); + $field_storages = entity_load_multiple('field_storage_config', $ids); $result = array(); - foreach ($field_configs as $field_config) { - $result[$field_config->getName()] = $field_config; + foreach ($field_storages as $field_storage) { + $result[$field_storage->getName()] = $field_storage; } return $result; } diff --git a/core/modules/system/src/Tests/Ajax/MultiFormTest.php b/core/modules/system/src/Tests/Ajax/MultiFormTest.php index bf55e6b495f2..44de1a25fe11 100644 --- a/core/modules/system/src/Tests/Ajax/MultiFormTest.php +++ b/core/modules/system/src/Tests/Ajax/MultiFormTest.php @@ -31,7 +31,7 @@ function setUp() { // Create a multi-valued field for 'page' nodes to use for Ajax testing. $field_name = 'field_ajax_test'; - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => $field_name, 'entity_type' => 'node', 'type' => 'text', diff --git a/core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php b/core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php index 63ea7a3fc9cd..aec60b5925a4 100644 --- a/core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php +++ b/core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php @@ -68,7 +68,7 @@ public function setUp() { if ($this->entity->getEntityType()->isFieldable()) { // Add field, so we can modify the Field and FieldInstance entities to // verify that changes to those indeed clear cache tags. - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => 'configurable_field', 'entity_type' => $this->entity->getEntityTypeId(), 'type' => 'test_field', @@ -184,7 +184,7 @@ protected function createReferenceTestEntities($referenced_entity) { // Add a field of the given type to the given entity type's "foo" bundle. $field_name = $referenced_entity->getEntityTypeId() . '_reference'; - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => $field_name, 'entity_type' => $entity_type, 'type' => 'entity_reference', @@ -403,8 +403,8 @@ public function testReferencedEntity() { // is a cache miss. $this->pass("Test modification of referenced entity's configurable field.", 'Debug'); $field_name = $this->entity->getEntityTypeId() . '.configurable_field'; - $field = entity_load('field_config', $field_name); - $field->save(); + $field_storage = entity_load('field_storage_config', $field_name); + $field_storage->save(); $this->verifyPageCache($referencing_entity_path, 'MISS'); $this->verifyPageCache($listing_path, 'MISS'); $this->verifyPageCache($non_referencing_entity_path, 'HIT'); diff --git a/core/modules/system/src/Tests/Entity/EntityLanguageTestBase.php b/core/modules/system/src/Tests/Entity/EntityLanguageTestBase.php index 3be40c6caa7c..b25790706e33 100644 --- a/core/modules/system/src/Tests/Entity/EntityLanguageTestBase.php +++ b/core/modules/system/src/Tests/Entity/EntityLanguageTestBase.php @@ -70,7 +70,7 @@ function setUp() { // Create field instances in all entity variations. foreach (entity_test_entity_types() as $entity_type) { - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => $this->field_name, 'entity_type' => $entity_type, 'type' => 'text', @@ -84,7 +84,7 @@ function setUp() { ))->save(); $this->instance[$entity_type] = entity_load('field_instance_config', $entity_type . '.' . $entity_type . '.' . $this->field_name); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => $this->untranslatable_field_name, 'entity_type' => $entity_type, 'type' => 'text', @@ -119,7 +119,7 @@ function setUp() { } /** - * Toggles field translatability. + * Toggles field storage translatability. * * @param string $entity_type * The type of the entity fields are attached to. diff --git a/core/modules/system/src/Tests/Entity/EntityQueryAggregateTest.php b/core/modules/system/src/Tests/Entity/EntityQueryAggregateTest.php index 6875faffb691..9cf3bcdca394 100644 --- a/core/modules/system/src/Tests/Entity/EntityQueryAggregateTest.php +++ b/core/modules/system/src/Tests/Entity/EntityQueryAggregateTest.php @@ -51,7 +51,7 @@ public function setUp() { // Add some fieldapi fields to be used in the test. for ($i = 1; $i <= 2; $i++) { $field_name = 'field_test_' . $i; - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => $field_name, 'entity_type' => 'entity_test', 'type' => 'integer', diff --git a/core/modules/system/src/Tests/Entity/EntityQueryRelationshipTest.php b/core/modules/system/src/Tests/Entity/EntityQueryRelationshipTest.php index a945b0dc35cb..552ba65e34a1 100644 --- a/core/modules/system/src/Tests/Entity/EntityQueryRelationshipTest.php +++ b/core/modules/system/src/Tests/Entity/EntityQueryRelationshipTest.php @@ -80,7 +80,7 @@ public function setUp() { 'type' => 'taxonomy_term_reference', ); $field['settings']['allowed_values']['vocabulary'] = $vocabulary->id(); - entity_create('field_config', $field)->save(); + entity_create('field_storage_config', $field)->save(); entity_test_create_bundle('test_bundle'); // Third, create the instance. entity_create('field_instance_config', array( diff --git a/core/modules/system/src/Tests/Entity/EntityQueryTest.php b/core/modules/system/src/Tests/Entity/EntityQueryTest.php index 4f56bd61b3bd..9e3d7b652622 100644 --- a/core/modules/system/src/Tests/Entity/EntityQueryTest.php +++ b/core/modules/system/src/Tests/Entity/EntityQueryTest.php @@ -59,15 +59,15 @@ function setUp() { $figures = drupal_strtolower($this->randomName()); $greetings = drupal_strtolower($this->randomName()); foreach (array($figures => 'shape', $greetings => 'text') as $field_name => $field_type) { - $field = entity_create('field_config', array( + $field_storage = entity_create('field_storage_config', array( 'name' => $field_name, 'entity_type' => 'entity_test_mulrev', 'type' => $field_type, 'cardinality' => 2, 'translatable' => TRUE, )); - $field->save(); - $fields[] = $field; + $field_storage->save(); + $field_storages[] = $field_storage; } $bundles = array(); for ($i = 0; $i < 2; $i++) { @@ -77,9 +77,9 @@ function setUp() { $bundle = $this->randomName(); } while ($bundles && strtolower($bundles[0]) >= strtolower($bundle)); entity_test_create_bundle($bundle); - foreach ($fields as $field) { + foreach ($field_storages as $field_storage) { entity_create('field_instance_config', array( - 'field' => $field, + 'field_storage' => $field_storage, 'bundle' => $bundle, ))->save(); } @@ -425,17 +425,17 @@ protected function testTableSort() { protected function testCount() { // Create a field with the same name in a different entity type. $field_name = $this->figures; - $field = entity_create('field_config', array( + $field_storage = entity_create('field_storage_config', array( 'name' => $field_name, 'entity_type' => 'entity_test', 'type' => 'shape', 'cardinality' => 2, 'translatable' => TRUE, )); - $field->save(); + $field_storage->save(); $bundle = $this->randomName(); entity_create('field_instance_config', array( - 'field' => $field, + 'field_storage' => $field_storage, 'bundle' => $bundle, ))->save(); diff --git a/core/modules/system/src/Tests/Entity/EntityTranslationFormTest.php b/core/modules/system/src/Tests/Entity/EntityTranslationFormTest.php index c2211e33ee3a..197b8710ab77 100644 --- a/core/modules/system/src/Tests/Entity/EntityTranslationFormTest.php +++ b/core/modules/system/src/Tests/Entity/EntityTranslationFormTest.php @@ -8,7 +8,7 @@ namespace Drupal\system\Tests\Entity; use Drupal\Core\Language\LanguageInterface; -use Drupal\field\Entity\FieldConfig; +use Drupal\field\Entity\FieldStorageConfig; use Drupal\simpletest\WebTestBase; use Drupal\Core\Language\Language; @@ -98,11 +98,11 @@ function testEntityFormLanguage() { $this->assertTrue($node, 'Node found in database.'); // Make body translatable. - $field = FieldConfig::loadByName('node', 'body'); - $field->translatable = TRUE; - $field->save(); - $field = FieldConfig::loadByName('node', 'body'); - $this->assertTrue($field->isTranslatable(), 'Field body is translatable.'); + $field_storage = FieldStorageConfig::loadByName('node', 'body'); + $field_storage->translatable = TRUE; + $field_storage->save(); + $field_storage = FieldStorageConfig::loadByName('node', 'body'); + $this->assertTrue($field_storage->isTranslatable(), 'Field body is translatable.'); // Create a body translation and check the form language. $langcode2 = $this->langcodes[1]; diff --git a/core/modules/system/src/Tests/Entity/EntityWithUriCacheTagsTestBase.php b/core/modules/system/src/Tests/Entity/EntityWithUriCacheTagsTestBase.php index bf45132732c3..6f1d7a840274 100644 --- a/core/modules/system/src/Tests/Entity/EntityWithUriCacheTagsTestBase.php +++ b/core/modules/system/src/Tests/Entity/EntityWithUriCacheTagsTestBase.php @@ -87,14 +87,13 @@ public function testEntityUri() { // is a cache miss. $this->pass("Test modification of entity's configurable field.", 'Debug'); $field_name = $this->entity->getEntityTypeId() . '.configurable_field'; - $field = entity_load('field_config', $field_name); - $field->save(); + $field_storage = entity_load('field_storage_config', $field_name); + $field_storage->save(); $this->verifyPageCache($entity_path, 'MISS'); // Verify a cache hit. $this->verifyPageCache($entity_path, 'HIT'); - // Verify that after modifying a configurable field instance on the // entity, there is a cache miss. $this->pass("Test modification of entity's configurable field instance.", 'Debug'); diff --git a/core/modules/system/src/Tests/Entity/FieldSqlStorageTest.php b/core/modules/system/src/Tests/Entity/FieldSqlStorageTest.php index d1952375b2e3..ee1ca2c18aea 100644 --- a/core/modules/system/src/Tests/Entity/FieldSqlStorageTest.php +++ b/core/modules/system/src/Tests/Entity/FieldSqlStorageTest.php @@ -10,7 +10,7 @@ use Drupal\Core\Database\Database; use Drupal\Core\Entity\ContentEntityDatabaseStorage; use Drupal\Core\Entity\Exception\FieldStorageDefinitionUpdateForbiddenException; -use Drupal\field\Entity\FieldConfig; +use Drupal\field\Entity\FieldStorageConfig; /** * Tests Field SQL Storage . @@ -37,11 +37,11 @@ class FieldSqlStorageTest extends EntityUnitTestBase { protected $field_name; /** - * A field to use in this class. + * A field storage to use in this class. * - * @var \Drupal\field\Entity\FieldConfig + * @var \Drupal\field\Entity\FieldStorageConfig */ - protected $field; + protected $fieldStorage; /** * A field instance to use in this test class. @@ -65,21 +65,21 @@ function setUp() { $this->field_name = strtolower($this->randomName()); $this->field_cardinality = 4; - $this->field = entity_create('field_config', array( + $this->fieldStorage = entity_create('field_storage_config', array( 'name' => $this->field_name, 'entity_type' => $entity_type, 'type' => 'test_field', 'cardinality' => $this->field_cardinality, )); - $this->field->save(); + $this->fieldStorage->save(); $this->instance = entity_create('field_instance_config', array( - 'field' => $this->field, + 'field_storage' => $this->fieldStorage, 'bundle' => $entity_type )); $this->instance->save(); - $this->table = ContentEntityDatabaseStorage::_fieldTableName($this->field); - $this->revision_table = ContentEntityDatabaseStorage::_fieldRevisionTableName($this->field); + $this->table = ContentEntityDatabaseStorage::_fieldTableName($this->fieldStorage); + $this->revision_table = ContentEntityDatabaseStorage::_fieldRevisionTableName($this->fieldStorage); } /** @@ -89,7 +89,7 @@ function testFieldLoad() { $entity_type = $bundle = 'entity_test_rev'; $storage = $this->container->get('entity.manager')->getStorage($entity_type); - $columns = array('bundle', 'deleted', 'entity_id', 'revision_id', 'delta', 'langcode', ContentEntityDatabaseStorage::_fieldColumnName($this->field, 'value')); + $columns = array('bundle', 'deleted', 'entity_id', 'revision_id', 'delta', 'langcode', ContentEntityDatabaseStorage::_fieldColumnName($this->fieldStorage, 'value')); // Create an entity with four revisions. $revision_ids = array(); @@ -255,12 +255,12 @@ function testLongNames() { $storage = $this->container->get('entity.manager')->getStorage($entity_type); // Create two fields with instances, and generate randome values. - $name_base = drupal_strtolower($this->randomName(FieldConfig::NAME_MAX_LENGTH - 1)); + $name_base = drupal_strtolower($this->randomName(FieldStorageConfig::NAME_MAX_LENGTH - 1)); $field_names = array(); $values = array(); for ($i = 0; $i < 2; $i++) { $field_names[$i] = $name_base . $i; - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => $field_names[$i], 'entity_type' => $entity_type, 'type' => 'test_field', @@ -290,15 +290,15 @@ function testLongNames() { function testUpdateFieldSchemaWithData() { $entity_type = 'entity_test_rev'; // Create a decimal 5.2 field and add some data. - $field = entity_create('field_config', array( + $field_storage = entity_create('field_storage_config', array( 'name' => 'decimal52', 'entity_type' => $entity_type, 'type' => 'decimal', 'settings' => array('precision' => 5, 'scale' => 2), )); - $field->save(); + $field_storage->save(); $instance = entity_create('field_instance_config', array( - 'field' => $field, + 'field_storage' => $field_storage, 'bundle' => $entity_type, )); $instance->save(); @@ -310,9 +310,9 @@ function testUpdateFieldSchemaWithData() { $entity->save(); // Attempt to update the field in a way that would work without data. - $field->settings['scale'] = 3; + $field_storage->settings['scale'] = 3; try { - $field->save(); + $field_storage->save(); $this->fail(t('Cannot update field schema with data.')); } catch (FieldStorageDefinitionUpdateForbiddenException $e) { @@ -325,19 +325,19 @@ function testUpdateFieldSchemaWithData() { */ function testFieldUpdateFailure() { // Create a text field. - $field = entity_create('field_config', array( + $field_storage = entity_create('field_storage_config', array( 'name' => 'test_text', 'entity_type' => 'entity_test', 'type' => 'text', 'settings' => array('max_length' => 255), )); - $field->save(); + $field_storage->save(); // Attempt to update the field in a way that would break the storage. - $prior_field = $field; - $field->settings['max_length'] = -1; + $prior_field_storage = $field_storage; + $field_storage->settings['max_length'] = -1; try { - $field->save(); + $field_storage->save(); $this->fail(t('Update succeeded.')); } catch (\Exception $e) { @@ -345,7 +345,7 @@ function testFieldUpdateFailure() { } // Ensure that the field tables are still there. - foreach (ContentEntityDatabaseStorage::_fieldSqlSchema($prior_field) as $table_name => $table_info) { + foreach (ContentEntityDatabaseStorage::_fieldSqlSchema($prior_field_storage) as $table_name => $table_info) { $this->assertTrue(db_table_exists($table_name), t('Table %table exists.', array('%table' => $table_name))); } } @@ -357,18 +357,18 @@ function testFieldUpdateIndexesWithData() { // Create a decimal field. $field_name = 'testfield'; $entity_type = 'entity_test_rev'; - $field = entity_create('field_config', array( + $field_storage = entity_create('field_storage_config', array( 'name' => $field_name, 'entity_type' => $entity_type, 'type' => 'text', )); - $field->save(); + $field_storage->save(); $instance = entity_create('field_instance_config', array( - 'field' => $field, + 'field_storage' => $field_storage, 'bundle' => $entity_type, )); $instance->save(); - $tables = array(ContentEntityDatabaseStorage::_fieldTableName($field), ContentEntityDatabaseStorage::_fieldRevisionTableName($field)); + $tables = array(ContentEntityDatabaseStorage::_fieldTableName($field_storage), ContentEntityDatabaseStorage::_fieldRevisionTableName($field_storage)); // Verify the indexes we will create do not exist yet. foreach ($tables as $table) { @@ -386,15 +386,15 @@ function testFieldUpdateIndexesWithData() { $entity->save(); // Add an index. - $field->indexes = array('value' => array(array('value', 255))); - $field->save(); + $field_storage->indexes = array('value' => array(array('value', 255))); + $field_storage->save(); foreach ($tables as $table) { $this->assertTrue(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value"), t("Index on value created in $table")); } // Add a different index, removing the existing custom one. - $field->indexes = array('value_format' => array(array('value', 127), array('format', 127))); - $field->save(); + $field_storage->indexes = array('value_format' => array(array('value', 127), array('format', 127))); + $field_storage->save(); foreach ($tables as $table) { $this->assertTrue(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value_format"), t("Index on value_format created in $table")); $this->assertFalse(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value"), t("Index on value removed in $table")); @@ -413,15 +413,15 @@ function testFieldSqlStorageForeignKeys() { // field_test_field_schema()). $field_name = 'testfield'; $foreign_key_name = 'shape'; - $field = entity_create('field_config', array( + $field_storage = entity_create('field_storage_config', array( 'name' => $field_name, 'entity_type' => 'entity_test', 'type' => 'shape', 'settings' => array('foreign_key_name' => $foreign_key_name), )); - $field->save(); + $field_storage->save(); // Get the field schema. - $schema = $field->getSchema(); + $schema = $field_storage->getSchema(); // Retrieve the field definition and check that the foreign key is in place. $this->assertEqual($schema['foreign keys'][$foreign_key_name]['table'], $foreign_key_name, 'Foreign key table name preserved through CRUD'); @@ -429,22 +429,22 @@ function testFieldSqlStorageForeignKeys() { // Update the field settings, it should update the foreign key definition too. $foreign_key_name = 'color'; - $field->settings['foreign_key_name'] = $foreign_key_name; - $field->save(); + $field_storage->settings['foreign_key_name'] = $foreign_key_name; + $field_storage->save(); // Reload the field schema after the update. - $schema = $field->getSchema(); + $schema = $field_storage->getSchema(); // Retrieve the field definition and check that the foreign key is in place. - $field = FieldConfig::loadByName('entity_test', $field_name); + $field_storage = FieldStorageConfig::loadByName('entity_test', $field_name); $this->assertEqual($schema['foreign keys'][$foreign_key_name]['table'], $foreign_key_name, 'Foreign key table name modified after update'); $this->assertEqual($schema['foreign keys'][$foreign_key_name]['columns'][$foreign_key_name], 'id', 'Foreign key column name modified after update'); // Verify the SQL schema. - $schemas = ContentEntityDatabaseStorage::_fieldSqlSchema($field); - $schema = $schemas[ContentEntityDatabaseStorage::_fieldTableName($field)]; + $schemas = ContentEntityDatabaseStorage::_fieldSqlSchema($field_storage); + $schema = $schemas[ContentEntityDatabaseStorage::_fieldTableName($field_storage)]; $this->assertEqual(count($schema['foreign keys']), 1, 'There is 1 foreign key in the schema'); $foreign_key = reset($schema['foreign keys']); - $foreign_key_column = ContentEntityDatabaseStorage::_fieldColumnName($field, $foreign_key_name); + $foreign_key_column = ContentEntityDatabaseStorage::_fieldColumnName($field_storage, $foreign_key_name); $this->assertEqual($foreign_key['table'], $foreign_key_name, 'Foreign key table name preserved in the schema'); $this->assertEqual($foreign_key['columns'][$foreign_key_column], 'id', 'Foreign key column name preserved in the schema'); } @@ -459,7 +459,7 @@ function testFieldSqlStorageBundleRename() { $value = mt_rand(1, 127); $entity = entity_create($entity_type, array( 'type' => $bundle, - $this->field->name => $value, + $this->fieldStorage->name => $value, )); $entity->save(); @@ -469,12 +469,12 @@ function testFieldSqlStorageBundleRename() { // Check that the 'bundle' column has been updated in storage. $row = db_select($this->table, 't') - ->fields('t', array('bundle', $this->field->name . '_value')) + ->fields('t', array('bundle', $this->fieldStorage->name . '_value')) ->condition('entity_id', $entity->id()) ->execute() ->fetch(); $this->assertEqual($row->bundle, $bundle_new); - $this->assertEqual($row->{$this->field->name . '_value'}, $value); + $this->assertEqual($row->{$this->fieldStorage->name . '_value'}, $value); } /** @@ -488,74 +488,74 @@ public function testTableNames() { // Short entity type and field name. $entity_type = 'short_entity_type'; $field_name = 'short_field_name'; - $field = entity_create('field_config', array( + $field_storage = entity_create('field_storage_config', array( 'entity_type' => $entity_type, 'name' => $field_name, 'type' => 'test_field', )); $expected = 'short_entity_type__short_field_name'; - $this->assertEqual(ContentEntityDatabaseStorage::_fieldTableName($field), $expected); + $this->assertEqual(ContentEntityDatabaseStorage::_fieldTableName($field_storage), $expected); $expected = 'short_entity_type_revision__short_field_name'; - $this->assertEqual(ContentEntityDatabaseStorage::_fieldRevisionTableName($field), $expected); + $this->assertEqual(ContentEntityDatabaseStorage::_fieldRevisionTableName($field_storage), $expected); // Short entity type, long field name $entity_type = 'short_entity_type'; $field_name = 'long_field_name_abcdefghijklmnopqrstuvwxyz'; - $field = entity_create('field_config', array( + $field_storage = entity_create('field_storage_config', array( 'entity_type' => $entity_type, 'name' => $field_name, 'type' => 'test_field', )); - $expected = 'short_entity_type__' . substr(hash('sha256', $field->uuid()), 0, 10); - $this->assertEqual(ContentEntityDatabaseStorage::_fieldTableName($field), $expected); - $expected = 'short_entity_type_r__' . substr(hash('sha256', $field->uuid()), 0, 10); - $this->assertEqual(ContentEntityDatabaseStorage::_fieldRevisionTableName($field), $expected); + $expected = 'short_entity_type__' . substr(hash('sha256', $field_storage->uuid()), 0, 10); + $this->assertEqual(ContentEntityDatabaseStorage::_fieldTableName($field_storage), $expected); + $expected = 'short_entity_type_r__' . substr(hash('sha256', $field_storage->uuid()), 0, 10); + $this->assertEqual(ContentEntityDatabaseStorage::_fieldRevisionTableName($field_storage), $expected); // Long entity type, short field name $entity_type = 'long_entity_type_abcdefghijklmnopqrstuvwxyz'; $field_name = 'short_field_name'; - $field = entity_create('field_config', array( + $field_storage = entity_create('field_storage_config', array( 'entity_type' => $entity_type, 'name' => $field_name, 'type' => 'test_field', )); - $expected = 'long_entity_type_abcdefghijklmnopq__' . substr(hash('sha256', $field->uuid()), 0, 10); - $this->assertEqual(ContentEntityDatabaseStorage::_fieldTableName($field), $expected); - $expected = 'long_entity_type_abcdefghijklmnopq_r__' . substr(hash('sha256', $field->uuid()), 0, 10); - $this->assertEqual(ContentEntityDatabaseStorage::_fieldRevisionTableName($field), $expected); + $expected = 'long_entity_type_abcdefghijklmnopq__' . substr(hash('sha256', $field_storage->uuid()), 0, 10); + $this->assertEqual(ContentEntityDatabaseStorage::_fieldTableName($field_storage), $expected); + $expected = 'long_entity_type_abcdefghijklmnopq_r__' . substr(hash('sha256', $field_storage->uuid()), 0, 10); + $this->assertEqual(ContentEntityDatabaseStorage::_fieldRevisionTableName($field_storage), $expected); // Long entity type and field name. $entity_type = 'long_entity_type_abcdefghijklmnopqrstuvwxyz'; $field_name = 'long_field_name_abcdefghijklmnopqrstuvwxyz'; - $field = entity_create('field_config', array( + $field_storage = entity_create('field_storage_config', array( 'entity_type' => $entity_type, 'name' => $field_name, 'type' => 'test_field', )); - $expected = 'long_entity_type_abcdefghijklmnopq__' . substr(hash('sha256', $field->uuid()), 0, 10); - $this->assertEqual(ContentEntityDatabaseStorage::_fieldTableName($field), $expected); - $expected = 'long_entity_type_abcdefghijklmnopq_r__' . substr(hash('sha256', $field->uuid()), 0, 10); - $this->assertEqual(ContentEntityDatabaseStorage::_fieldRevisionTableName($field), $expected); + $expected = 'long_entity_type_abcdefghijklmnopq__' . substr(hash('sha256', $field_storage->uuid()), 0, 10); + $this->assertEqual(ContentEntityDatabaseStorage::_fieldTableName($field_storage), $expected); + $expected = 'long_entity_type_abcdefghijklmnopq_r__' . substr(hash('sha256', $field_storage->uuid()), 0, 10); + $this->assertEqual(ContentEntityDatabaseStorage::_fieldRevisionTableName($field_storage), $expected); // Try creating a second field and check there are no clashes. - $field2 = entity_create('field_config', array( + $field_storage2 = entity_create('field_storage_config', array( 'entity_type' => $entity_type, 'name' => $field_name . '2', 'type' => 'test_field', )); - $this->assertNotEqual(ContentEntityDatabaseStorage::_fieldTableName($field), ContentEntityDatabaseStorage::_fieldTableName($field2)); - $this->assertNotEqual(ContentEntityDatabaseStorage::_fieldRevisionTableName($field), ContentEntityDatabaseStorage::_fieldRevisionTableName($field2)); + $this->assertNotEqual(ContentEntityDatabaseStorage::_fieldTableName($field_storage), ContentEntityDatabaseStorage::_fieldTableName($field_storage2)); + $this->assertNotEqual(ContentEntityDatabaseStorage::_fieldRevisionTableName($field_storage), ContentEntityDatabaseStorage::_fieldRevisionTableName($field_storage2)); // Deleted field. - $field = entity_create('field_config', array( + $field_storage = entity_create('field_storage_config', array( 'entity_type' => 'some_entity_type', 'name' => 'some_field_name', 'type' => 'test_field', 'deleted' => TRUE, )); - $expected = 'field_deleted_data_' . substr(hash('sha256', $field->uuid()), 0, 10); - $this->assertEqual(ContentEntityDatabaseStorage::_fieldTableName($field, TRUE), $expected); - $expected = 'field_deleted_revision_' . substr(hash('sha256', $field->uuid()), 0, 10); - $this->assertEqual(ContentEntityDatabaseStorage::_fieldRevisionTableName($field, TRUE), $expected); + $expected = 'field_deleted_data_' . substr(hash('sha256', $field_storage->uuid()), 0, 10); + $this->assertEqual(ContentEntityDatabaseStorage::_fieldTableName($field_storage, TRUE), $expected); + $expected = 'field_deleted_revision_' . substr(hash('sha256', $field_storage->uuid()), 0, 10); + $this->assertEqual(ContentEntityDatabaseStorage::_fieldRevisionTableName($field_storage, TRUE), $expected); } } diff --git a/core/modules/system/src/Tests/Entity/FieldTranslationSqlStorageTest.php b/core/modules/system/src/Tests/Entity/FieldTranslationSqlStorageTest.php index f506ced3e3dd..b1129577914a 100644 --- a/core/modules/system/src/Tests/Entity/FieldTranslationSqlStorageTest.php +++ b/core/modules/system/src/Tests/Entity/FieldTranslationSqlStorageTest.php @@ -10,7 +10,7 @@ use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\ContentEntityDatabaseStorage; use Drupal\Core\Language\LanguageInterface; -use Drupal\field\Entity\FieldConfig; +use Drupal\field\Entity\FieldStorageConfig; /** * Tests Field translation SQL Storage. @@ -85,10 +85,10 @@ protected function assertFieldStorageLangcode(ContentEntityInterface $entity, $m $fields = array($this->field_name, $this->untranslatable_field_name); foreach ($fields as $field_name) { - $field = FieldConfig::loadByName($entity_type, $field_name); + $field_storage = FieldStorageConfig::loadByName($entity_type, $field_name); $tables = array( - ContentEntityDatabaseStorage::_fieldTableName($field), - ContentEntityDatabaseStorage::_fieldRevisionTableName($field), + ContentEntityDatabaseStorage::_fieldTableName($field_storage), + ContentEntityDatabaseStorage::_fieldRevisionTableName($field_storage), ); foreach ($tables as $table) { diff --git a/core/modules/system/src/Tests/Form/ArbitraryRebuildTest.php b/core/modules/system/src/Tests/Form/ArbitraryRebuildTest.php index 3da65ff6f7bb..a922ca6b38aa 100644 --- a/core/modules/system/src/Tests/Form/ArbitraryRebuildTest.php +++ b/core/modules/system/src/Tests/Form/ArbitraryRebuildTest.php @@ -27,7 +27,7 @@ function setUp() { parent::setUp(); // Auto-create a field for testing. - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => 'test_multiple', 'entity_type' => 'user', 'type' => 'text', diff --git a/core/modules/system/src/Tests/Form/RebuildTest.php b/core/modules/system/src/Tests/Form/RebuildTest.php index 754a3033bc14..7e5a39bd21c1 100644 --- a/core/modules/system/src/Tests/Form/RebuildTest.php +++ b/core/modules/system/src/Tests/Form/RebuildTest.php @@ -65,19 +65,17 @@ function testRebuildPreservesValues() { function testPreserveFormActionAfterAJAX() { // Create a multi-valued field for 'page' nodes to use for Ajax testing. $field_name = 'field_ajax_test'; - $field = array( + entity_create('field_storage_config', array( 'name' => $field_name, 'entity_type' => 'node', 'type' => 'text', 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED, - ); - entity_create('field_config', $field)->save(); - $instance = array( + ))->save(); + entity_create('field_instance_config', array( 'field_name' => $field_name, 'entity_type' => 'node', 'bundle' => 'page', - ); - entity_create('field_instance_config', $instance)->save(); + ))->save(); entity_get_form_display('node', 'page', 'default') ->setComponent($field_name, array('type' => 'text_textfield')) ->save(); diff --git a/core/modules/system/system.api.php b/core/modules/system/system.api.php index 8ff4b544eef0..350869b7e2f8 100644 --- a/core/modules/system/system.api.php +++ b/core/modules/system/system.api.php @@ -2830,7 +2830,7 @@ function hook_link_alter(&$variables) { */ function hook_config_import_steps_alter(&$sync_steps, \Drupal\Core\Config\ConfigImporter $config_importer) { $deletes = $config_importer->getUnprocessedConfiguration('delete'); - if (isset($deletes['field.field.node.body'])) { + if (isset($deletes['field.storage.node.body'])) { $sync_steps[] = '_additional_configuration_step'; } } diff --git a/core/modules/system/tests/modules/entity_test/entity_test.install b/core/modules/system/tests/modules/entity_test/entity_test.install index 162f7ea081b7..4dfd09b5f603 100644 --- a/core/modules/system/tests/modules/entity_test/entity_test.install +++ b/core/modules/system/tests/modules/entity_test/entity_test.install @@ -17,7 +17,7 @@ function entity_test_install() { ); foreach ($entity_types as $entity_type) { // Auto-create fields for testing. - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => 'field_test_text', 'entity_type' => $entity_type, 'type' => 'text', diff --git a/core/modules/system/tests/upgrade/drupal-7.field.database.php b/core/modules/system/tests/upgrade/drupal-7.field.database.php index 6412fee6f8fa..b00e42bb4830 100644 --- a/core/modules/system/tests/upgrade/drupal-7.field.database.php +++ b/core/modules/system/tests/upgrade/drupal-7.field.database.php @@ -57,7 +57,7 @@ // Add a field shared across different entity types (instance on article nodes // and users). -$field_id = db_insert('field_config') +$field_id = db_insert('field_storage_config') ->fields(array( 'field_name' => 'test_shared_field', 'type' => 'text', @@ -348,7 +348,7 @@ ->execute(); // Add a deleted field and instance. -$field_id = db_insert('field_config') +$field_id = db_insert('field_storage_config') ->fields(array( 'field_name' => 'test_deleted_field', 'type' => 'text', diff --git a/core/modules/taxonomy/src/Controller/TermAutocompleteController.php b/core/modules/taxonomy/src/Controller/TermAutocompleteController.php index b1450b57d0f4..d701c90ca7c1 100644 --- a/core/modules/taxonomy/src/Controller/TermAutocompleteController.php +++ b/core/modules/taxonomy/src/Controller/TermAutocompleteController.php @@ -105,7 +105,7 @@ public function autocomplete(Request $request, $entity_type, $field_name) { // will display it as debugging information. return new Response(t('Taxonomy field @field_name not found.', array('@field_name' => $field_name)), 403); } - $field = $field_storage_definitions[$field_name]; + $field_storage = $field_storage_definitions[$field_name]; // The user enters a comma-separated list of tags. We only autocomplete the // last tag. @@ -117,7 +117,7 @@ public function autocomplete(Request $request, $entity_type, $field_name) { // Part of the criteria for the query come from the field's own settings. $vids = array(); - foreach ($field->getSetting('allowed_values') as $tree) { + foreach ($field_storage->getSetting('allowed_values') as $tree) { $vids[] = $tree['vocabulary']; } diff --git a/core/modules/taxonomy/src/Entity/Vocabulary.php b/core/modules/taxonomy/src/Entity/Vocabulary.php index d492d7a3e4ef..aa47b3a75d2d 100644 --- a/core/modules/taxonomy/src/Entity/Vocabulary.php +++ b/core/modules/taxonomy/src/Entity/Vocabulary.php @@ -111,7 +111,7 @@ public function postSave(EntityStorageInterface $storage, $update = TRUE) { } } - $fields = \Drupal::entityManager()->getStorage('field_config')->loadMultiple($field_ids); + $fields = \Drupal::entityManager()->getStorage('field_storage_config')->loadMultiple($field_ids); foreach ($fields as $field) { $update_field = FALSE; @@ -160,7 +160,7 @@ public static function postDelete(EntityStorageInterface $storage, array $entiti } // Load all Taxonomy module fields and delete those which use only this // vocabulary. - $taxonomy_fields = entity_load_multiple_by_properties('field_config', array('module' => 'taxonomy')); + $taxonomy_fields = entity_load_multiple_by_properties('field_storage_config', array('module' => 'taxonomy')); foreach ($taxonomy_fields as $taxonomy_field) { $modified_field = FALSE; // Term reference fields may reference terms from more than one diff --git a/core/modules/taxonomy/src/Tests/LegacyTest.php b/core/modules/taxonomy/src/Tests/LegacyTest.php index 7f71d05daa83..409b990f0ab5 100644 --- a/core/modules/taxonomy/src/Tests/LegacyTest.php +++ b/core/modules/taxonomy/src/Tests/LegacyTest.php @@ -35,7 +35,7 @@ function setUp() { $vocabulary->save(); $field_name = 'field_' . $vocabulary->id(); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => $field_name, 'entity_type' => 'node', 'type' => 'taxonomy_term_reference', diff --git a/core/modules/taxonomy/src/Tests/RssTest.php b/core/modules/taxonomy/src/Tests/RssTest.php index 5ca86293a330..334937d1cdb5 100644 --- a/core/modules/taxonomy/src/Tests/RssTest.php +++ b/core/modules/taxonomy/src/Tests/RssTest.php @@ -32,7 +32,7 @@ function setUp() { $this->vocabulary = $this->createVocabulary(); $this->field_name = 'taxonomy_' . $this->vocabulary->id(); - $this->field = entity_create('field_config', array( + $this->fieldStorage = entity_create('field_storage_config', array( 'name' => $this->field_name, 'entity_type' => 'node', 'type' => 'taxonomy_term_reference', @@ -46,9 +46,9 @@ function setUp() { ), ), )); - $this->field->save(); + $this->fieldStorage->save(); entity_create('field_instance_config', array( - 'field' => $this->field, + 'field_storage' => $this->fieldStorage, 'bundle' => 'article', ))->save(); entity_get_form_display('node', 'article', 'default') diff --git a/core/modules/taxonomy/src/Tests/TaxonomyImageTest.php b/core/modules/taxonomy/src/Tests/TaxonomyImageTest.php index 138efe738365..f1d6aff5770f 100644 --- a/core/modules/taxonomy/src/Tests/TaxonomyImageTest.php +++ b/core/modules/taxonomy/src/Tests/TaxonomyImageTest.php @@ -38,7 +38,7 @@ public function setUp() { // Add a field instance to the vocabulary. $entity_type = 'taxonomy_term'; $name = 'field_test'; - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => $name, 'entity_type' => $entity_type, 'type' => 'image', diff --git a/core/modules/taxonomy/src/Tests/TaxonomyTermReferenceItemTest.php b/core/modules/taxonomy/src/Tests/TaxonomyTermReferenceItemTest.php index ef9c0a70a063..ee13d0fa11af 100644 --- a/core/modules/taxonomy/src/Tests/TaxonomyTermReferenceItemTest.php +++ b/core/modules/taxonomy/src/Tests/TaxonomyTermReferenceItemTest.php @@ -45,7 +45,7 @@ public function setUp() { )); $vocabulary->save(); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => 'field_test_taxonomy', 'entity_type' => 'entity_test', 'type' => 'taxonomy_term_reference', diff --git a/core/modules/taxonomy/src/Tests/TermFieldMultipleVocabularyTest.php b/core/modules/taxonomy/src/Tests/TermFieldMultipleVocabularyTest.php index 5c32231cd929..d3894d805b22 100644 --- a/core/modules/taxonomy/src/Tests/TermFieldMultipleVocabularyTest.php +++ b/core/modules/taxonomy/src/Tests/TermFieldMultipleVocabularyTest.php @@ -8,7 +8,7 @@ namespace Drupal\taxonomy\Tests; use Drupal\Core\Field\FieldStorageDefinitionInterface; -use Drupal\field\Entity\FieldConfig; +use Drupal\field\Entity\FieldStorageConfig; /** * Tests a taxonomy term reference field that allows multiple vocabularies. @@ -37,7 +37,7 @@ function setUp() { // Set up a field and instance. $this->field_name = drupal_strtolower($this->randomName()); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => $this->field_name, 'entity_type' => 'entity_test', 'type' => 'taxonomy_term_reference', @@ -116,9 +116,9 @@ function testTaxonomyTermFieldMultipleVocabularies() { $this->assertText($term1->getName(), 'Term 1 name is displayed.'); $this->assertNoText($term2->getName(), 'Term 2 name is not displayed.'); - // Verify that field and instance settings are correct. - $field = FieldConfig::loadByName('entity_test', $this->field_name); - $this->assertEqual(count($field->getSetting('allowed_values')), 1, 'Only one vocabulary is allowed for the field.'); + // Verify that field storage and instance settings are correct. + $field_storage = FieldStorageConfig::loadByName('entity_test', $this->field_name); + $this->assertEqual(count($field_storage->getSetting('allowed_values')), 1, 'Only one vocabulary is allowed for the field.'); // The widget should still be displayed. $this->drupalGet('entity_test/add'); diff --git a/core/modules/taxonomy/src/Tests/TermFieldTest.php b/core/modules/taxonomy/src/Tests/TermFieldTest.php index 43ce35832658..37f59ee3853f 100644 --- a/core/modules/taxonomy/src/Tests/TermFieldTest.php +++ b/core/modules/taxonomy/src/Tests/TermFieldTest.php @@ -6,7 +6,8 @@ */ namespace Drupal\taxonomy\Tests; -use Drupal\field\Entity\FieldConfig; + +use Drupal\field\Entity\FieldStorageConfig; /** * Tests the creation of term fields. @@ -15,6 +16,13 @@ */ class TermFieldTest extends TaxonomyTestBase { + /** + * The field storage to test against. + * + * @var \Drupal\field\FieldStorageConfigInterface + */ + protected $field_storage; + /** * Modules to enable. * @@ -37,9 +45,9 @@ function setUp() { $this->drupalLogin($web_user); $this->vocabulary = $this->createVocabulary(); - // Setup a field and instance. + // Setup a field. $this->field_name = drupal_strtolower($this->randomName()); - $this->field = entity_create('field_config', array( + $this->field_storage = entity_create('field_storage_config', array( 'name' => $this->field_name, 'entity_type' => 'entity_test', 'type' => 'taxonomy_term_reference', @@ -52,9 +60,9 @@ function setUp() { ), ) )); - $this->field->save(); + $this->field_storage->save(); entity_create('field_instance_config', array( - 'field' => $this->field, + 'field_storage' => $this->field_storage, 'bundle' => 'entity_test', ))->save(); entity_get_form_display('entity_test', 'entity_test', 'default') @@ -143,7 +151,7 @@ function testTaxonomyTermFieldInstanceSettingsAutocompleteWidget() { function testTaxonomyTermFieldChangeMachineName() { // Add several entries in the 'allowed_values' setting, to make sure that // they all get updated. - $this->field->settings['allowed_values'] = array( + $this->field_storage->settings['allowed_values'] = array( array( 'vocabulary' => $this->vocabulary->id(), 'parent' => '0', @@ -157,15 +165,15 @@ function testTaxonomyTermFieldChangeMachineName() { 'parent' => '0', ), ); - $this->field->save(); + $this->field_storage->save(); // Change the machine name. $new_name = drupal_strtolower($this->randomName()); $this->vocabulary->vid = $new_name; $this->vocabulary->save(); // Check that the field instance is still attached to the vocabulary. - $field = FieldConfig::loadByName('entity_test', $this->field_name); - $allowed_values = $field->getSetting('allowed_values'); + $field_storage = FieldStorageConfig::loadByName('entity_test', $this->field_name); + $allowed_values = $field_storage->getSetting('allowed_values'); $this->assertEqual($allowed_values[0]['vocabulary'], $new_name, 'Index 0: Machine name was updated correctly.'); $this->assertEqual($allowed_values[1]['vocabulary'], $new_name, 'Index 1: Machine name was updated correctly.'); $this->assertEqual($allowed_values[2]['vocabulary'], 'foo', 'Index 2: Machine name was left untouched.'); diff --git a/core/modules/taxonomy/src/Tests/TermIndexTest.php b/core/modules/taxonomy/src/Tests/TermIndexTest.php index 09fb6a1ff992..76bc2781b021 100644 --- a/core/modules/taxonomy/src/Tests/TermIndexTest.php +++ b/core/modules/taxonomy/src/Tests/TermIndexTest.php @@ -28,7 +28,7 @@ function setUp() { $this->vocabulary = $this->createVocabulary(); $this->field_name_1 = drupal_strtolower($this->randomName()); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => $this->field_name_1, 'entity_type' => 'node', 'type' => 'taxonomy_term_reference', @@ -59,7 +59,7 @@ function setUp() { ->save(); $this->field_name_2 = drupal_strtolower($this->randomName()); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => $this->field_name_2, 'entity_type' => 'node', 'type' => 'taxonomy_term_reference', diff --git a/core/modules/taxonomy/src/Tests/TermTest.php b/core/modules/taxonomy/src/Tests/TermTest.php index 2bd36200f689..ce47f3c47f7b 100644 --- a/core/modules/taxonomy/src/Tests/TermTest.php +++ b/core/modules/taxonomy/src/Tests/TermTest.php @@ -11,7 +11,7 @@ use Drupal\Component\Utility\String; use Drupal\Component\Utility\Tags; use Drupal\Core\Field\FieldStorageDefinitionInterface; -use Drupal\field\Entity\FieldConfig; +use Drupal\field\Entity\FieldStorageConfig; /** * Tests load, save and delete for taxonomy terms. @@ -27,7 +27,7 @@ function setUp() { $this->vocabulary = $this->createVocabulary(); $field_name = 'taxonomy_' . $this->vocabulary->id(); - $field = array( + entity_create('field_storage_config', array( 'name' => $field_name, 'entity_type' => 'node', 'type' => 'taxonomy_term_reference', @@ -40,8 +40,7 @@ function setUp() { ), ), ), - ); - entity_create('field_config', $field)->save(); + ))->save(); $this->instance = entity_create('field_instance_config', array( 'field_name' => $field_name, @@ -232,7 +231,7 @@ function testNodeTermCreationAndDeletion() { $field_name = $this->randomName(); $tag = $this->randomName(); $message = t("Taxonomy field @field_name not found.", array('@field_name' => $field_name)); - $this->assertFalse(FieldConfig::loadByName('node', $field_name), format_string('Field %field_name does not exist.', array('%field_name' => $field_name))); + $this->assertFalse(FieldStorageConfig::loadByName('node', $field_name), format_string('Field %field_name does not exist.', array('%field_name' => $field_name))); $this->drupalGet('taxonomy/autocomplete/node/' . $field_name, array('query' => array('q' => $tag))); $this->assertRaw($message, 'Autocomplete returns correct error message when the taxonomy field does not exist.'); } diff --git a/core/modules/taxonomy/src/Tests/TokenReplaceTest.php b/core/modules/taxonomy/src/Tests/TokenReplaceTest.php index 2a645de0872e..fac60e3da302 100644 --- a/core/modules/taxonomy/src/Tests/TokenReplaceTest.php +++ b/core/modules/taxonomy/src/Tests/TokenReplaceTest.php @@ -25,7 +25,7 @@ function setUp() { $this->drupalLogin($this->admin_user); $this->vocabulary = $this->createVocabulary(); $this->field_name = 'taxonomy_' . $this->vocabulary->id(); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => $this->field_name, 'entity_type' => 'node', 'type' => 'taxonomy_term_reference', diff --git a/core/modules/taxonomy/src/Tests/Views/TaxonomyTestBase.php b/core/modules/taxonomy/src/Tests/Views/TaxonomyTestBase.php index aee659b55e37..ee9cc44bf8af 100644 --- a/core/modules/taxonomy/src/Tests/Views/TaxonomyTestBase.php +++ b/core/modules/taxonomy/src/Tests/Views/TaxonomyTestBase.php @@ -78,7 +78,7 @@ protected function mockStandardInstall() { )); $this->vocabulary->save(); $this->field_name = 'field_' . $this->vocabulary->id(); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => $this->field_name, 'entity_type' => 'node', 'type' => 'taxonomy_term_reference', diff --git a/core/modules/taxonomy/src/Tests/VocabularyCrudTest.php b/core/modules/taxonomy/src/Tests/VocabularyCrudTest.php index 3f615096e406..7ca73d4cdc6f 100644 --- a/core/modules/taxonomy/src/Tests/VocabularyCrudTest.php +++ b/core/modules/taxonomy/src/Tests/VocabularyCrudTest.php @@ -141,7 +141,7 @@ function testTaxonomyVocabularyLoadMultiple() { */ function testTaxonomyVocabularyChangeMachineName() { // Add a field instance to the vocabulary. - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => 'field_test', 'entity_type' => 'taxonomy_term', 'type' => 'test_field', @@ -173,21 +173,21 @@ function testTaxonomyVocabularyChangeMachineName() { function testUninstallReinstall() { // Fields and field instances attached to taxonomy term bundles should be // removed when the module is uninstalled. - $this->field_name = drupal_strtolower($this->randomName() . '_field_name'); - $this->field_definition = array( - 'name' => $this->field_name, + $field_name = drupal_strtolower($this->randomName() . '_field_name'); + $storage_definition = array( + 'name' => $field_name, 'entity_type' => 'taxonomy_term', 'type' => 'text', 'cardinality' => 4 ); - entity_create('field_config', $this->field_definition)->save(); - $this->instance_definition = array( - 'field_name' => $this->field_name, + entity_create('field_storage_config', $storage_definition)->save(); + $instance_definition = array( + 'field_name' => $field_name, 'entity_type' => 'taxonomy_term', 'bundle' => $this->vocabulary->id(), 'label' => $this->randomName() . '_label', ); - entity_create('field_instance_config', $this->instance_definition)->save(); + entity_create('field_instance_config', $instance_definition)->save(); require_once DRUPAL_ROOT . '/core/includes/install.inc'; $this->container->get('module_handler')->uninstall(array('taxonomy')); @@ -199,7 +199,7 @@ function testUninstallReinstall() { // an instance of this field on the same bundle name should be successful. $this->vocabulary->enforceIsNew(); $this->vocabulary->save(); - entity_create('field_config', $this->field_definition)->save(); - entity_create('field_instance_config', $this->instance_definition)->save(); + entity_create('field_storage_config', $storage_definition)->save(); + entity_create('field_instance_config', $instance_definition)->save(); } } diff --git a/core/modules/taxonomy/taxonomy.views.inc b/core/modules/taxonomy/taxonomy.views.inc index a4fd292ff809..fa34f4fe6bc2 100644 --- a/core/modules/taxonomy/taxonomy.views.inc +++ b/core/modules/taxonomy/taxonomy.views.inc @@ -6,7 +6,7 @@ */ use Drupal\Core\Entity\ContentEntityDatabaseStorage; -use Drupal\field\FieldConfigInterface; +use Drupal\field\FieldStorageConfigInterface; /** * Implements hook_views_data(). @@ -388,19 +388,19 @@ function taxonomy_views_data_alter(&$data) { * * @see field_views_field_default_views_data() */ -function taxonomy_field_views_data(FieldConfigInterface $field) { - $data = field_views_field_default_views_data($field); +function taxonomy_field_views_data(FieldStorageConfigInterface $field_storage) { + $data = field_views_field_default_views_data($field_storage); foreach ($data as $table_name => $table_data) { foreach ($table_data as $field_name => $field_data) { if (isset($field_data['filter']) && $field_name != 'delta') { $data[$table_name][$field_name]['filter']['id'] = 'taxonomy_index_tid'; - $allowed_values = $field->getSetting('allowed_values'); + $allowed_values = $field_storage->getSetting('allowed_values'); $data[$table_name][$field_name]['filter']['vocabulary'] = $allowed_values[0]['vocabulary']; } } // Add the relationship only on the tid field. - $field_name = $field->getName(); + $field_name = $field_storage->getName(); $data[$table_name][$field_name . '_target_id']['relationship'] = array( 'id' => 'standard', 'base' => 'taxonomy_term_data', @@ -418,9 +418,9 @@ function taxonomy_field_views_data(FieldConfigInterface $field) { * * Views integration to provide reverse relationships on term references. */ -function taxonomy_field_views_data_views_data_alter(array &$data, FieldConfigInterface $field) { - $field_name = $field->getName(); - $entity_type_id = $field->entity_type; +function taxonomy_field_views_data_views_data_alter(array &$data, FieldStorageConfigInterface $field_storage) { + $field_name = $field_storage->getName(); + $entity_type_id = $field_storage->entity_type; $entity_type = \Drupal::entityManager()->getDefinition($entity_type_id); $pseudo_field_name = 'reverse_' . $field_name . '_' . $entity_type_id; @@ -432,7 +432,7 @@ function taxonomy_field_views_data_views_data_alter(array &$data, FieldConfigInt 'id' => 'entity_reverse', 'field_name' => $field_name, 'entity_type' => $entity_type_id, - 'field table' => ContentEntityDatabaseStorage::_fieldTableName($field), + 'field table' => ContentEntityDatabaseStorage::_fieldTableName($field_storage), 'field field' => $field_name . '_target_id', 'base' => $entity_type->getBaseTable(), 'base field' => $entity_type->getKey('id'), diff --git a/core/modules/telephone/src/Tests/TelephoneFieldTest.php b/core/modules/telephone/src/Tests/TelephoneFieldTest.php index a7f88924867a..22b7becf6792 100644 --- a/core/modules/telephone/src/Tests/TelephoneFieldTest.php +++ b/core/modules/telephone/src/Tests/TelephoneFieldTest.php @@ -46,7 +46,7 @@ function setUp() { function testTelephoneField() { // Add the telepone field to the article content type. - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => 'field_telephone', 'entity_type' => 'node', 'type' => 'telephone', diff --git a/core/modules/telephone/src/Tests/TelephoneItemTest.php b/core/modules/telephone/src/Tests/TelephoneItemTest.php index aa2f3d4cd989..733f1a3fe40d 100644 --- a/core/modules/telephone/src/Tests/TelephoneItemTest.php +++ b/core/modules/telephone/src/Tests/TelephoneItemTest.php @@ -29,7 +29,7 @@ public function setUp() { parent::setUp(); // Create a telephone field and instance for validation. - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => 'field_test', 'entity_type' => 'entity_test', 'type' => 'telephone', diff --git a/core/modules/text/src/Tests/Formatter/TextFormatterTest.php b/core/modules/text/src/Tests/Formatter/TextFormatterTest.php index 156363a5602e..b9ba45a4be1b 100644 --- a/core/modules/text/src/Tests/Formatter/TextFormatterTest.php +++ b/core/modules/text/src/Tests/Formatter/TextFormatterTest.php @@ -55,7 +55,7 @@ public function setUp() { ))->save(); // Set up two fields: one with text processing enabled, the other disabled. - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => 'processed_text', 'entity_type' => $this->entityType, 'type' => 'text', @@ -70,7 +70,7 @@ public function setUp() { 'text_processing' => TRUE, ), ))->save(); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => 'unprocessed_text', 'entity_type' => $this->entityType, 'type' => 'text', diff --git a/core/modules/text/src/Tests/Formatter/TextPlainUnitTest.php b/core/modules/text/src/Tests/Formatter/TextPlainUnitTest.php index a3c1339851f2..327e3182ea11 100644 --- a/core/modules/text/src/Tests/Formatter/TextPlainUnitTest.php +++ b/core/modules/text/src/Tests/Formatter/TextPlainUnitTest.php @@ -54,16 +54,16 @@ function setUp() { $this->formatter_type = 'string'; $this->formatter_settings = array(); - $this->field = entity_create('field_config', array( + $this->fieldStorage = entity_create('field_storage_config', array( 'name' => $this->field_name, 'entity_type' => $this->entity_type, 'type' => $this->field_type, 'settings' => $this->field_settings, )); - $this->field->save(); + $this->fieldStorage->save(); $this->instance = entity_create('field_instance_config', array( - 'field' => $this->field, + 'field_storage' => $this->fieldStorage, 'bundle' => $this->bundle, 'label' => $this->randomName(), 'settings' => $this->instance_settings, diff --git a/core/modules/text/src/Tests/TextFieldTest.php b/core/modules/text/src/Tests/TextFieldTest.php index 46ab33de456f..aee702262507 100644 --- a/core/modules/text/src/Tests/TextFieldTest.php +++ b/core/modules/text/src/Tests/TextFieldTest.php @@ -43,25 +43,26 @@ function setUp() { function testTextFieldValidation() { // Create a field with settings to validate. $max_length = 3; - $this->field = entity_create('field_config', array( - 'name' => drupal_strtolower($this->randomName()), + $field_name = drupal_strtolower($this->randomName()); + $field_storage = entity_create('field_storage_config', array( + 'name' => $field_name, 'entity_type' => 'entity_test', 'type' => 'text', 'settings' => array( 'max_length' => $max_length, ) )); - $this->field->save(); + $field_storage->save(); entity_create('field_instance_config', array( - 'field' => $this->field, + 'field_storage' => $field_storage, 'bundle' => 'entity_test', ))->save(); // Test validation with valid and invalid values. $entity = entity_create('entity_test'); for ($i = 0; $i <= $max_length + 2; $i++) { - $entity->{$this->field->name}->value = str_repeat('x', $i); - $violations = $entity->{$this->field->name}->validate(); + $entity->{$field_name}->value = str_repeat('x', $i); + $violations = $entity->{$field_name}->validate(); if ($i <= $max_length) { $this->assertEqual(count($violations), 0, "Length $i does not cause validation error when max_length is $max_length"); } @@ -84,15 +85,15 @@ function testTextfieldWidgets() { */ function _testTextfieldWidgets($field_type, $widget_type) { // Setup a field and instance - $this->field_name = drupal_strtolower($this->randomName()); - $this->field = entity_create('field_config', array( - 'name' => $this->field_name, + $field_name = drupal_strtolower($this->randomName()); + $field_storage = entity_create('field_storage_config', array( + 'name' => $field_name, 'entity_type' => 'entity_test', 'type' => $field_type )); - $this->field->save(); + $field_storage->save(); entity_create('field_instance_config', array( - 'field' => $this->field, + 'field_storage' => $field_storage, 'bundle' => 'entity_test', 'label' => $this->randomName() . '_label', 'settings' => array( @@ -100,7 +101,7 @@ function _testTextfieldWidgets($field_type, $widget_type) { ), ))->save(); entity_get_form_display('entity_test', 'entity_test', 'default') - ->setComponent($this->field_name, array( + ->setComponent($field_name, array( 'type' => $widget_type, 'settings' => array( 'placeholder' => 'A placeholder on ' . $widget_type, @@ -108,13 +109,13 @@ function _testTextfieldWidgets($field_type, $widget_type) { )) ->save(); entity_get_display('entity_test', 'entity_test', 'full') - ->setComponent($this->field_name) + ->setComponent($field_name) ->save(); // Display creation form. $this->drupalGet('entity_test/add'); - $this->assertFieldByName("{$this->field_name}[0][value]", '', 'Widget is displayed'); - $this->assertNoFieldByName("{$this->field_name}[0][format]", '1', 'Format selector is not displayed'); + $this->assertFieldByName("{$field_name}[0][value]", '', 'Widget is displayed'); + $this->assertNoFieldByName("{$field_name}[0][format]", '1', 'Format selector is not displayed'); $this->assertRaw(format_string('placeholder="A placeholder on !widget_type"', array('!widget_type' => $widget_type))); // Submit with some value. @@ -122,7 +123,7 @@ function _testTextfieldWidgets($field_type, $widget_type) { $edit = array( 'user_id' => 1, 'name' => $this->randomName(), - "{$this->field_name}[0][value]" => $value, + "{$field_name}[0][value]" => $value, ); $this->drupalPostForm(NULL, $edit, t('Save')); preg_match('|entity_test/manage/(\d+)|', $this->url, $match); @@ -150,15 +151,15 @@ function testTextfieldWidgetsFormatted() { */ function _testTextfieldWidgetsFormatted($field_type, $widget_type) { // Setup a field and instance - $this->field_name = drupal_strtolower($this->randomName()); - $this->field = entity_create('field_config', array( - 'name' => $this->field_name, + $field_name = drupal_strtolower($this->randomName()); + $field_storage = entity_create('field_storage_config', array( + 'name' => $field_name, 'entity_type' => 'entity_test', 'type' => $field_type )); - $this->field->save(); + $field_storage->save(); entity_create('field_instance_config', array( - 'field' => $this->field, + 'field_storage' => $field_storage, 'bundle' => 'entity_test', 'label' => $this->randomName() . '_label', 'settings' => array( @@ -166,12 +167,12 @@ function _testTextfieldWidgetsFormatted($field_type, $widget_type) { ), ))->save(); entity_get_form_display('entity_test', 'entity_test', 'default') - ->setComponent($this->field_name, array( + ->setComponent($field_name, array( 'type' => $widget_type, )) ->save(); entity_get_display('entity_test', 'entity_test', 'full') - ->setComponent($this->field_name) + ->setComponent($field_name) ->save(); // Disable all text formats besides the plain text fallback format. @@ -186,15 +187,15 @@ function _testTextfieldWidgetsFormatted($field_type, $widget_type) { // Display the creation form. Since the user only has access to one format, // no format selector will be displayed. $this->drupalGet('entity_test/add'); - $this->assertFieldByName("{$this->field_name}[0][value]", '', 'Widget is displayed'); - $this->assertNoFieldByName("{$this->field_name}[0][format]", '', 'Format selector is not displayed'); + $this->assertFieldByName("{$field_name}[0][value]", '', 'Widget is displayed'); + $this->assertNoFieldByName("{$field_name}[0][format]", '', 'Format selector is not displayed'); // Submit with data that should be filtered. $value = '<em>' . $this->randomName() . '</em>'; $edit = array( 'user_id' => 1, 'name' => $this->randomName(), - "{$this->field_name}[0][value]" => $value, + "{$field_name}[0][value]" => $value, ); $this->drupalPostForm(NULL, $edit, t('Save')); preg_match('|entity_test/manage/(\d+)|', $this->url, $match); @@ -229,14 +230,14 @@ function _testTextfieldWidgetsFormatted($field_type, $widget_type) { // Display edition form. // We should now have a 'text format' selector. $this->drupalGet('entity_test/manage/' . $id); - $this->assertFieldByName("{$this->field_name}[0][value]", NULL, 'Widget is displayed'); - $this->assertFieldByName("{$this->field_name}[0][format]", NULL, 'Format selector is displayed'); + $this->assertFieldByName("{$field_name}[0][value]", NULL, 'Widget is displayed'); + $this->assertFieldByName("{$field_name}[0][format]", NULL, 'Format selector is displayed'); // Edit and change the text format to the new one that was created. $edit = array( 'user_id' => 1, 'name' => $this->randomName(), - "{$this->field_name}[0][format]" => $format_id, + "{$field_name}[0][format]" => $format_id, ); $this->drupalPostForm(NULL, $edit, t('Save')); $this->assertText(t('entity_test @id has been updated.', array('@id' => $id)), 'Entity was updated'); @@ -249,4 +250,5 @@ function _testTextfieldWidgetsFormatted($field_type, $widget_type) { $this->drupalSetContent(drupal_render($content)); $this->assertRaw($value, 'Value is displayed unfiltered'); } + } diff --git a/core/modules/text/src/Tests/TextWithSummaryItemTest.php b/core/modules/text/src/Tests/TextWithSummaryItemTest.php index 178fc58fe645..67cbec5c88d9 100644 --- a/core/modules/text/src/Tests/TextWithSummaryItemTest.php +++ b/core/modules/text/src/Tests/TextWithSummaryItemTest.php @@ -26,11 +26,11 @@ class TextWithSummaryItemTest extends FieldUnitTestBase { public static $modules = array('filter'); /** - * Field entity. + * Field storage entity. * - * @var \Drupal\field\Entity\FieldConfig. + * @var \Drupal\field\Entity\FieldStorageConfig. */ - protected $field; + protected $fieldStorage; /** * Field instance. @@ -103,7 +103,7 @@ public function testCrudAndUpdate() { */ protected function createField($entity_type) { // Create a field . - $this->field = entity_create('field_config', array( + $this->fieldStorage = entity_create('field_storage_config', array( 'name' => 'summary_field', 'entity_type' => $entity_type, 'type' => 'text_with_summary', @@ -111,9 +111,9 @@ protected function createField($entity_type) { 'max_length' => 10, ) )); - $this->field->save(); + $this->fieldStorage->save(); $this->instance = entity_create('field_instance_config', array( - 'field' => $this->field, + 'field_storage' => $this->fieldStorage, 'bundle' => $entity_type, 'settings' => array( 'text_processing' => 0, diff --git a/core/modules/user/src/Tests/UserCreateTest.php b/core/modules/user/src/Tests/UserCreateTest.php index b0495607d8b3..d1bba88e9b83 100644 --- a/core/modules/user/src/Tests/UserCreateTest.php +++ b/core/modules/user/src/Tests/UserCreateTest.php @@ -33,7 +33,7 @@ protected function testUserAdd() { // Create a field and an instance. $field_name = 'test_field'; - $field = array( + entity_create('field_storage_config', array( 'name' => $field_name, 'entity_type' => 'user', 'module' => 'image', @@ -44,10 +44,9 @@ protected function testUserAdd() { 'settings' => array( 'uri_scheme' => 'public', ), - ); - entity_create('field_config', $field)->save(); + ))->save(); - $instance = array( + entity_create('field_instance_config', array( 'field_name' => $field_name, 'entity_type' => 'user', 'label' => 'Picture', @@ -63,8 +62,7 @@ protected function testUserAdd() { 'max_resolution' => '85x85', 'min_resolution' => '', ), - ); - entity_create('field_instance_config', $instance)->save(); + ))->save(); // Test user creation page for valid fields. $this->drupalGet('admin/people/create'); diff --git a/core/modules/user/src/Tests/UserRegistrationTest.php b/core/modules/user/src/Tests/UserRegistrationTest.php index fe5239b7184d..97aed33b52a1 100644 --- a/core/modules/user/src/Tests/UserRegistrationTest.php +++ b/core/modules/user/src/Tests/UserRegistrationTest.php @@ -192,15 +192,15 @@ function testRegistrationDefaultValues() { */ function testRegistrationWithUserFields() { // Create a field, and an instance on 'user' entity type. - $field = entity_create('field_config', array( + $field_storage = entity_create('field_storage_config', array( 'name' => 'test_user_field', 'entity_type' => 'user', 'type' => 'test_field', 'cardinality' => 1, )); - $field->save(); + $field_storage->save(); $instance = entity_create('field_instance_config', array( - 'field' => $field, + 'field_storage' => $field_storage, 'label' => 'Some user field', 'bundle' => 'user', 'required' => TRUE, @@ -247,8 +247,8 @@ function testRegistrationWithUserFields() { $this->assertEqual($new_user->test_user_field->value, $value, 'The field value was correclty saved.'); // Check that the 'add more' button works. - $field->cardinality = FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED; - $field->save(); + $field_storage->cardinality = FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED; + $field_storage->save(); foreach (array('js', 'nojs') as $js) { $this->drupalGet('user/register'); // Add two inputs. @@ -277,4 +277,5 @@ function testRegistrationWithUserFields() { $this->assertEqual($new_user->test_user_field[2]->value, $value + 2, format_string('@js : The field value was correclty saved.', array('@js' => $js))); } } + } diff --git a/core/modules/views/src/Tests/DefaultViewsTest.php b/core/modules/views/src/Tests/DefaultViewsTest.php index 9c65b35b427b..d33b8631464e 100644 --- a/core/modules/views/src/Tests/DefaultViewsTest.php +++ b/core/modules/views/src/Tests/DefaultViewsTest.php @@ -57,7 +57,7 @@ protected function setUp() { // Setup a field and instance. $this->field_name = drupal_strtolower($this->randomName()); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => $this->field_name, 'entity_type' => 'node', 'type' => 'taxonomy_term_reference', diff --git a/core/modules/views/src/Tests/Wizard/TaggedWithTest.php b/core/modules/views/src/Tests/Wizard/TaggedWithTest.php index c46a0f0bd129..5e095e300f5c 100644 --- a/core/modules/views/src/Tests/Wizard/TaggedWithTest.php +++ b/core/modules/views/src/Tests/Wizard/TaggedWithTest.php @@ -49,8 +49,9 @@ function setUp() { $this->tag_vocabulary->save(); // Create the tag field itself. - $this->tag_field = entity_create('field_config', array( - 'name' => 'field_views_testing_tags', + $this->tag_field_name = 'field_views_testing_tags'; + $this->tag_field_storage = entity_create('field_storage_config', array( + 'name' => $this->tag_field_name, 'entity_type' => 'node', 'type' => 'taxonomy_term_reference', 'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED, @@ -63,12 +64,12 @@ function setUp() { ), ), )); - $this->tag_field->save(); + $this->tag_field_storage->save(); // Create an instance of the tag field on one of the content types, and // configure it to display an autocomplete widget. $this->tag_instance = array( - 'field' => $this->tag_field, + 'field_storage' => $this->tag_field_storage, 'bundle' => $this->node_type_with_tags->type, ); entity_create('field_instance_config', $this->tag_instance)->save(); @@ -104,11 +105,11 @@ function testTaggedWith() { // Create three nodes, with different tags. $edit = array(); $edit['title[0][value]'] = $node_tag1_title = $this->randomName(); - $edit[$this->tag_field->name] = 'tag1'; + $edit[$this->tag_field_name] = 'tag1'; $this->drupalPostForm($node_add_path, $edit, t('Save')); $edit = array(); $edit['title[0][value]'] = $node_tag1_tag2_title = $this->randomName(); - $edit[$this->tag_field->name] = 'tag1, tag2'; + $edit[$this->tag_field_name] = 'tag1, tag2'; $this->drupalPostForm($node_add_path, $edit, t('Save')); $edit = array(); $edit['title[0][value]'] = $node_no_tags_title = $this->randomName(); diff --git a/core/modules/views/tests/modules/views_test_data/views_test_data.views_execution.inc b/core/modules/views/tests/modules/views_test_data/views_test_data.views_execution.inc index 5e778539faaa..1675be5cfa07 100644 --- a/core/modules/views/tests/modules/views_test_data/views_test_data.views_execution.inc +++ b/core/modules/views/tests/modules/views_test_data/views_test_data.views_execution.inc @@ -5,6 +5,7 @@ * Provides views data and hooks for views_test_data module. */ +use Drupal\field\FieldStorageConfigInterface; use Drupal\views\ViewExecutable; use Drupal\views\ViewStorageInterface; @@ -25,14 +26,14 @@ function views_test_data_views_form_substitutions(ViewExecutable $view) { /** * Implements hook_field_views_data(). */ -function views_test_data_field_views_data($field) { +function views_test_data_field_views_data(FieldStorageConfigInterface $field_storage) { \Drupal::state()->set('views_hook_test_field_views_data', TRUE); } /** * Implements hook_field_views_data_alter(). */ -function views_test_data_field_views_data_alter(&$data, $field, $module) { +function views_test_data_field_views_data_alter(&$data, FieldStorageConfigInterface $field_storage, $module) { \Drupal::state()->set('views_hook_test_field_views_data_alter', TRUE); } diff --git a/core/modules/views/views.api.php b/core/modules/views/views.api.php index 836f4bea3cb2..78bdd0f6da9e 100644 --- a/core/modules/views/views.api.php +++ b/core/modules/views/views.api.php @@ -294,14 +294,14 @@ function hook_views_data_alter(array &$data) { * Override the default Views data for a Field API field. * * The field module's implementation of hook_views_data() invokes this for each - * field, in the module that defines the field type (as declared in the field - * array). It is not invoked in other modules. + * field storage, in the module that defines the field type. It is not invoked + * in other modules. * * If no hook implementation exists, hook_views_data() falls back to * field_views_field_default_views_data(). * - * @param \Drupal\field\FieldConfigInterface $field - * The field config entity. + * @param \Drupal\field\FieldStorageConfigInterface $field_storage + * The field storage config entity. * * @return array * An array of views data, in the same format as the return value of @@ -311,15 +311,15 @@ function hook_views_data_alter(array &$data) { * @see hook_field_views_data_alter() * @see hook_field_views_data_views_data_alter() */ -function hook_field_views_data(\Drupal\field\FieldConfigInterface $field) { - $data = field_views_field_default_views_data($field); +function hook_field_views_data(\Drupal\field\FieldStorageConfigInterface $field_storage) { + $data = field_views_field_default_views_data($field_storage); foreach ($data as $table_name => $table_data) { // Add the relationship only on the target_id field. - $data[$table_name][$field->getName() . '_target_id']['relationship'] = array( + $data[$table_name][$field_storage->getName() . '_target_id']['relationship'] = array( 'id' => 'standard', 'base' => 'file_managed', 'base field' => 'target_id', - 'label' => t('image from !field_name', array('!field_name' => $field->getName())), + 'label' => t('image from !field_name', array('!field_name' => $field_storage->getName())), ); } @@ -332,21 +332,21 @@ function hook_field_views_data(\Drupal\field\FieldConfigInterface $field) { * This is called on all modules even if there is no hook_field_views_data() * implementation for the field, and therefore may be used to alter the * default data that field_views_field_default_views_data() supplies for the - * field. + * field storage. * * @param array $data - * The views data for the field. This has the same format as the return - * value of hook_views_data(). - * @param \Drupal\field\FieldConfigInterface $field - * The field config entity. + * The views data for the field storage. This has the same format as the + * return value of hook_views_data(). + * @param \Drupal\field\FieldStorageConfigInterface $field_storage + * The field storage config entity. * * @see field_views_data() * @see hook_field_views_data() * @see hook_field_views_data_views_data_alter() */ -function hook_field_views_data_alter(array &$data, \Drupal\field\FieldConfigInterface $field) { - $entity_type_id = $field->entity_type; - $field_name = $field->getName(); +function hook_field_views_data_alter(array &$data, \Drupal\field\FieldStorageConfigInterface $field_storage) { + $entity_type_id = $field_storage->entity_type; + $field_name = $field_storage->getName(); $entity_type = \Drupal::entityManager()->getDefinition($entity_type_id); $pseudo_field_name = 'reverse_' . $field_name . '_' . $entity_type_id; @@ -358,7 +358,7 @@ function hook_field_views_data_alter(array &$data, \Drupal\field\FieldConfigInte 'id' => 'entity_reverse', 'field_name' => $field_name, 'entity_type' => $entity_type_id, - 'field table' => ContentEntityDatabaseStorage::_fieldTableName($field), + 'field table' => ContentEntityDatabaseStorage::_fieldTableName($field_storage), 'field field' => $field_name . '_target_id', 'base' => $entity_type->getBaseTable(), 'base field' => $entity_type->getKey('id'), @@ -377,11 +377,11 @@ function hook_field_views_data_alter(array &$data, \Drupal\field\FieldConfigInte * Alter the Views data on a per field basis. * * The field module's implementation of hook_views_data_alter() invokes this for - * each field, in the module that defines the field type (as declared in the - * field array). It is not invoked in other modules. + * each field storage, in the module that defines the field type. It is not + * invoked in other modules. * * Unlike hook_field_views_data_alter(), this operates on the whole of the views - * data. This allows a field module to add data that concerns its fields in + * data. This allows a field type to add data that concerns its fields in * other tables, which would not yet be defined at the point when * hook_field_views_data() and hook_field_views_data_alter() are invoked. For * example, entityreference adds reverse relationships on the tables for the @@ -392,14 +392,14 @@ function hook_field_views_data_alter(array &$data, \Drupal\field\FieldConfigInte * * @param array $data * The views data. - * @param \Drupal\field\FieldConfigInterface $field - * The field config entity. + * @param \Drupal\field\FieldStorageConfigInterface $field + * The field storage config entity. * * @see hook_field_views_data() * @see hook_field_views_data_alter() * @see field_views_data_alter() */ -function hook_field_views_data_views_data_alter(array &$data, \Drupal\field\FieldConfigInterface $field) { +function hook_field_views_data_views_data_alter(array &$data, \Drupal\field\FieldStorageConfigInterface $field) { $field_name = $field->getName(); $data_key = 'field_data_' . $field_name; $entity_type_id = $field->entity_type; diff --git a/core/modules/views_ui/admin.inc b/core/modules/views_ui/admin.inc index e90ef359a886..1bd863661f04 100644 --- a/core/modules/views_ui/admin.inc +++ b/core/modules/views_ui/admin.inc @@ -226,9 +226,9 @@ function views_ui_taxonomy_autocomplete_validate($element, &$form_state) { // Get the machine names of the vocabularies we will search, keyed by the // vocabulary IDs. $field_storage_definitions = \Drupal::entityManager()->getFieldStorageDefinitions($element['#entity_type']); - $field = $field_storage_definitions[$element['#field_name']]; + $field_storage = $field_storage_definitions[$element['#field_name']]; $vocabularies = array(); - $allowed_values = $field->getSetting('allowed_values'); + $allowed_values = $field_storage->getSetting('allowed_values'); if (!empty($allowed_values)) { foreach ($allowed_values as $tree) { if ($vocabulary = entity_load('taxonomy_vocabulary', $tree['vocabulary'])) { diff --git a/core/profiles/standard/config/install/field.instance.node.article.field_image.yml b/core/profiles/standard/config/install/field.instance.node.article.field_image.yml index 05702fd70130..31ba6386b31f 100644 --- a/core/profiles/standard/config/install/field.instance.node.article.field_image.yml +++ b/core/profiles/standard/config/install/field.instance.node.article.field_image.yml @@ -28,5 +28,5 @@ langcode: und field_type: image dependencies: entity: - - field.field.node.field_image + - field.storage.node.field_image - node.type.article diff --git a/core/profiles/standard/config/install/field.instance.node.article.field_tags.yml b/core/profiles/standard/config/install/field.instance.node.article.field_tags.yml index 369306a37568..0960d3f4d7c6 100644 --- a/core/profiles/standard/config/install/field.instance.node.article.field_tags.yml +++ b/core/profiles/standard/config/install/field.instance.node.article.field_tags.yml @@ -13,5 +13,5 @@ status: true langcode: und dependencies: entity: - - field.field.node.field_tags + - field.storage.node.field_tags - node.type.article diff --git a/core/profiles/standard/config/install/field.instance.user.user.user_picture.yml b/core/profiles/standard/config/install/field.instance.user.user.user_picture.yml index 64693008797d..a7a2ef72cc46 100644 --- a/core/profiles/standard/config/install/field.instance.user.user.user_picture.yml +++ b/core/profiles/standard/config/install/field.instance.user.user.user_picture.yml @@ -28,4 +28,4 @@ settings: field_type: image dependencies: entity: - - field.field.user.user_picture + - field.storage.user.user_picture diff --git a/core/profiles/standard/config/install/field.field.node.field_image.yml b/core/profiles/standard/config/install/field.storage.node.field_image.yml similarity index 100% rename from core/profiles/standard/config/install/field.field.node.field_image.yml rename to core/profiles/standard/config/install/field.storage.node.field_image.yml diff --git a/core/profiles/standard/config/install/field.field.node.field_tags.yml b/core/profiles/standard/config/install/field.storage.node.field_tags.yml similarity index 100% rename from core/profiles/standard/config/install/field.field.node.field_tags.yml rename to core/profiles/standard/config/install/field.storage.node.field_tags.yml diff --git a/core/profiles/standard/config/install/field.field.user.user_picture.yml b/core/profiles/standard/config/install/field.storage.user.user_picture.yml similarity index 100% rename from core/profiles/standard/config/install/field.field.user.user_picture.yml rename to core/profiles/standard/config/install/field.storage.user.user_picture.yml diff --git a/core/tests/Drupal/Tests/Core/Config/StorageComparerTest.php b/core/tests/Drupal/Tests/Core/Config/StorageComparerTest.php index 15962fee8424..b3c7fc590ef4 100644 --- a/core/tests/Drupal/Tests/Core/Config/StorageComparerTest.php +++ b/core/tests/Drupal/Tests/Core/Config/StorageComparerTest.php @@ -68,12 +68,12 @@ protected function getConfigData() { 'uuid' => $uuid->generate(), 'dependencies' => array( 'entity' => array( - 'field.field.node.body' + 'field.storage.node.body' ), ), ), // Config entity which is required by another config entity. - 'field.field.node.body' => array( + 'field.storage.node.body' => array( 'id' => 'node.body', 'uuid' => $uuid->generate(), 'dependencies' => array( @@ -140,7 +140,7 @@ public function testCreateChangelistNoChange() { */ public function testCreateChangelistCreate() { $target_data = $source_data = $this->getConfigData(); - unset($target_data['field.field.node.body']); + unset($target_data['field.storage.node.body']); unset($target_data['field.instance.node.article.body']); unset($target_data['views.view.test_view']); @@ -168,7 +168,7 @@ public function testCreateChangelistCreate() { $this->storageComparer->createChangelist(); $expected = array( - 'field.field.node.body', + 'field.storage.node.body', 'views.view.test_view', 'field.instance.node.article.body', ); @@ -182,7 +182,7 @@ public function testCreateChangelistCreate() { */ public function testCreateChangelistDelete() { $target_data = $source_data = $this->getConfigData(); - unset($source_data['field.field.node.body']); + unset($source_data['field.storage.node.body']); unset($source_data['field.instance.node.article.body']); unset($source_data['views.view.test_view']); @@ -212,7 +212,7 @@ public function testCreateChangelistDelete() { $expected = array( 'field.instance.node.article.body', 'views.view.test_view', - 'field.field.node.body', + 'field.storage.node.body', ); $this->assertEquals($expected, $this->storageComparer->getChangelist('delete')); $this->assertEmpty($this->storageComparer->getChangelist('create')); @@ -226,7 +226,7 @@ public function testCreateChangelistUpdate() { $target_data = $source_data = $this->getConfigData(); $source_data['system.site']['title'] = 'Drupal New!'; $source_data['field.instance.node.article.body']['new_config_key'] = 'new data'; - $source_data['field.field.node.body']['new_config_key'] = 'new data'; + $source_data['field.storage.node.body']['new_config_key'] = 'new data'; $this->sourceStorage->expects($this->once()) ->method('listAll') @@ -252,7 +252,7 @@ public function testCreateChangelistUpdate() { $this->storageComparer->createChangelist(); $expected = array( - 'field.field.node.body', + 'field.storage.node.body', 'system.site', 'field.instance.node.article.body', ); diff --git a/core/tests/Drupal/Tests/Core/Entity/ContentEntityDatabaseStorageTest.php b/core/tests/Drupal/Tests/Core/Entity/ContentEntityDatabaseStorageTest.php index 7c93ba3442b4..849d0630998e 100644 --- a/core/tests/Drupal/Tests/Core/Entity/ContentEntityDatabaseStorageTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/ContentEntityDatabaseStorageTest.php @@ -986,14 +986,14 @@ public function testFieldSqlSchemaForEntityWithStringIdentifier() { ->will($this->returnValue($this->fieldDefinitions)); // Define a field definition for a test_field field. - $field = $this->getMock('\Drupal\Core\Field\FieldStorageDefinitionInterface'); - $field->deleted = FALSE; + $field_storage = $this->getMock('\Drupal\field\FieldStorageConfigInterface'); + $field_storage->deleted = FALSE; - $field->expects($this->any()) + $field_storage->expects($this->any()) ->method('getName') ->will($this->returnValue('test_field')); - $field->expects($this->any()) + $field_storage->expects($this->any()) ->method('getTargetEntityTypeId') ->will($this->returnValue('test_entity')); @@ -1009,11 +1009,11 @@ public function testFieldSqlSchemaForEntityWithStringIdentifier() { 'indexes' => array(), 'foreign keys' => array(), ); - $field->expects($this->any()) + $field_storage->expects($this->any()) ->method('getSchema') ->will($this->returnValue($field_schema)); - $schema = ContentEntityDatabaseStorage::_fieldSqlSchema($field); + $schema = ContentEntityDatabaseStorage::_fieldSqlSchema($field_storage); // Make sure that the entity_id schema field if of type varchar. $this->assertEquals($schema['test_entity__test_field']['fields']['entity_id']['type'], 'varchar'); -- GitLab