diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityInterface.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityInterface.php index b355cb5..ccbe113 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityInterface.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityInterface.php @@ -85,8 +85,8 @@ 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 + * \Drupal\field\Entity\FieldStorageConfig::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 diff --git a/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php b/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php index 2e29857..7a83390 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php @@ -18,7 +18,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; /** @@ -1750,7 +1750,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 d5a6334..facca39 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 be7f0fe..cf6947b 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 ee27996..6489541 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 706fa69..dadcf4b 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 65c08c5..35e1341 100644 --- a/core/modules/block_content/src/Tests/BlockContentFieldTest.php +++ b/core/modules/block_content/src/Tests/BlockContentFieldTest.php @@ -25,9 +25,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. @@ -64,15 +64,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, @@ -80,12 +80,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', )) @@ -95,8 +95,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 391a255..95fd135 100644 --- a/core/modules/comment/comment.install +++ b/core/modules/comment/comment.install @@ -5,14 +5,14 @@ * Install, update and uninstall functions for the Comment module. */ -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(); } @@ -55,7 +55,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 0d3d736..500e32c 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -23,9 +23,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; @@ -188,12 +188,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'); } @@ -737,7 +737,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 1bed270..1c7843d 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 = $this->entityManager->getStorage('field_storage_config')->create(array( 'entity_type' => $entity_type, 'name' => $field_name, 'type' => 'comment', @@ -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 15831e0..24db82d 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 777d92b..ec442fe 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; /** @@ -493,8 +493,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 d653e56..b7178fc 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 .= '

' . $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(), )) . '

'; } } diff --git a/core/modules/comment/src/Tests/CommentFieldsTest.php b/core/modules/comment/src/Tests/CommentFieldsTest.php index 70b3ecd..76a87c4 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; /** @@ -47,8 +47,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'; @@ -57,15 +57,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); } /** @@ -77,9 +77,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 d139a38..103782a 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; /** @@ -76,10 +76,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 33c4813..9762065 100644 --- a/core/modules/comment/src/Tests/CommentNodeChangesTest.php +++ b/core/modules/comment/src/Tests/CommentNodeChangesTest.php @@ -33,11 +33,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 f4f6fec..d59efee 100644 --- a/core/modules/comment/src/Tests/CommentNonNodeTest.php +++ b/core/modules/comment/src/Tests/CommentNonNodeTest.php @@ -402,9 +402,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 e1be25d..71929ce 100644 --- a/core/modules/comment/src/Tests/CommentStringIdEntitiesTest.php +++ b/core/modules/comment/src/Tests/CommentStringIdEntitiesTest.php @@ -56,7 +56,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( @@ -64,7 +64,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 7314c30..b87604c 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. @@ -74,9 +74,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 fb040b7..24e7b75 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; @@ -125,7 +125,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); @@ -162,7 +162,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 5be58c8..c56001a 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; /** @@ -44,15 +44,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.'); } @@ -61,13 +61,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 b705b16..ccc3a1d 100644 --- a/core/modules/comment/src/Tests/CommentValidationTest.php +++ b/core/modules/comment/src/Tests/CommentValidationTest.php @@ -55,7 +55,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 baa12f5..f1b6378 100644 --- a/core/modules/config/src/Tests/ConfigExportImportUITest.php +++ b/core/modules/config/src/Tests/ConfigExportImportUITest.php @@ -72,27 +72,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'); @@ -106,18 +107,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(); @@ -128,7 +129,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 1624211..b25126f 100644 --- a/core/modules/config/src/Tests/ConfigImportAllTest.php +++ b/core/modules/config/src/Tests/ConfigImportAllTest.php @@ -67,8 +67,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); + $fields = \Drupal::entityManager()->getStorage('field_storage_config')->loadMultiple(); + \Drupal::entityManager()->getStorage('field_storage_config')->delete($fields); // 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 4308ca7..4ddcf15 100644 --- a/core/modules/contact/src/Tests/Views/ContactFieldsTest.php +++ b/core/modules/contact/src/Tests/Views/ContactFieldsTest.php @@ -23,11 +23,11 @@ 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; public static function getInfo() { return array( @@ -40,12 +40,12 @@ public static function getInfo() { 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', @@ -53,7 +53,7 @@ protected function setUp() { ))->save(); entity_create('field_instance_config', array( - 'field' => $this->field, + 'field_storage' => $this->field_storage, 'bundle' => 'contact_message', ))->save(); @@ -66,7 +66,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 383d043..06a355b 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 0d22898..287729b 100644 --- a/core/modules/content_translation/content_translation.module +++ b/core/modules/content_translation/content_translation.module @@ -679,7 +679,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 0db6520..9028806 100644 --- a/core/modules/content_translation/src/Tests/ContentTranslationSettingsTest.php +++ b/core/modules/content_translation/src/Tests/ContentTranslationSettingsTest.php @@ -203,7 +203,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 5749baf..9a169c9 100644 --- a/core/modules/content_translation/src/Tests/ContentTranslationSyncImageTest.php +++ b/core/modules/content_translation/src/Tests/ContentTranslationSyncImageTest.php @@ -55,7 +55,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 b299b3f..bf6ea23 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 62b69cb..c240e73 100644 --- a/core/modules/datetime/src/Tests/DateTimeFieldTest.php +++ b/core/modules/datetime/src/Tests/DateTimeFieldTest.php @@ -24,11 +24,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. @@ -58,22 +58,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(); @@ -84,7 +84,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(); } @@ -92,7 +92,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'); @@ -159,10 +159,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'); @@ -226,10 +226,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') @@ -294,17 +294,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(); @@ -313,14 +313,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('', '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. @@ -329,20 +329,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('', '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. @@ -350,7 +350,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'); } /** @@ -359,9 +359,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 79f0781..6f50ace 100644 --- a/core/modules/datetime/src/Tests/DateTimeItemTest.php +++ b/core/modules/datetime/src/Tests/DateTimeItemTest.php @@ -35,15 +35,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 dcaf31d..bc96764 100644 --- a/core/modules/editor/src/Tests/QuickEditIntegrationTest.php +++ b/core/modules/editor/src/Tests/QuickEditIntegrationTest.php @@ -150,8 +150,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 f0c8e0c..f812e05 100644 --- a/core/modules/entity/src/Tests/EntityDisplayTest.php +++ b/core/modules/entity/src/Tests/EntityDisplayTest.php @@ -146,15 +146,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(); @@ -167,7 +167,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( @@ -323,15 +323,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 6caf775..277605c 100644 --- a/core/modules/entity/src/Tests/EntityFormDisplayTest.php +++ b/core/modules/entity/src/Tests/EntityFormDisplayTest.php @@ -55,16 +55,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(); @@ -77,7 +77,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( @@ -186,15 +186,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 48ffc92..7fcc560 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 47f0179..e35884b 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 cabf660..269ad8c 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 61e3308..7e478da 100644 --- a/core/modules/entity_reference/src/Tests/EntityReferenceAutoCreateTest.php +++ b/core/modules/entity_reference/src/Tests/EntityReferenceAutoCreateTest.php @@ -35,7 +35,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 ff29c03..a2a0a93 100644 --- a/core/modules/entity_reference/src/Tests/EntityReferenceFieldDefaultValueTest.php +++ b/core/modules/entity_reference/src/Tests/EntityReferenceFieldDefaultValueTest.php @@ -48,15 +48,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', @@ -70,16 +70,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'); @@ -88,7 +88,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 d5357ba..a494684 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. @@ -46,20 +44,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. * * @var array @@ -91,8 +75,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 61d0ee5..02fad12 100644 --- a/core/modules/entity_reference/src/Tests/EntityReferenceFormatterTest.php +++ b/core/modules/entity_reference/src/Tests/EntityReferenceFormatterTest.php @@ -64,7 +64,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 368c1d2..a9de6e8 100644 --- a/core/modules/entity_reference/src/Tests/EntityReferenceSelectionAccessTest.php +++ b/core/modules/entity_reference/src/Tests/EntityReferenceSelectionAccessTest.php @@ -61,8 +61,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, @@ -73,9 +73,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', @@ -204,8 +204,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, @@ -215,9 +215,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', @@ -348,8 +348,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, @@ -360,9 +360,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 a0ab8db..e38fa73 100644 --- a/core/modules/entity_reference/src/Tests/EntityReferenceSelectionSortTest.php +++ b/core/modules/entity_reference/src/Tests/EntityReferenceSelectionSortTest.php @@ -37,7 +37,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', @@ -54,8 +54,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, @@ -65,9 +65,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 4b8dd06..8d73a86 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; @@ -63,7 +63,7 @@ protected function setUp() { ViewTestData::createTestViews(get_class($this), array('entity_reference_test_views')); - $field = FieldConfig::create(array( + $field = FieldStorageConfig::create(array( 'settings' => array( 'target_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 56328a3..120ad5d 100644 --- a/core/modules/entity_reference/src/Tests/Views/SelectionTest.php +++ b/core/modules/entity_reference/src/Tests/Views/SelectionTest.php @@ -39,8 +39,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, @@ -50,9 +50,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 7018b5f..f680f5a 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 f364c51..49d59b0 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,45 +249,45 @@ 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. */ -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 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 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 5695f40..576a48a 100644 --- a/core/modules/field/field.module +++ b/core/modules/field/field.module @@ -125,7 +125,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; @@ -162,15 +162,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; } @@ -323,11 +323,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. @@ -347,16 +347,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 4a289cf..a17e6f2 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 f74e97c..f5f1b33 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 a33df39..fe2fbe6 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 + // 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 field deletion is staged. - if (!$field->deleted) { - $field->delete(); + 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 79830db..7a41fa2 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 af025e3..2fd46c9 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,25 @@ 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. + // @todo update error messages... 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 +264,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 +279,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 +323,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 +334,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 +389,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 +740,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 c6575ec..0000000 --- a/core/modules/field/src/FieldConfigInterface.php +++ /dev/null @@ -1,34 +0,0 @@ -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); } @@ -149,7 +147,7 @@ public function loadByProperties(array $conditions = array()) { break; case 'field_id': - case 'field_uuid': + case 'field_storage_uuid': $checked_value = $field->uuid(); break; diff --git a/core/modules/field/src/FieldStorageConfigInterface.php b/core/modules/field/src/FieldStorageConfigInterface.php new file mode 100644 index 0000000..4f4eb04 --- /dev/null +++ b/core/modules/field/src/FieldStorageConfigInterface.php @@ -0,0 +1,34 @@ +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 0000000..ef709ba --- /dev/null +++ b/core/modules/field/src/FieldStorageConfigUpdateForbiddenException.php @@ -0,0 +1,13 @@ +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; } @@ -161,14 +163,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; } /** @@ -926,8 +928,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/Tests/BulkDeleteTest.php b/core/modules/field/src/Tests/BulkDeleteTest.php index 8e96eab..c297e58 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; - /** * Unit test class for field bulk delete and batch purge functionality. @@ -23,7 +21,7 @@ class BulkDeleteTest extends FieldUnitTestBase { * * @var array */ - protected $fields; + protected $fieldStorages; /** * The entities to use in this test. @@ -103,7 +101,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(); @@ -114,36 +112,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(); } @@ -165,8 +163,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. @@ -176,24 +174,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. @@ -223,10 +221,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. @@ -241,7 +239,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'); } @@ -258,34 +256,34 @@ 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. @@ -316,13 +314,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. @@ -341,20 +339,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 6a16101..9c7015b 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 CRUD operations. + * Tests field storage CRUD operations. */ class CrudTest extends FieldUnitTestBase { @@ -26,8 +26,8 @@ class CrudTest extends FieldUnitTestBase { public static function getInfo() { return array( - 'name' => 'Field CRUD tests', - 'description' => 'Test field create, read, update, and delete.', + 'name' => 'Field storage CRUD tests', + 'description' => 'Test field storage create, read, update, and delete.', 'group' => 'Field API', ); } @@ -38,42 +38,42 @@ public static function getInfo() { // 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) { @@ -82,11 +82,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) { @@ -95,11 +95,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) { @@ -107,11 +107,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) { @@ -120,12 +120,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) { @@ -134,12 +134,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) { @@ -148,12 +148,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) { @@ -163,12 +163,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) { @@ -177,50 +177,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', ); @@ -230,60 +230,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). @@ -292,13 +289,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( @@ -312,14 +309,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. @@ -327,53 +324,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) { @@ -382,22 +378,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', )); @@ -412,22 +408,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', @@ -435,18 +431,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 9a9ed1e..56c4dc4 100644 --- a/core/modules/field/src/Tests/DisplayApiTest.php +++ b/core/modules/field/src/Tests/DisplayApiTest.php @@ -72,7 +72,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', @@ -100,7 +100,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 e01d129..b6762b3 100644 --- a/core/modules/field/src/Tests/Email/EmailFieldTest.php +++ b/core/modules/field/src/Tests/Email/EmailFieldTest.php @@ -22,11 +22,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. @@ -60,14 +60,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 dfeab31..0312af6 100644 --- a/core/modules/field/src/Tests/Email/EmailItemTest.php +++ b/core/modules/field/src/Tests/Email/EmailItemTest.php @@ -35,7 +35,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 59b0cba..9b59c09 100644 --- a/core/modules/field/src/Tests/FieldAccessTest.php +++ b/core/modules/field/src/Tests/FieldAccessTest.php @@ -51,14 +51,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, ); @@ -67,7 +67,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 73a3b1e..4a29ce0 100644 --- a/core/modules/field/src/Tests/FieldAttachOtherTest.php +++ b/core/modules/field/src/Tests/FieldAttachOtherTest.php @@ -54,9 +54,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. @@ -71,7 +71,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( @@ -81,7 +81,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); @@ -98,14 +98,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->content = drupal_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->content = drupal_render($content); $this->assertNoRaw($this->instance->getLabel(), "Hidden field: label is not displayed."); @@ -116,7 +116,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( @@ -134,7 +134,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( @@ -183,7 +183,7 @@ function testFieldAttachCache() { // Initialize random values and a test entity. $entity_init = entity_create('entity_test', array('type' => $this->instance->bundle)); $langcode = LanguageInterface::LANGCODE_NOT_SPECIFIED; - $values = $this->_generateTestFieldValues($this->field->getCardinality()); + $values = $this->_generateTestFieldValues($this->field_storage->getCardinality()); // Non-cacheable entity type. $entity_type = 'entity_test'; @@ -226,7 +226,7 @@ function testFieldAttachCache() { $this->assertEqual($cache->data[$langcode][$this->field_name_2], $values, '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'); @@ -238,7 +238,7 @@ function testFieldAttachCache() { $this->assertEqual($cache->data[$langcode][$this->field_name_2], $values, '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(); @@ -275,11 +275,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"); } @@ -297,7 +297,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"); } @@ -322,11 +322,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; @@ -336,11 +336,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 9ec1d7c..f52b9b3 100644 --- a/core/modules/field/src/Tests/FieldAttachStorageTest.php +++ b/core/modules/field/src/Tests/FieldAttachStorageTest.php @@ -51,7 +51,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. @@ -115,13 +115,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], @@ -242,7 +242,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(); @@ -300,7 +300,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()); @@ -351,13 +351,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, @@ -370,7 +370,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 3275b47..2c4edd9 100644 --- a/core/modules/field/src/Tests/FieldDataCountTest.php +++ b/core/modules/field/src/Tests/FieldDataCountTest.php @@ -13,7 +13,7 @@ * Tests counting field data records. * * @see \Drupal\Core\Entity\FieldableEntityStorageInterface::countFieldData() - * @see \Drupal\field\Entity\FieldConfig::hasData() + * @see \Drupal\field\Entity\FieldStorageConfig::hasData() */ class FieldDataCountTest extends FieldUnitTestBase { @@ -27,8 +27,8 @@ class FieldDataCountTest extends FieldUnitTestBase { */ public static function getInfo() { return array( - 'name' => 'Field config hasData() tests.', - 'description' => 'Tests counting field data records and the hasData() method on FieldConfig entity.', + 'name' => 'Field storage config hasData() tests.', + 'description' => 'Tests counting field data records and the hasData() method on FieldStorageConfig entity.', 'group' => 'Field API', ); } @@ -47,29 +47,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++) { @@ -85,7 +85,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() @@ -94,17 +94,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 7a1c4fb..0989301 100644 --- a/core/modules/field/src/Tests/FieldImportCreateTest.php +++ b/core/modules/field/src/Tests/FieldImportCreateTest.php @@ -33,9 +33,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)); @@ -47,14 +47,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.'); @@ -82,7 +82,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_config_name = "field.storage.$field_id"; $instance_config_name = "field.instance.$instance_id"; // One field with two field instances. @@ -90,7 +90,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_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"; @@ -111,12 +111,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 b0485c4..2885a70 100644 --- a/core/modules/field/src/Tests/FieldImportDeleteTest.php +++ b/core/modules/field/src/Tests/FieldImportDeleteTest.php @@ -35,21 +35,21 @@ public static function getInfo() { 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"; @@ -60,15 +60,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))); @@ -80,10 +80,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); @@ -93,22 +93,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 dd6fe61..322ed3d 100644 --- a/core/modules/field/src/Tests/FieldImportDeleteUninstallTest.php +++ b/core/modules/field/src/Tests/FieldImportDeleteUninstallTest.php @@ -46,28 +46,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(); @@ -87,7 +85,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'); @@ -99,7 +97,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(); @@ -110,10 +108,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.'); } /** @@ -121,15 +119,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(); @@ -148,7 +146,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'); @@ -159,8 +157,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.'); @@ -170,8 +168,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 c8f6db0..333c917 100644 --- a/core/modules/field/src/Tests/FieldImportDeleteUninstallUiTest.php +++ b/core/modules/field/src/Tests/FieldImportDeleteUninstallUiTest.php @@ -43,28 +43,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(); @@ -79,7 +77,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(); @@ -97,7 +95,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 @@ -117,10 +115,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 2b867e5..bc116d4 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; @@ -18,25 +18,25 @@ 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; public static function getInfo() { return array( @@ -49,15 +49,15 @@ public static function getInfo() { 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', ); @@ -73,7 +73,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 @@ -84,18 +84,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) { @@ -104,8 +104,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) { @@ -119,30 +119,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'); @@ -160,24 +160,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. @@ -189,41 +189,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 2100833..63c9269 100644 --- a/core/modules/field/src/Tests/FieldUnitTestBase.php +++ b/core/modules/field/src/Tests/FieldUnitTestBase.php @@ -62,22 +62,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 1a57a4c..9ebdb31 100644 --- a/core/modules/field/src/Tests/FieldValidationTest.php +++ b/core/modules/field/src/Tests/FieldValidationTest.php @@ -41,7 +41,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++) { @@ -61,7 +61,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 255c19d..c38b9d7 100644 --- a/core/modules/field/src/Tests/FormTest.php +++ b/core/modules/field/src/Tests/FormTest.php @@ -27,21 +27,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. @@ -64,18 +64,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', @@ -95,10 +95,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) @@ -177,12 +177,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) @@ -208,11 +208,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) @@ -252,15 +252,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) @@ -343,17 +343,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', @@ -390,10 +390,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) @@ -451,10 +451,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( @@ -498,14 +498,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) @@ -513,19 +513,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) @@ -587,14 +587,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 b7f0708..0445137 100644 --- a/core/modules/field/src/Tests/NestedFormTest.php +++ b/core/modules/field/src/Tests/NestedFormTest.php @@ -34,12 +34,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', @@ -63,8 +63,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 f9efa00..2c5767c 100644 --- a/core/modules/field/src/Tests/Number/NumberFieldTest.php +++ b/core/modules/field/src/Tests/Number/NumberFieldTest.php @@ -22,20 +22,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. * * @var \Drupal\user\UserInterface @@ -63,7 +49,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', @@ -155,7 +141,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', @@ -259,7 +245,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', @@ -358,13 +344,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 011bf09..94c6ebe 100644 --- a/core/modules/field/src/Tests/Number/NumberItemTest.php +++ b/core/modules/field/src/Tests/Number/NumberItemTest.php @@ -36,7 +36,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 d3afd9a..3641a99 100644 --- a/core/modules/field/src/Tests/ShapeItemTest.php +++ b/core/modules/field/src/Tests/ShapeItemTest.php @@ -41,18 +41,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 a7680d3..aae5ea8 100644 --- a/core/modules/field/src/Tests/TestItemTest.php +++ b/core/modules/field/src/Tests/TestItemTest.php @@ -42,18 +42,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 618d8a5..58f22f1 100644 --- a/core/modules/field/src/Tests/TranslationTest.php +++ b/core/modules/field/src/Tests/TranslationTest.php @@ -55,11 +55,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. @@ -92,11 +92,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); @@ -128,7 +128,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]); } @@ -148,11 +148,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(); @@ -164,7 +164,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]); } @@ -182,7 +182,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 18b9ef2..2577ddc 100644 --- a/core/modules/field/src/Tests/TranslationWebTest.php +++ b/core/modules/field/src/Tests/TranslationWebTest.php @@ -36,11 +36,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. @@ -69,11 +69,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(); @@ -103,7 +103,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); @@ -132,7 +132,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 be0d496..bd7e75b 100644 --- a/core/modules/field/src/Tests/Views/ApiDataTest.php +++ b/core/modules/field/src/Tests/Views/ApiDataTest.php @@ -13,11 +13,6 @@ */ class ApiDataTest extends FieldTestBase { - /** - * Stores the fields for this test case. - */ - var $fields; - public static function getInfo() { return array( 'name' => 'Field: Views Data', @@ -61,9 +56,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 e5af4ab..43222e0 100644 --- a/core/modules/field/src/Tests/Views/FieldTestBase.php +++ b/core/modules/field/src/Tests/Views/FieldTestBase.php @@ -39,7 +39,7 @@ * * @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 15a4914..a9d2555 100644 --- a/core/modules/field/src/Tests/Views/HandlerFieldFieldTest.php +++ b/core/modules/field/src/Tests/Views/HandlerFieldFieldTest.php @@ -48,21 +48,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(); @@ -72,14 +72,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); } @@ -95,8 +95,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; @@ -117,7 +117,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); @@ -131,8 +131,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); @@ -140,14 +140,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); @@ -167,7 +167,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 81242db..1e4bf28 100644 --- a/core/modules/field/src/Tests/reEnableModuleFieldTest.php +++ b/core/modules/field/src/Tests/reEnableModuleFieldTest.php @@ -49,14 +49,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(); @@ -96,7 +96,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 93e090b..6ebda87 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 6c9b7d4..13c846d 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 @@ 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 e21b180..45302e3 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 c1537bf..d1fd117 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_2 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 35d694a..ea2b33a 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 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 440536e..50f76c1 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 faf3e18..c69e8ba 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 dbe30a7..2bf3bb7 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 ccc0c13..9e04777 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 1d2b2ca..6a11a15 100644 --- a/core/modules/field/tests/src/FieldInstanceConfigEntityUnitTest.php +++ b/core/modules/field/tests/src/FieldInstanceConfigEntityUnitTest.php @@ -49,6 +49,13 @@ class FieldInstanceConfigEntityUnitTest extends UnitTestCase { protected $uuid; /** + * The mock field storage. + * + * @var \Drupal\field\FieldStorageConfigInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $fieldStorage; + + /** * {@inheritdoc} */ public static function getInfo() { @@ -78,12 +85,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')); @@ -92,7 +99,7 @@ public function setUp() { ->method('getFieldStorageDefinitions') ->with('test_entity_type') ->will($this->returnValue(array( - $this->field->getName() => $this->field, + $this->fieldStorage->getName() => $this->fieldStorage, ))); } @@ -127,14 +134,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']); } @@ -142,7 +149,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 85% rename from core/modules/field/tests/src/FieldConfigEntityUnitTest.php rename to core/modules/field/tests/src/FieldStorageConfigEntityUnitTest.php index 0e1c723..59671d1 100644 --- a/core/modules/field/tests/src/FieldConfigEntityUnitTest.php +++ b/core/modules/field/tests/src/FieldStorageConfigEntityUnitTest.php @@ -2,22 +2,22 @@ /** * @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 Drupal * @group Config */ -class FieldConfigEntityUnitTest extends UnitTestCase { +class FieldStorageConfigEntityUnitTest extends UnitTestCase { /** * The entity type used for testing. @@ -53,7 +53,7 @@ class FieldConfigEntityUnitTest extends UnitTestCase { public static function getInfo() { return array( 'description' => '', - 'name' => '\Drupal\field\Entity\FieldConfig unit test', + 'name' => '\Drupal\field\Entity\FieldStorageConfig unit test', 'group' => 'Entity', ); } @@ -90,7 +90,7 @@ 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 + // 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') @@ -106,9 +106,9 @@ public function testCalculateDependencies() { ->will($this->returnValue($fieldConfigentityType)); $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, 'fieldConfig'); - $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 1dbee70..9fd1efb 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\FieldConfigListBuilder'); 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 826150b..2b3672f 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 b801f4c..74252e0 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 300b317..6d0cf27e 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; /** @@ -134,7 +134,7 @@ 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, + '#route_name' => 'field_ui.storage_edit_' . $this->entity_type, '#route_parameters' => $route_parameters, '#options' => array('attributes' => array('title' => $this->t('Edit field settings.'))), ), @@ -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' => '
 
', '#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 { diff --git a/core/modules/field_ui/src/Form/FieldEditForm.php b/core/modules/field_ui/src/Form/FieldStorageEditForm.php similarity index 96% rename from core/modules/field_ui/src/Form/FieldEditForm.php rename to core/modules/field_ui/src/Form/FieldStorageEditForm.php index aea0a64..1898372 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. diff --git a/core/modules/field_ui/src/Plugin/Derivative/FieldUiLocalTask.php b/core/modules/field_ui/src/Plugin/Derivative/FieldUiLocalTask.php index 1238afd..35d0218 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 57f7efd..9820438 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 3e54cea..1196bb8 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 d22030d..af5d16c 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 functionality of the 'Manage fields' screen. @@ -46,20 +46,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()) @@ -113,7 +111,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']); } @@ -138,12 +136,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')); @@ -188,7 +186,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'. @@ -245,9 +243,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); @@ -290,7 +288,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' @@ -372,16 +370,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.'); } /** @@ -416,33 +414,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); } @@ -458,7 +457,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, @@ -546,8 +545,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.'); } /** @@ -555,7 +554,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.views.inc b/core/modules/file/file.views.inc index e1029d5..09fc3ad 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/Tests/FileFieldTestBase.php b/core/modules/file/src/Tests/FileFieldTestBase.php index 644f6f9..78f39c9 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 f901002..943eee6 100644 --- a/core/modules/file/src/Tests/FileFieldWidgetTest.php +++ b/core/modules/file/src/Tests/FileFieldWidgetTest.php @@ -217,7 +217,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); @@ -229,12 +229,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 c4fd4b4..131addb 100644 --- a/core/modules/file/src/Tests/FileItemTest.php +++ b/core/modules/file/src/Tests/FileItemTest.php @@ -45,7 +45,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 7c9e3a2..2d52a29 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,7 +7,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\file\Entity\File; -use Drupal\field\FieldConfigInterface; +use Drupal\field\FieldStorageConfigInterface; /** * Form constructor for testing a 'managed_file' element. @@ -73,10 +73,10 @@ function file_module_test_form_submit($form, &$form_state) { /** * 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 710b8bd..568eb7e 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: list_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 2b3d14f..8aacf39 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 3b38876..bb68136 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; /** @@ -37,8 +37,8 @@ public static function getInfo() { */ 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 exists.'); // Create a taxonomy term. $term = entity_create('taxonomy_term', array( @@ -83,8 +83,8 @@ 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 has been deleted.'); } @@ -93,13 +93,13 @@ function testForumUninstallWithField() { */ function testForumUninstallWithoutField() { // 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 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 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 8bb4777..2ebff74 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 4064236..9d7fb67 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; /** @@ -364,7 +363,7 @@ function image_entity_presave(EntityInterface $entity) { $field = $entity->getFieldStorageDefinition(); $default_settings = \Drupal::service('plugin.manager.field.field_type')->getDefaultInstanceSettings('image'); } - elseif ($entity_type_id == 'field_config') { + elseif ($entity_type_id == 'field_storage_config') { $field = $entity; $default_settings = \Drupal::service('plugin.manager.field.field_type')->getDefaultSettings('image'); } @@ -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); } @@ -475,9 +474,9 @@ function image_field_instance_config_update(FieldInstanceConfigInterface $field_ } /** - * 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; diff --git a/core/modules/image/image.views.inc b/core/modules/image/image.views.inc index fe2d59a..5120350 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 f4626a4..3b5a90d 100644 --- a/core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php +++ b/core/modules/image/src/Tests/ImageFieldDefaultImagesTest.php @@ -50,7 +50,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' => '', @@ -67,30 +67,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, @@ -116,7 +111,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(), @@ -137,7 +132,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(), @@ -182,12 +177,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(), @@ -294,8 +289,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', @@ -304,30 +299,26 @@ public function testInvalidDefaultImage() { 'fid' => 100000, ) ), - ); - $instance = array( - 'field_name' => $field['name'], + )); + $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(), - 'entity_type' => 'node', - 'bundle' => 'page', 'settings' => array( 'default_image' => array( 'fid' => 100000, ) ), - ); - $field_config = entity_create('field_config', $field); - $field_config->save(); - $settings = $field_config->getSettings(); + )); + $field_instance->save(); + $settings = $field_instance->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(); - // 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 5058d2f..bfe9127 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; /** * Test class to check that formatters and display settings are working. @@ -253,7 +253,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')); @@ -295,11 +295,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( @@ -337,11 +337,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. @@ -353,12 +353,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 f4e1021..48b69f1 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 53472a8..f65c1ea 100644 --- a/core/modules/image/src/Tests/ImageItemTest.php +++ b/core/modules/image/src/Tests/ImageItemTest.php @@ -50,7 +50,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 64bfdf1..8f87978 100644 --- a/core/modules/image/src/Tests/ImageThemeFunctionTest.php +++ b/core/modules/image/src/Tests/ImageThemeFunctionTest.php @@ -45,7 +45,7 @@ public static function getInfo() { 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 99976bc..99a40d1 100644 --- a/core/modules/link/src/Tests/LinkFieldTest.php +++ b/core/modules/link/src/Tests/LinkFieldTest.php @@ -26,9 +26,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. @@ -68,14 +68,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, @@ -192,14 +192,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( @@ -310,15 +310,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( @@ -452,15 +452,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 8125790..7a20c83 100644 --- a/core/modules/link/src/Tests/LinkItemTest.php +++ b/core/modules/link/src/Tests/LinkItemTest.php @@ -36,7 +36,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/EntityFieldConfig.php index 8d2c312..8b9a61b 100644 --- a/core/modules/migrate/src/Plugin/migrate/destination/EntityFieldConfig.php +++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityFieldConfig.php @@ -9,7 +9,7 @@ /** * @MigrateDestination( - * id = "entity:field_config" + * id = "entity:field_storage_config" * ) */ class EntityFieldConfig extends EntityConfigBase { 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 2a5ccc4..908aece 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 @@ -16,4 +16,4 @@ process: type: constants.type settings: constants.settings destination: - plugin: entity:field_config + plugin: entity:field_storage_config 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 3e6edbf..dff41e4 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 @@ -75,4 +75,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 05cd8e2..4259807 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 @@ -18,4 +18,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 ed53dd1..6567b4f 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 @@ -15,4 +15,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 183a265..ac0cad1 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 @@ -25,4 +25,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 13d3bf6..68576cb 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 @@ -18,7 +18,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 17171c2..5d58e87 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateCckFieldRevisionTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateCckFieldRevisionTest.php @@ -37,7 +37,7 @@ public static function getInfo() { */ protected function setUp() { parent::setUp(); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'entity_type' => 'node', 'name' => 'field_test', 'type' => 'text', @@ -47,7 +47,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 1d5c3ce..e65f083 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateCckFieldValuesTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateCckFieldValuesTest.php @@ -37,7 +37,7 @@ public static function getInfo() { */ protected function setUp() { parent::setUp(); - entity_create('field_config', array( + entity_create('field_storage_config', array( 'entity_type' => 'node', 'name' => 'field_test', 'type' => 'text', @@ -47,7 +47,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', @@ -58,7 +58,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 ac5c9c7..fd38a2a 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 @@ */ 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 0bc5309..fe035a6 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateCommentVariableFieldTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateCommentVariableFieldTest.php @@ -23,7 +23,7 @@ class MigrateCommentVariableFieldTest extends MigrateDrupalTestBase { public static function getInfo() { return array( 'name' => 'Migrate comment variables to a field,', - 'description' => 'Upgrade comment variables to field.field.node.comment.yml', + 'description' => 'Upgrade comment variables to field.storage.node.comment.yml', 'group' => 'Migrate Drupal', ); } @@ -50,7 +50,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_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 f35fc45..d24d2d9 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateCommentVariableInstanceTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateCommentVariableInstanceTest.php @@ -47,7 +47,7 @@ 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', diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateFieldInstanceTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateFieldInstanceTest.php index dfaa2a3..a7a423c 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateFieldInstanceTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateFieldInstanceTest.php @@ -174,7 +174,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 b891231..47e636f 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateFieldTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateFieldTest.php @@ -53,32 +53,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'); @@ -87,13 +87,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 436ed9a..cc300f4 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateProfileValuesTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateProfileValuesTest.php @@ -48,43 +48,43 @@ public static function getInfo() { 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' => 'list_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' => 'list_boolean', diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateTermNodeTestBase.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateTermNodeTestBase.php index 1d8cc99..47ea02e 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 a1d25ba..bbe1997 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 ceac437..b89edf4 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateUploadFieldTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateUploadFieldTest.php @@ -51,8 +51,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 ebd61fa..23d3ed4 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateUploadInstanceTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateUploadInstanceTest.php @@ -53,7 +53,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 9184d2c..d69c208 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateUserPictureFieldTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateUserPictureFieldTest.php @@ -42,8 +42,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 f6881de..ed4f150 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateUserPictureInstanceTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateUserPictureInstanceTest.php @@ -45,7 +45,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 e29143e..5808fa7 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateUserProfileEntityDisplayTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateUserProfileEntityDisplayTest.php @@ -41,43 +41,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' => 'list_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' => 'list_boolean', diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateUserProfileEntityFormDisplayTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateUserProfileEntityFormDisplayTest.php index 947b662..a68f67d 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateUserProfileEntityFormDisplayTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateUserProfileEntityFormDisplayTest.php @@ -36,43 +36,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' => 'list_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' => 'list_boolean', diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateUserProfileFieldInstanceTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateUserProfileFieldInstanceTest.php index b866689..59a28ee 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateUserProfileFieldInstanceTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateUserProfileFieldInstanceTest.php @@ -114,7 +114,7 @@ protected function createFields() { 'profile_love_migrations' => 'list_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 69af4a0..db4086f 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateUserProfileFieldTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateUserProfileFieldTest.php @@ -48,36 +48,36 @@ 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, 'list_boolean', 'Field type is list_boolean.'); + $field_storage = entity_load('field_storage_config', 'user.profile_sell_address'); + $this->assertEqual($field_storage->type, 'list_boolean', 'Field type is list_boolean.'); // Migrated selection field. - $field = entity_load('field_config', 'user.profile_sold_to'); - $this->assertEqual($field->type, 'list_text', 'Field type is list_text.'); + $field_storage = entity_load('field_storage_config', 'user.profile_sold_to'); + $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.'); + $field_storage = entity_load('field_storage_config', 'user.profile_birthdate'); + $this->assertEqual($field_storage->type, 'datetime', 'Field type is datetime.'); } } diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateUserTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateUserTest.php index d894b1c..57692c1 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateUserTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateUserTest.php @@ -47,7 +47,7 @@ public static function getInfo() { 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 4b7066c..d0167c3 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateVocabularyEntityDisplayTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateVocabularyEntityDisplayTest.php @@ -39,7 +39,7 @@ public static function getInfo() { 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 00022f6..9bded15 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateVocabularyEntityFormDisplayTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateVocabularyEntityFormDisplayTest.php @@ -39,7 +39,7 @@ public static function getInfo() { 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 53b78c4..c624c88 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateVocabularyFieldInstanceTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateVocabularyFieldInstanceTest.php @@ -62,7 +62,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 df4781c..7fc6403 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateVocabularyFieldTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateVocabularyFieldTest.php @@ -67,10 +67,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 fc8b713..dfad3e7 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; @@ -372,19 +372,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 67bdbe3..4562d91 100644 --- a/core/modules/node/src/Tests/MultiStepNodeFormBasicOptionsTest.php +++ b/core/modules/node/src/Tests/MultiStepNodeFormBasicOptionsTest.php @@ -37,7 +37,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 dfcb72f..6b455dd 100644 --- a/core/modules/node/src/Tests/NodeAccessFieldTest.php +++ b/core/modules/node/src/Tests/NodeAccessFieldTest.php @@ -59,7 +59,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 7af2816..0cabf87 100644 --- a/core/modules/node/src/Tests/NodeAccessLanguageAwareCombinationTest.php +++ b/core/modules/node/src/Tests/NodeAccessLanguageAwareCombinationTest.php @@ -55,7 +55,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' => 'list_boolean', @@ -65,10 +65,10 @@ public function setUp() { 'allowed_values' => array(0 => 'Not private', 1 => '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 6012dfc..ee92719 100644 --- a/core/modules/node/src/Tests/NodeAccessLanguageAwareTest.php +++ b/core/modules/node/src/Tests/NodeAccessLanguageAwareTest.php @@ -48,7 +48,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' => 'list_boolean', @@ -58,10 +58,10 @@ public function setUp() { 'allowed_values' => array(0 => 'Not private', 1 => '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 5139bb5..51051b5 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; @@ -62,9 +62,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 d1635c5..c0e5488 100644 --- a/core/modules/node/src/Tests/PagePreviewTest.php +++ b/core/modules/node/src/Tests/PagePreviewTest.php @@ -67,7 +67,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/options/options.module b/core/modules/options/options.module index d9a1b24..90ddc5a 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 b01e582..c5986d0 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 ed775b4..ed08893 100644 --- a/core/modules/options/src/Tests/OptionsFieldTest.php +++ b/core/modules/options/src/Tests/OptionsFieldTest.php @@ -45,21 +45,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'); @@ -67,8 +67,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'); @@ -80,8 +80,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 baecfca..508139a 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; /** @@ -229,10 +229,10 @@ function testOptionsAllowedValuesBoolean() { $this->drupalGet($this->admin_path); $this->assertFieldByName('on', $on, t("The 'On' value is stored correctly.")); $this->assertFieldByName('off', $off, t("The 'Off' value is stored correctly.")); - $field = FieldConfig::loadByName('node', $this->field_name); - $this->assertEqual($field->getSetting('allowed_values'), $allowed_values, 'The allowed value is correct'); - $this->assertNull($field->getSetting('on'), 'The on value is not saved into settings'); - $this->assertNull($field->getSetting('off'), 'The off value is not saved into settings'); + $field_storage = FieldStorageConfig::loadByName('node', $this->field_name); + $this->assertEqual($field_storage->getSetting('allowed_values'), $allowed_values, 'The allowed value is correct'); + $this->assertNull($field_storage->getSetting('on'), 'The on value is not saved into settings'); + $this->assertNull($field_storage->getSetting('off'), 'The off value is not saved into settings'); } /** @@ -256,7 +256,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, @@ -269,7 +269,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'; } /** @@ -292,8 +292,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 272e026..ef8eb06 100644 --- a/core/modules/options/src/Tests/OptionsFieldUnitTestBase.php +++ b/core/modules/options/src/Tests/OptionsFieldUnitTestBase.php @@ -30,18 +30,18 @@ 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 bcec12c..e243b5e 100644 --- a/core/modules/options/src/Tests/OptionsWidgetsTest.php +++ b/core/modules/options/src/Tests/OptionsWidgetsTest.php @@ -22,23 +22,23 @@ 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; /** - * A boolean field to use in this test class. + * A boolean field storage to use in this test class. * - * @var \Drupal\field\Entity\FieldConfig + * @var \Drupal\field\Entity\FieldStorageConfig */ protected $bool; @@ -61,8 +61,8 @@ public static function getInfo() { 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', @@ -81,8 +81,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', @@ -99,8 +99,8 @@ function setUp() { )); $this->card_2->save(); - // Boolean field. - $this->bool = entity_create('field_config', array( + // Boolean field storage. + $this->bool = entity_create('field_storage_config', array( 'name' => 'bool', 'entity_type' => 'entity_test', 'type' => 'list_boolean', @@ -127,7 +127,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(); @@ -184,7 +184,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(); @@ -273,7 +273,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, )); @@ -372,7 +372,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(); @@ -492,7 +492,7 @@ function testSelectListMultiple() { function testOnOffCheckbox() { // Create an instance of the 'boolean' field. entity_create('field_instance_config', array( - 'field' => $this->bool, + 'field_storage' => $this->bool, 'bundle' => 'entity_test', ))->save(); entity_get_form_display('entity_test', 'entity_test', 'default') @@ -546,7 +546,7 @@ function testOnOffCheckboxLabelSetting() { // Create a test field instance. $field_name = 'bool'; - entity_create('field_config', array( + entity_create('field_storage_config', array( 'name' => $field_name, 'entity_type' => 'node', 'type' => 'list_boolean', diff --git a/core/modules/path/src/Tests/PathLanguageTest.php b/core/modules/path/src/Tests/PathLanguageTest.php index 958b4e8..3152e92 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; - /** * Tests URL aliases for translated nodes. */ diff --git a/core/modules/quickedit/src/Tests/EditorSelectionTest.php b/core/modules/quickedit/src/Tests/EditorSelectionTest.php index 03ce968..943b4bd 100644 --- a/core/modules/quickedit/src/Tests/EditorSelectionTest.php +++ b/core/modules/quickedit/src/Tests/EditorSelectionTest.php @@ -93,8 +93,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 @@ -142,8 +142,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."); } @@ -173,8 +173,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 1e2f838..b0c932c 100644 --- a/core/modules/quickedit/src/Tests/QuickEditAutocompleteTermTest.php +++ b/core/modules/quickedit/src/Tests/QuickEditAutocompleteTermTest.php @@ -80,7 +80,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', @@ -95,7 +95,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 08c1a86..ec4d025 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 d02c092..f851383 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; @@ -82,24 +82,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; } @@ -109,14 +109,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'; @@ -124,7 +124,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 1909550..9a26aca 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 ed49cfc..7a81a81 100644 --- a/core/modules/rdf/src/Tests/Field/TaxonomyTermReferenceRdfaTest.php +++ b/core/modules/rdf/src/Tests/Field/TaxonomyTermReferenceRdfaTest.php @@ -60,7 +60,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 2c84d0f..18a2d11 100644 --- a/core/modules/rdf/src/Tests/TaxonomyTermFieldAttributesTest.php +++ b/core/modules/rdf/src/Tests/TaxonomyTermFieldAttributesTest.php @@ -155,7 +155,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 ffcf33d..aad4664 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; /** * Test node search with multiple languages. @@ -47,9 +47,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 54f21a4..edbd11f 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. @@ -58,9 +58,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 3f4d0dd..5b2dc7f 100644 --- a/core/modules/serialization/src/Tests/EntityResolverTest.php +++ b/core/modules/serialization/src/Tests/EntityResolverTest.php @@ -36,8 +36,8 @@ public static function getInfo() { 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 0c1dc03..8d5bf5c 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 41347e0..7270824 100644 --- a/core/modules/simpletest/src/Tests/KernelTestBaseTest.php +++ b/core/modules/simpletest/src/Tests/KernelTestBaseTest.php @@ -250,20 +250,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 da1d53e..9870e47 100644 --- a/core/modules/system/entity.api.php +++ b/core/modules/system/entity.api.php @@ -830,15 +830,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 dfbc423..ad99acb 100644 --- a/core/modules/system/src/Tests/Ajax/MultiFormTest.php +++ b/core/modules/system/src/Tests/Ajax/MultiFormTest.php @@ -36,7 +36,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 05e405e..b9788ce 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', @@ -158,7 +158,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', @@ -365,8 +365,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 3be40c6..b257907 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 6ea5549..b8effb8 100644 --- a/core/modules/system/src/Tests/Entity/EntityQueryAggregateTest.php +++ b/core/modules/system/src/Tests/Entity/EntityQueryAggregateTest.php @@ -58,7 +58,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 8d67666..b795762 100644 --- a/core/modules/system/src/Tests/Entity/EntityQueryRelationshipTest.php +++ b/core/modules/system/src/Tests/Entity/EntityQueryRelationshipTest.php @@ -86,7 +86,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 a3be1e8..954b1d8 100644 --- a/core/modules/system/src/Tests/Entity/EntityQueryTest.php +++ b/core/modules/system/src/Tests/Entity/EntityQueryTest.php @@ -65,15 +65,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++) { @@ -83,9 +83,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(); } @@ -431,17 +431,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 41806e3..5ad1edd 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; @@ -104,11 +104,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 4b7d0f8..247e010 100644 --- a/core/modules/system/src/Tests/Entity/EntityWithUriCacheTagsTestBase.php +++ b/core/modules/system/src/Tests/Entity/EntityWithUriCacheTagsTestBase.php @@ -86,14 +86,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 28cfed2..4e64450 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 storage. @@ -35,11 +35,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. @@ -71,21 +71,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); } /** @@ -95,7 +95,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(); @@ -261,12 +261,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', @@ -296,15 +296,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(); @@ -316,9 +316,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) { @@ -331,19 +331,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) { @@ -351,7 +351,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))); } } @@ -363,18 +363,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) { @@ -392,15 +392,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")); @@ -419,15 +419,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'); @@ -435,22 +435,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'); } @@ -465,7 +465,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(); @@ -475,12 +475,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); } /** @@ -494,74 +494,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 5ea3ef9..89d6ce3 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 entity translation. @@ -91,10 +91,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 030a2e1..d06df51 100644 --- a/core/modules/system/src/Tests/Form/ArbitraryRebuildTest.php +++ b/core/modules/system/src/Tests/Form/ArbitraryRebuildTest.php @@ -33,7 +33,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 f8cd8b0..ce5a5f1 100644 --- a/core/modules/system/src/Tests/Form/RebuildTest.php +++ b/core/modules/system/src/Tests/Form/RebuildTest.php @@ -72,19 +72,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 461c431..e51f198 100644 --- a/core/modules/system/system.api.php +++ b/core/modules/system/system.api.php @@ -2832,7 +2832,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 162f7ea..4dfd09b 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 6412fee..b00e42b 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/Entity/Vocabulary.php b/core/modules/taxonomy/src/Entity/Vocabulary.php index d492d7a..aa47b3a 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 bf7ae23..1e06f39 100644 --- a/core/modules/taxonomy/src/Tests/LegacyTest.php +++ b/core/modules/taxonomy/src/Tests/LegacyTest.php @@ -41,7 +41,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 f947600..4441d2e 100644 --- a/core/modules/taxonomy/src/Tests/RssTest.php +++ b/core/modules/taxonomy/src/Tests/RssTest.php @@ -37,7 +37,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', @@ -51,9 +51,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 576b9d1..bcc8729 100644 --- a/core/modules/taxonomy/src/Tests/TaxonomyImageTest.php +++ b/core/modules/taxonomy/src/Tests/TaxonomyImageTest.php @@ -44,7 +44,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 4f3b384..8d1c811 100644 --- a/core/modules/taxonomy/src/Tests/TaxonomyTermReferenceItemTest.php +++ b/core/modules/taxonomy/src/Tests/TaxonomyTermReferenceItemTest.php @@ -51,7 +51,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 cfe29f9..4f48caf 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. @@ -43,7 +43,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', @@ -122,9 +122,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 c1dfff1..20eeea0 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 for taxonomy term field and formatter. @@ -14,6 +15,13 @@ class TermFieldTest extends TaxonomyTestBase { /** + * The field storage to test against. + * + * @var \Drupal\field\FieldStorageConfigInterface + */ + protected $field_storage; + + /** * Modules to enable. * * @var array @@ -43,9 +51,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', @@ -58,9 +66,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') @@ -149,7 +157,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', @@ -163,15 +171,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 ce4c8fd..881784c 100644 --- a/core/modules/taxonomy/src/Tests/TermIndexTest.php +++ b/core/modules/taxonomy/src/Tests/TermIndexTest.php @@ -34,7 +34,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', @@ -65,7 +65,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 e08cf24..2ba1dc9 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 for taxonomy term functions. @@ -33,7 +33,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', @@ -46,8 +46,7 @@ function setUp() { ), ), ), - ); - entity_create('field_config', $field)->save(); + ))->save(); $this->instance = entity_create('field_instance_config', array( 'field_name' => $field_name, @@ -238,7 +237,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 241883b..045f878 100644 --- a/core/modules/taxonomy/src/Tests/TokenReplaceTest.php +++ b/core/modules/taxonomy/src/Tests/TokenReplaceTest.php @@ -30,7 +30,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 aee659b..ee9cc44 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 5867695..100dbfe 100644 --- a/core/modules/taxonomy/src/Tests/VocabularyCrudTest.php +++ b/core/modules/taxonomy/src/Tests/VocabularyCrudTest.php @@ -147,7 +147,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', @@ -179,21 +179,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'; module_uninstall(array('taxonomy')); @@ -205,7 +205,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 2dfa5b2..2f98da4 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(). @@ -405,19 +405,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', @@ -435,9 +435,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; @@ -449,7 +449,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 e0fe150..3133224 100644 --- a/core/modules/telephone/src/Tests/TelephoneFieldTest.php +++ b/core/modules/telephone/src/Tests/TelephoneFieldTest.php @@ -52,7 +52,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 d2b6f11..e117cce 100644 --- a/core/modules/telephone/src/Tests/TelephoneItemTest.php +++ b/core/modules/telephone/src/Tests/TelephoneItemTest.php @@ -35,7 +35,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 3745a5a..b96d9b0 100644 --- a/core/modules/text/src/Tests/Formatter/TextFormatterTest.php +++ b/core/modules/text/src/Tests/Formatter/TextFormatterTest.php @@ -64,7 +64,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', @@ -79,7 +79,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 750dc4a..a6ffeec 100644 --- a/core/modules/text/src/Tests/Formatter/TextPlainUnitTest.php +++ b/core/modules/text/src/Tests/Formatter/TextPlainUnitTest.php @@ -68,16 +68,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 11e5d73..20d137d 100644 --- a/core/modules/text/src/Tests/TextFieldTest.php +++ b/core/modules/text/src/Tests/TextFieldTest.php @@ -49,25 +49,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"); } @@ -90,15 +91,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( @@ -106,7 +107,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, @@ -114,13 +115,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. @@ -128,7 +129,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); @@ -156,15 +157,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( @@ -172,12 +173,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. @@ -192,15 +193,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 = '' . $this->randomName() . ''; $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); @@ -235,14 +236,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'); @@ -255,4 +256,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 72d6aae..7304b33 100644 --- a/core/modules/text/src/Tests/TextWithSummaryItemTest.php +++ b/core/modules/text/src/Tests/TextWithSummaryItemTest.php @@ -24,11 +24,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. @@ -109,7 +109,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', @@ -117,9 +117,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 104f314..55351b2 100644 --- a/core/modules/user/src/Tests/UserCreateTest.php +++ b/core/modules/user/src/Tests/UserCreateTest.php @@ -39,7 +39,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', @@ -50,10 +50,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', @@ -69,8 +68,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 faa9c7c..266860b 100644 --- a/core/modules/user/src/Tests/UserRegistrationTest.php +++ b/core/modules/user/src/Tests/UserRegistrationTest.php @@ -198,15 +198,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, @@ -253,8 +253,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. @@ -283,4 +283,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 513c3b2..fb2b3f9 100644 --- a/core/modules/views/src/Tests/DefaultViewsTest.php +++ b/core/modules/views/src/Tests/DefaultViewsTest.php @@ -63,7 +63,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 47fedaa..ddea838 100644 --- a/core/modules/views/src/Tests/Wizard/TaggedWithTest.php +++ b/core/modules/views/src/Tests/Wizard/TaggedWithTest.php @@ -55,8 +55,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, @@ -69,12 +70,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(); @@ -110,11 +111,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 5e77853..1675be5 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 578e376..fda9e9b 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/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 05702fd..31ba638 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 369306a..0960d3f 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 6469300..a7a2ef7 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 178be29..0f0ee8f 100644 --- a/core/tests/Drupal/Tests/Core/Config/StorageComparerTest.php +++ b/core/tests/Drupal/Tests/Core/Config/StorageComparerTest.php @@ -78,12 +78,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( @@ -150,7 +150,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']); @@ -178,7 +178,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', ); @@ -192,7 +192,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']); @@ -222,7 +222,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')); @@ -236,7 +236,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') @@ -262,7 +262,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 c743200..4fe0170 100644 --- a/core/tests/Drupal/Tests/Core/Entity/ContentEntityDatabaseStorageTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/ContentEntityDatabaseStorageTest.php @@ -957,14 +957,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')); @@ -980,11 +980,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');