diff --git a/core/modules/block/custom_block/custom_block.module b/core/modules/block/custom_block/custom_block.module
index b8785de..86df478 100644
--- a/core/modules/block/custom_block/custom_block.module
+++ b/core/modules/block/custom_block/custom_block.module
@@ -201,22 +201,22 @@ function custom_block_add_body_field($block_type_id, $label = 'Block body') {
$field = field_info_field('block_body');
$instance = field_info_instance('custom_block', 'block_body', $block_type_id);
if (empty($field)) {
- $field = array(
+ $field = entity_create('field_entity', array(
'field_name' => 'block_body',
'type' => 'text_with_summary',
'entity_types' => array('custom_block'),
- );
- $field = field_create_field($field);
+ ));
+ $field->save();
}
if (empty($instance)) {
- $instance = array(
+ $instance = entity_create('field_instance', array(
'field_name' => 'block_body',
'entity_type' => 'custom_block',
'bundle' => $block_type_id,
'label' => $label,
'settings' => array('display_summary' => FALSE),
- );
- $instance = field_create_instance($instance);
+ ));
+ $instance->save();
// Assign widget settings for the 'default' form mode.
entity_get_form_display('custom_block', $block_type_id, 'default')
diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockFieldTest.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockFieldTest.php
index 909dd12..ab2f78c 100644
--- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockFieldTest.php
+++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockFieldTest.php
@@ -64,21 +64,21 @@ public function testBlockFields() {
$this->blockType = $this->createCustomBlockType('link');
// Create a field with settings to validate.
- $this->field = array(
+ $this->field = entity_create('field_entity', array(
'field_name' => drupal_strtolower($this->randomName()),
'type' => 'link',
'cardinality' => 2,
- );
- field_create_field($this->field);
- $this->instance = array(
+ ));
+ $this->field->save();
+ $this->instance = entity_create('field_instance', array(
'field_name' => $this->field['field_name'],
'entity_type' => 'custom_block',
'bundle' => 'link',
'settings' => array(
'title' => DRUPAL_OPTIONAL,
),
- );
- field_create_instance($this->instance);
+ ));
+ $this->instance->save();
entity_get_form_display('custom_block', 'link', 'default')
->setComponent($this->field['field_name'], array(
'type' => 'link_default',
diff --git a/core/modules/comment/comment.install b/core/modules/comment/comment.install
index b022efb..ba79656 100644
--- a/core/modules/comment/comment.install
+++ b/core/modules/comment/comment.install
@@ -10,7 +10,7 @@
*/
function comment_uninstall() {
// Delete comment_body field.
- field_delete_field('comment_body');
+ field_info_field('comment_body')->delete();
// Remove variables.
variable_del('comment_block_count');
diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module
index 0c2cd55..c17d161 100644
--- a/core/modules/comment/comment.module
+++ b/core/modules/comment/comment.module
@@ -345,26 +345,26 @@ function comment_node_type_delete($info) {
function _comment_body_field_create($info) {
// Create the field if needed.
if (!field_read_field('comment_body', array('include_inactive' => TRUE))) {
- $field = array(
+ $field = entity_create('field_entity', array(
'field_name' => 'comment_body',
'type' => 'text_long',
'entity_types' => array('comment'),
- );
- field_create_field($field);
+ ));
+ $field->save();
}
// Create the instance if needed.
if (!field_read_instance('comment', 'comment_body', 'comment_node_' . $info->type, array('include_inactive' => TRUE))) {
entity_invoke_bundle_hook('create', 'comment', 'comment_node_' . $info->type);
// Attaches the body field by default.
- $instance = array(
+ $instance = entity_create('field_instance', array(
'field_name' => 'comment_body',
'label' => 'Comment',
'entity_type' => 'comment',
'bundle' => 'comment_node_' . $info->type,
'settings' => array('text_processing' => 1),
'required' => TRUE,
- );
- field_create_instance($instance);
+ ));
+ $instance->save();
// Assign widget settings for the 'default' form mode.
entity_get_form_display('comment', 'comment_node_' . $info->type, 'default')
diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentFieldsTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentFieldsTest.php
index c92d2ab..ecd464a 100644
--- a/core/modules/comment/lib/Drupal/comment/Tests/CommentFieldsTest.php
+++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentFieldsTest.php
@@ -41,7 +41,7 @@ function testCommentDefaultFields() {
$this->assertTrue(isset($instances['comment_node_' . $type_name]['comment_body']), format_string('The comment_body field is present for comments on type @type', array('@type' => $type_name)));
// Delete the instance along the way.
- field_delete_instance($instances['comment_node_' . $type_name]['comment_body']);
+ $instances['comment_node_' . $type_name]['comment_body']->delete();
}
// Check that the 'comment_body' field is deleted.
diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentLanguageTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentLanguageTest.php
index 35a935e..85430f0 100644
--- a/core/modules/comment/lib/Drupal/comment/Tests/CommentLanguageTest.php
+++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentLanguageTest.php
@@ -72,7 +72,7 @@ function setUp() {
// Make comment body translatable.
$field = field_info_field('comment_body');
$field['translatable'] = TRUE;
- field_update_field($field);
+ $field->save();
$this->assertTrue(field_is_translatable('comment', $field), 'Comment body is translatable.');
}
diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentTranslationUITest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentTranslationUITest.php
index 100e02f..2a14791 100644
--- a/core/modules/comment/lib/Drupal/comment/Tests/CommentTranslationUITest.php
+++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentTranslationUITest.php
@@ -65,7 +65,7 @@ function setupTestFields() {
parent::setupTestFields();
$field = field_info_field('comment_body');
$field['translatable'] = TRUE;
- field_update_field($field);
+ $field->save();
}
/**
diff --git a/core/modules/contact/lib/Drupal/contact/Tests/Views/ContactFieldsTest.php b/core/modules/contact/lib/Drupal/contact/Tests/Views/ContactFieldsTest.php
index 0ce0071..2263ea0 100644
--- a/core/modules/contact/lib/Drupal/contact/Tests/Views/ContactFieldsTest.php
+++ b/core/modules/contact/lib/Drupal/contact/Tests/Views/ContactFieldsTest.php
@@ -39,19 +39,17 @@ public static function getInfo() {
protected function setUp() {
parent::setUp();
- $field = array(
+ $this->field = entity_create('field_entity', array(
'field_name' => strtolower($this->randomName()),
'type' => 'text'
- );
-
- $this->field = field_create_field($field);
+ ));
+ $this->field->save();
- $instance = array(
- 'field_name' => $field['field_name'],
+ entity_create('field_instance', array(
+ 'field_name' => $this->field['field_name'],
'entity_type' => 'contact_message',
'bundle' => 'contact_message',
- );
- field_create_instance($instance);
+ ))->save();
$this->container->get('views.views_data')->clear();
}
diff --git a/core/modules/datetime/lib/Drupal/datetime/Tests/DatetimeFieldTest.php b/core/modules/datetime/lib/Drupal/datetime/Tests/DatetimeFieldTest.php
index ac3f4a3..cf2b1d0 100644
--- a/core/modules/datetime/lib/Drupal/datetime/Tests/DatetimeFieldTest.php
+++ b/core/modules/datetime/lib/Drupal/datetime/Tests/DatetimeFieldTest.php
@@ -48,12 +48,13 @@ function setUp() {
$this->drupalLogin($web_user);
// Create a field with settings to validate.
- $this->field = field_create_field(array(
+ $this->field = entity_create('field_entity', array(
'field_name' => drupal_strtolower($this->randomName()),
'type' => 'datetime',
'settings' => array('datetime_type' => 'date'),
));
- $this->instance = field_create_instance(array(
+ $this->field->save();
+ $this->instance = entity_create('field_instance', array(
'field_name' => $this->field['field_name'],
'entity_type' => 'test_entity',
'bundle' => 'test_bundle',
@@ -61,6 +62,7 @@ function setUp() {
'default_value' => 'blank',
),
));
+ $this->instance->save();
entity_get_form_display($this->instance['entity_type'], $this->instance['bundle'], 'default')
->setComponent($this->field['field_name'], array(
@@ -150,7 +152,7 @@ function testDatetimeField() {
// Change the field to a datetime field.
$this->field['settings']['datetime_type'] = 'datetime';
- field_update_field($this->field);
+ $this->field->save();
// Display creation form.
$this->drupalGet('test-entity/add/test_bundle');
@@ -217,7 +219,7 @@ function testDatelistWidget() {
// Change the field to a datetime field.
$this->field['settings']['datetime_type'] = 'datetime';
- field_update_field($this->field);
+ $this->field->save();
// Change the widget to a datelist widget.
entity_get_form_display($this->instance['entity_type'], $this->instance['bundle'], 'default')
@@ -282,12 +284,12 @@ function testDefaultValue() {
// Change the field to a datetime field.
$this->field['settings']['datetime_type'] = 'datetime';
- field_update_field($this->field);
+ $this->field->save();
// Set the default value to 'now'.
$this->instance['settings']['default_value'] = 'now';
$this->instance['default_value_function'] = 'datetime_default_value';
- field_update_instance($this->instance);
+ $this->instance->save();
// Display creation form.
$date = new DrupalDateTime();
@@ -305,7 +307,7 @@ function testDefaultValue() {
// Set the default value to 'blank'.
$this->instance['settings']['default_value'] = 'blank';
$this->instance['default_value_function'] = 'datetime_default_value';
- field_update_instance($this->instance);
+ $this->instance->save();
// Display creation form.
$date = new DrupalDateTime();
@@ -323,7 +325,7 @@ function testInvalidField() {
// Change the field to a datetime field.
$this->field['settings']['datetime_type'] = 'datetime';
- field_update_field($this->field);
+ $this->field->save();
// Display creation form.
$this->drupalGet('test-entity/add/test_bundle');
diff --git a/core/modules/edit/lib/Drupal/edit/Tests/EditTestBase.php b/core/modules/edit/lib/Drupal/edit/Tests/EditTestBase.php
index 30aec3f..8c455f0 100644
--- a/core/modules/edit/lib/Drupal/edit/Tests/EditTestBase.php
+++ b/core/modules/edit/lib/Drupal/edit/Tests/EditTestBase.php
@@ -59,10 +59,11 @@ function createFieldWithInstance($field_name, $type, $cardinality, $label, $inst
'type' => $type,
'cardinality' => $cardinality,
);
- $this->$field = field_create_field($this->field);
+ $this->$field = entity_create('field_entity', $this->field);
+ $this->$field->save();
$instance = $field_name . '_instance';
- $this->$instance = array(
+ $this->$instance = entity_create('field_instance', array(
'field_name' => $field_name,
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
@@ -70,8 +71,8 @@ function createFieldWithInstance($field_name, $type, $cardinality, $label, $inst
'description' => $label,
'weight' => mt_rand(0, 127),
'settings' => $instance_settings,
- );
- field_create_instance($this->$instance);
+ ));
+ $this->$instance->save();
entity_get_form_display('entity_test', 'entity_test', 'default')
->setComponent($field_name, array(
diff --git a/core/modules/edit/lib/Drupal/edit/Tests/EditorSelectionTest.php b/core/modules/edit/lib/Drupal/edit/Tests/EditorSelectionTest.php
index 767c570..15d95f7 100644
--- a/core/modules/edit/lib/Drupal/edit/Tests/EditorSelectionTest.php
+++ b/core/modules/edit/lib/Drupal/edit/Tests/EditorSelectionTest.php
@@ -80,23 +80,23 @@ function testText() {
// Editor selection with text processing, cardinality 1.
$this->field_text_instance['settings']['text_processing'] = 1;
- field_update_instance($this->field_text_instance);
+ $this->field_text_instance->save();
$this->assertEqual('form', $this->getSelectedEditor($items, $field_name), "With text processing, cardinality 1, the 'form' editor is selected.");
// Editor selection without text processing, cardinality 1 (again).
$this->field_text_instance['settings']['text_processing'] = 0;
- field_update_instance($this->field_text_instance);
+ $this->field_text_instance->save();
$this->assertEqual('direct', $this->getSelectedEditor($items, $field_name), "Without text processing again, cardinality 1, the 'direct' editor is selected.");
// Editor selection without text processing, cardinality >1
$this->field_text_field['cardinality'] = 2;
- field_update_field($this->field_text_field);
+ $this->field_text_field->save();
$items[] = array('value' => 'Hallo, wereld!', 'format' => 'full_html');
$this->assertEqual('form', $this->getSelectedEditor($items, $field_name), "Without text processing, cardinality >1, the 'form' editor is selected.");
// Editor selection with text processing, cardinality >1
$this->field_text_instance['settings']['text_processing'] = 1;
- field_update_instance($this->field_text_instance);
+ $this->field_text_instance->save();
$this->assertEqual('form', $this->getSelectedEditor($items, $field_name), "With text processing, cardinality >1, the 'form' editor is selected.");
}
@@ -134,7 +134,7 @@ function testTextWysiwyg() {
// Editor selection with text processing, cardinality >1
$this->field_textarea_field['cardinality'] = 2;
- field_update_field($this->field_textarea_field);
+ $this->field_textarea_field->save();
$items[] = array('value' => 'Hallo, wereld!', 'format' => 'full_html');
$this->assertEqual('form', $this->getSelectedEditor($items, $field_name), "With cardinality >1, and both items using the full_html text format, the 'form' editor is selected.");
}
@@ -164,7 +164,7 @@ function testNumber() {
// Editor selection with cardinality >1.
$this->field_nr_field['cardinality'] = 2;
- field_update_field($this->field_nr_field);
+ $this->field_nr_field->save();
$this->assertEqual('form', $this->getSelectedEditor($items, $field_name), "With cardinality >1, the 'form' editor is selected.");
}
diff --git a/core/modules/editor/lib/Drupal/editor/Tests/EditIntegrationTest.php b/core/modules/editor/lib/Drupal/editor/Tests/EditIntegrationTest.php
index 6e8e36f..f6b73b5 100644
--- a/core/modules/editor/lib/Drupal/editor/Tests/EditIntegrationTest.php
+++ b/core/modules/editor/lib/Drupal/editor/Tests/EditIntegrationTest.php
@@ -137,7 +137,7 @@ function testEditorSelection() {
// Editor selection with text processing, cardinality >1
$this->field_textarea_field['cardinality'] = 2;
- field_update_field($this->field_textarea_field);
+ $this->field_textarea_field->save();
$items[] = array('value' => 'Hallo, wereld!', 'format' => 'full_html');
$this->assertEqual('form', $this->getSelectedEditor($items, $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/email/lib/Drupal/email/Tests/EmailFieldTest.php b/core/modules/email/lib/Drupal/email/Tests/EmailFieldTest.php
index dbb2bed..58e6aa0 100644
--- a/core/modules/email/lib/Drupal/email/Tests/EmailFieldTest.php
+++ b/core/modules/email/lib/Drupal/email/Tests/EmailFieldTest.php
@@ -49,13 +49,13 @@ function testEmailField() {
'field_name' => drupal_strtolower($this->randomName()),
'type' => 'email',
);
- field_create_field($this->field);
+ entity_create('field_entity', $this->field)->save();
$this->instance = array(
'field_name' => $this->field['field_name'],
'entity_type' => 'test_entity',
'bundle' => 'test_bundle',
);
- field_create_instance($this->instance);
+ entity_create('field_instance', $this->instance)->save();
// Create a form display for the default form mode.
entity_get_form_display('test_entity', 'test_bundle', 'default')
diff --git a/core/modules/email/lib/Drupal/email/Tests/EmailItemTest.php b/core/modules/email/lib/Drupal/email/Tests/EmailItemTest.php
index 1555b8d..9fc5bcc 100644
--- a/core/modules/email/lib/Drupal/email/Tests/EmailItemTest.php
+++ b/core/modules/email/lib/Drupal/email/Tests/EmailItemTest.php
@@ -39,13 +39,13 @@ public function setUp() {
'field_name' => 'field_email',
'type' => 'email',
);
- field_create_field($this->field);
+ entity_create('field_entity', $this->field)->save();
$this->instance = array(
'entity_type' => 'entity_test',
'field_name' => 'field_email',
'bundle' => 'entity_test',
);
- field_create_instance($this->instance);
+ entity_create('field_instance', $this->instance)->save();
// Create a form display for the default form mode.
entity_get_form_display('entity_test', 'entity_test', 'default')
diff --git a/core/modules/entity/lib/Drupal/entity/Tests/EntityDisplayTest.php b/core/modules/entity/lib/Drupal/entity/Tests/EntityDisplayTest.php
index 051fb76..e33f487 100644
--- a/core/modules/entity/lib/Drupal/entity/Tests/EntityDisplayTest.php
+++ b/core/modules/entity/lib/Drupal/entity/Tests/EntityDisplayTest.php
@@ -144,13 +144,13 @@ public function testFieldComponent() {
'field_name' => 'test_field',
'type' => 'test_field'
);
- field_create_field($field);
+ entity_create('field_entity', $field)->save();
$instance = array(
'field_name' => $field['field_name'],
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
);
- field_create_instance($instance);
+ entity_create('field_instance', $instance)->save();
// Check that providing no options results in default values being used.
$display->setComponent($field['field_name']);
diff --git a/core/modules/entity/lib/Drupal/entity/Tests/EntityFormDisplayTest.php b/core/modules/entity/lib/Drupal/entity/Tests/EntityFormDisplayTest.php
index b92cfbf..5d199ad 100644
--- a/core/modules/entity/lib/Drupal/entity/Tests/EntityFormDisplayTest.php
+++ b/core/modules/entity/lib/Drupal/entity/Tests/EntityFormDisplayTest.php
@@ -66,13 +66,13 @@ public function testFieldComponent() {
'field_name' => 'test_field',
'type' => 'test_field'
);
- field_create_field($field);
+ entity_create('field_entity', $field)->save();
$instance = array(
'field_name' => $field['field_name'],
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
);
- field_create_instance($instance);
+ entity_create('field_instance', $instance)->save();
// Check that providing no options results in default values being used.
$form_display->setComponent($field['field_name']);
diff --git a/core/modules/entity_reference/entity_reference.module b/core/modules/entity_reference/entity_reference.module
index 3c68c46..2e47c31 100644
--- a/core/modules/entity_reference/entity_reference.module
+++ b/core/modules/entity_reference/entity_reference.module
@@ -218,7 +218,7 @@ function entity_reference_field_update_field($field, $prior_field, $has_data) {
foreach ($bundles as $bundle) {
$instance = field_info_instance($entity_type, $field_name, $bundle);
$instance['settings']['handler_settings'] = array();
- field_update_instance($instance);
+ $instance->save();
}
}
}
@@ -453,7 +453,7 @@ function entity_reference_create_instance($entity_type, $bundle, $field_name, $f
'target_type' => $target_entity_type,
),
);
- field_create_field($field);
+ entity_create('field_entity', $field)->save();
}
if (empty($instance)) {
@@ -467,6 +467,7 @@ function entity_reference_create_instance($entity_type, $bundle, $field_name, $f
'handler_settings' => $selection_handler_settings,
),
);
- field_create_instance($instance);
+ entity_create('field_instance', $instance)->save();
}
}
+
diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceAutoCreateTest.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceAutoCreateTest.php
index ace6f5d..fcc9beb 100644
--- a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceAutoCreateTest.php
+++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceAutoCreateTest.php
@@ -45,7 +45,7 @@ function setUp() {
'cardinality' => FIELD_CARDINALITY_UNLIMITED,
);
- field_create_field($field);
+ entity_create('field_entity', $field)->save();
$instance = array(
'label' => 'Entity reference field',
@@ -65,7 +65,7 @@ function setUp() {
),
);
- field_create_instance($instance);
+ entity_create('field_instance', $instance)->save();
entity_get_form_display('node', $referencing->type, 'default')
->setComponent('test_field', array(
diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionSortTest.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionSortTest.php
index d3245e0..253249d 100644
--- a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionSortTest.php
+++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionSortTest.php
@@ -41,7 +41,7 @@ public function testSort() {
'type' => 'text',
'entity_types' => array('node'),
);
- field_create_field($field_info);
+ entity_create('field_entity', $field_info)->save();
$instance_info = array(
'label' => 'Text Field',
@@ -51,7 +51,7 @@ public function testSort() {
'settings' => array(),
'required' => FALSE,
);
- field_create_instance($instance_info);
+ entity_create('field_instance', $instance_info)->save();
// Build a fake field instance.
diff --git a/core/modules/field/field.attach.inc b/core/modules/field/field.attach.inc
index baa7ff4..6fd3e36 100644
--- a/core/modules/field/field.attach.inc
+++ b/core/modules/field/field.attach.inc
@@ -1610,7 +1610,7 @@ function field_entity_bundle_delete($entity_type, $bundle) {
// entity types or bundles.
$instances = field_read_instances(array('entity_type' => $entity_type, 'bundle' => $bundle), array('include_inactive' => TRUE));
foreach ($instances as $instance) {
- field_delete_instance($instance);
+ $instance->delete();
}
// Clear the cache.
diff --git a/core/modules/field/field.crud.inc b/core/modules/field/field.crud.inc
index ec2daa3..b0d124a 100644
--- a/core/modules/field/field.crud.inc
+++ b/core/modules/field/field.crud.inc
@@ -25,89 +25,6 @@
*/
/**
- * Creates a field.
- *
- * This function does not bind the field to any bundle; use
- * field_create_instance() for that.
- *
- * @param array $field
- * A field definition. The field_name and type properties are required.
- * Other properties, if omitted, will be given the following default values:
- * - cardinality: 1
- * - locked: FALSE
- * - indexes: the field-type indexes, specified by the field type's
- * hook_field_schema(). The indexes specified in $field are added
- * to those default indexes. It is possible to override the
- * definition of a field-type index by providing an index with the
- * same name, or to remove it by redefining it as an empty array
- * of columns. Overriding field-type indexes should be done
- * carefully, for it might seriously affect the site's performance.
- * - settings: each omitted setting is given the default value defined in
- * hook_field_info().
- * - storage:
- * - type: the storage backend specified in the
- * 'field.settings.default_storage' configuration.
- * - settings: each omitted setting is given the default value specified in
- * hook_field_storage_info().
- *
- * @return \Drupal\field\Plugin\Core\Entity\Field
- * The field entity.
- *
- * @throws Drupal\field\FieldException
- *
- * @deprecated as of Drupal 8.0. Use
- * entity_create('field_entity', $definition)->save().
- *
- * See: @link field Field API data structures @endlink.
- */
-function field_create_field(array $field) {
- $field = entity_create('field_entity', $field);
- $field->save();
- return $field;
-}
-
-/**
- * Updates a field.
- *
- * Any module may forbid any update for any reason. For example, the
- * field's storage module might forbid an update if it would change
- * the storage schema while data for the field exists. A field type
- * module might forbid an update if it would change existing data's
- * semantics, or if there are external dependencies on field settings
- * that cannot be updated.
- *
- * @param mixed $field
- * Either the \Drupal\field\Plugin\Core\Entity\Field object to update, or a
- * field array structure. If the latter, $field['field_name'] must provided;
- * it identifies the field that will be updated to match this structure. Any
- * other properties of the field that are not specified in $field will be left
- * unchanged, so it is not necessary to pass in a fully populated $field
- * structure.
- *
- * @throws Drupal\field\FieldException
- *
- * @deprecated as of Drupal 8.0. Use $field->save().
- *
- * @see field_create_field()
- */
-function field_update_field($field) {
- // Module developers can still pass in an array of properties.
- if (is_array($field)) {
- $field_loaded = entity_load('field_entity', $field['field_name']);
- if (empty($field_loaded)) {
- throw new FieldException('Attempt to update a non-existent field.');
- }
- // Merge incoming values.
- foreach ($field as $key => $value) {
- $field_loaded[$key] = $value;
- }
- $field = $field_loaded;
- }
-
- $field->save();
-}
-
-/**
* Reads a single field record directly from the database.
*
* Generally, you should use the field_info_field() instead.
@@ -215,103 +132,6 @@ function field_read_fields($conditions = array(), $include_additional = array())
}
/**
- * Marks a field and its instances and data for deletion.
- *
- * @param $field_name
- * The field name to delete.
- *
- * @deprecated as of Drupal 8.0. Use $field->delete().
- */
-function field_delete_field($field_name) {
- if ($field = field_info_field($field_name)) {
- $field->delete();
- }
-}
-
-/**
- * Creates an instance of a field, binding it to a bundle.
- *
- * @param array $instance
- * A field instance definition array. The field_name, entity_type and
- * bundle properties are required. Other properties, if omitted,
- * will be given the following default values:
- * - label: the field name
- * - description: empty string
- * - required: FALSE
- * - default_value_function: empty string
- * - settings: each omitted setting is given the default value specified in
- * hook_field_info().
- * - widget:
- * - type: the default widget specified in hook_field_info().
- * - settings: each omitted setting is given the default value specified in
- * hook_field_widget_info().
- *
- * @return \Drupal\field\Plugin\Core\Entity\FieldInstance
- * The field instance entity.
- *
- * @throws Drupal\field\FieldException
- *
- * @deprecated as of Drupal 8.0. Use
- * entity_create('field_instance', $definition)->save().
- *
- * See: @link field Field API data structures @endlink.
- */
-function field_create_instance(array $instance) {
- $instance = entity_create('field_instance', $instance);
- $instance->save();
- return $instance;
-}
-
-/**
- * Updates an instance of a field.
- *
- * @param mixed $instance
- * Either the \Drupal\field\Plugin\Core\Entity\FieldInstance to update, or an
- * associative array representing an instance structure. If the latter, the
- * required keys and values are:
- * - entity_type: The type of the entity the field is attached to.
- * - bundle: The bundle this field belongs to.
- * - field_name: The name of an existing field.
- * The other array elements represent properties of the instance, and all
- * properties must be specified or their default values will be used (except
- * internal-use properties, which are assigned automatically). To avoid losing
- * the previously stored properties of the instance when making a change,
- * first load the instance with field_info_instance(), then override the
- * values you want to override, and finally save using this function. Example:
- * @code
- * // Fetch an instance info array.
- * $instance_info = field_info_instance($entity_type, $field_name, $bundle_name);
- * // Change a single property in the instance definition.
- * $instance_info['definition']['required'] = TRUE;
- * // Write the changed definition back.
- * field_update_instance($instance_info['definition']);
- * @endcode
- *
- * @throws Drupal\field\FieldException
- *
- * @deprecated as of Drupal 8.0. Use $instance->save().
- *
- * @see field_info_instance()
- * @see field_create_instance()
- */
-function field_update_instance($instance) {
- // Module developers can still pass in an array of properties.
- if (is_array($instance)) {
- $instance_loaded = entity_load('field_instance', $instance['entity_type'] . '.' . $instance['bundle'] . '.' . $instance['field_name']);
- if (empty($instance_loaded)) {
- throw new FieldException('Attempt to update a non-existent instance.');
- }
- // Merge incoming values.
- foreach ($instance as $key => $value) {
- $instance_loaded[$key] = $value;
- }
- $instance = $instance_loaded;
- }
-
- $instance->save();
-}
-
-/**
* Reads a single instance record from the database.
*
* Generally, you should use field_info_instance() instead, as it provides
@@ -439,22 +259,6 @@ function field_read_instances($conditions = array(), $include_additional = array
}
/**
- * Marks a field instance and its data for deletion.
- *
- * @param \Drupal\field\Plugin\Core\Entity\FieldInstance $instance
- * The field instance.
- * @param $field_cleanup
- * If TRUE, the field will be deleted as well if its last instance is being
- * deleted. If FALSE, it is the caller's responsibility to handle the case of
- * fields left without instances. Defaults to TRUE.
- *
- * @deprecated as of Drupal 8.0. Use $instance->delete().
- */
-function field_delete_instance(FieldInstance $instance, $field_cleanup = TRUE) {
- $instance->delete($field_cleanup);
-}
-
-/**
* @} End of "defgroup field_crud".
*/
diff --git a/core/modules/field/field.module b/core/modules/field/field.module
index bf0ac56..f5fa1f0 100644
--- a/core/modules/field/field.module
+++ b/core/modules/field/field.module
@@ -73,8 +73,7 @@
* field_sql_storage.module, stores field data in the local SQL database.
*
* - @link field_purge Field API bulk data deletion @endlink: Cleans up after
- * bulk deletion operations such as field_delete_field() and
- * field_delete_instance().
+ * bulk deletion operations such as deletion of field or field_instance.
*
* - @link field_language Field language API @endlink: Provides native
* multilingual support for the Field API.
diff --git a/core/modules/field/lib/Drupal/field/Tests/ActiveTest.php b/core/modules/field/lib/Drupal/field/Tests/ActiveTest.php
index c555dc8..c74d426 100644
--- a/core/modules/field/lib/Drupal/field/Tests/ActiveTest.php
+++ b/core/modules/field/lib/Drupal/field/Tests/ActiveTest.php
@@ -37,7 +37,7 @@ function testActive() {
'type' => 'field_sql_storage',
),
);
- field_create_field($field_definition);
+ entity_create('field_entity', $field_definition)->save();
// Test disabling and enabling:
// - the field type module,
diff --git a/core/modules/field/lib/Drupal/field/Tests/BulkDeleteTest.php b/core/modules/field/lib/Drupal/field/Tests/BulkDeleteTest.php
index 7ff4ff9..33a07cd 100644
--- a/core/modules/field/lib/Drupal/field/Tests/BulkDeleteTest.php
+++ b/core/modules/field/lib/Drupal/field/Tests/BulkDeleteTest.php
@@ -102,10 +102,12 @@ function setUp() {
}
// Create two fields.
- $field = array('field_name' => 'bf_1', 'type' => 'test_field', 'cardinality' => 1);
- $this->fields[] = field_create_field($field);
- $field = array('field_name' => 'bf_2', 'type' => 'test_field', 'cardinality' => 4);
- $this->fields[] = field_create_field($field);
+ $field = entity_create('field_entity', array('field_name' => 'bf_1', 'type' => 'test_field', 'cardinality' => 1));
+ $field->save();
+ $this->fields[] = $field;
+ $field = entity_create('field_entity', array('field_name' => 'bf_2', 'type' => 'test_field', 'cardinality' => 4));
+ $field->save();
+ $this->fields[] = $field;
// For each bundle, create an instance of each field, and 10
// entities with values for each field.
@@ -113,12 +115,13 @@ function setUp() {
$this->entity_type = 'test_entity';
foreach ($this->bundles as $bundle) {
foreach ($this->fields as $field) {
- $instance = array(
+ $instance = entity_create('field_instance', array(
'field_name' => $field['field_name'],
'entity_type' => $this->entity_type,
'bundle' => $bundle,
- );
- $this->instances[] = field_create_instance($instance);
+ ));
+ $instance->save();
+ $this->instances[] = $instance;
}
for ($i = 0; $i < 10; $i++) {
@@ -142,9 +145,8 @@ function setUp() {
* the database and that the appropriate Field API functions can
* operate on the deleted data and instance.
*
- * This tests how EntityFieldQuery interacts with
- * field_delete_instance() and could be moved to FieldCrudTestCase,
- * but depends on this class's setUp().
+ * This tests how EntityFieldQuery interacts with field instance deletion and
+ * could be moved to FieldCrudTestCase, but depends on this class's setUp().
*/
function testDeleteFieldInstance() {
$bundle = reset($this->bundles);
@@ -160,7 +162,7 @@ function testDeleteFieldInstance() {
// Delete the instance.
$instance = field_info_instance($this->entity_type, $field['field_name'], $bundle);
- field_delete_instance($instance);
+ $instance->delete();
// The instance still exists, deleted.
$instances = field_read_instances(array('field_id' => $field['uuid'], 'deleted' => TRUE), array('include_deleted' => TRUE, 'include_inactive' => TRUE));
@@ -210,7 +212,7 @@ function testPurgeInstance() {
// Delete the instance.
$instance = field_info_instance($this->entity_type, $field['field_name'], $bundle);
- field_delete_instance($instance);
+ $instance->delete();
// No field hooks were called.
$mem = field_test_memorize();
@@ -274,7 +276,7 @@ function testPurgeField() {
// Delete the first instance.
$bundle = reset($this->bundles);
$instance = field_info_instance($this->entity_type, $field['field_name'], $bundle);
- field_delete_instance($instance);
+ $instance->delete();
// Assert that hook_field_delete() was not called yet.
$mem = field_test_memorize();
@@ -305,7 +307,7 @@ function testPurgeField() {
// Delete the second instance.
$bundle = next($this->bundles);
$instance = field_info_instance($this->entity_type, $field['field_name'], $bundle);
- field_delete_instance($instance);
+ $instance->delete();
// Assert that hook_field_delete() was not called yet.
$mem = field_test_memorize();
diff --git a/core/modules/field/lib/Drupal/field/Tests/CrudTest.php b/core/modules/field/lib/Drupal/field/Tests/CrudTest.php
index 8f9bdf9..3496c81 100644
--- a/core/modules/field/lib/Drupal/field/Tests/CrudTest.php
+++ b/core/modules/field/lib/Drupal/field/Tests/CrudTest.php
@@ -40,7 +40,8 @@ function testCreateField() {
'type' => 'test_field',
);
field_test_memorize();
- $field = field_create_field($field_definition);
+ $field = entity_create('field_entity', $field_definition);
+ $field->save();
$mem = field_test_memorize();
$this->assertIdentical($mem['field_test_field_create_field'][0][0]['field_name'], $field_definition['field_name'], 'hook_field_create_field() called with correct arguments.');
$this->assertIdentical($mem['field_test_field_create_field'][0][0]['type'], $field_definition['type'], 'hook_field_create_field() called with correct arguments.');
@@ -66,7 +67,7 @@ function testCreateField() {
// Guarantee that the name is unique.
try {
- field_create_field($field_definition);
+ entity_create('field_entity', $field_definition)->save();
$this->fail(t('Cannot create two fields with the same name.'));
}
catch (FieldException $e) {
@@ -78,7 +79,7 @@ function testCreateField() {
$field_definition = array(
'field_name' => 'field_1',
);
- field_create_field($field_definition);
+ entity_create('field_entity', $field_definition)->save();
$this->fail(t('Cannot create a field with no type.'));
}
catch (FieldException $e) {
@@ -90,7 +91,7 @@ function testCreateField() {
$field_definition = array(
'type' => 'test_field'
);
- field_create_field($field_definition);
+ entity_create('field_entity', $field_definition)->save();
$this->fail(t('Cannot create an unnamed field.'));
}
catch (FieldException $e) {
@@ -103,7 +104,7 @@ function testCreateField() {
'field_name' => '2field_2',
'type' => 'test_field',
);
- field_create_field($field_definition);
+ entity_create('field_entity', $field_definition)->save();
$this->fail(t('Cannot create a field with a name starting with a digit.'));
}
catch (FieldException $e) {
@@ -116,7 +117,7 @@ function testCreateField() {
'field_name' => 'field#_3',
'type' => 'test_field',
);
- field_create_field($field_definition);
+ entity_create('field_entity', $field_definition)->save();
$this->fail(t('Cannot create a field with a name containing an illegal character.'));
}
catch (FieldException $e) {
@@ -129,7 +130,7 @@ function testCreateField() {
'field_name' => '_12345678901234567890123456789012',
'type' => 'test_field',
);
- field_create_field($field_definition);
+ entity_create('field_entity', $field_definition)->save();
$this->fail(t('Cannot create a field with a name longer than 32 characters.'));
}
catch (FieldException $e) {
@@ -143,7 +144,7 @@ function testCreateField() {
'type' => 'test_field',
'field_name' => 'ftvid',
);
- field_create_field($field_definition);
+ entity_create('field_entity', $field_definition)->save();
$this->fail(t('Cannot create a field bearing the name of an entity key.'));
}
catch (FieldException $e) {
@@ -164,7 +165,7 @@ function testCreateFieldFail() {
// Try to create the field.
try {
- $field = field_create_field($field_definition);
+ entity_create('field_entity', $field_definition)->save();
$this->assertTrue(FALSE, 'Field creation (correctly) fails.');
}
catch (\Exception $e) {
@@ -184,7 +185,7 @@ function testReadField() {
'field_name' => 'field_1',
'type' => 'test_field',
);
- field_create_field($field_definition);
+ entity_create('field_entity', $field_definition)->save();
// Read the field back.
$field = field_read_field($field_definition['field_name']);
@@ -199,7 +200,7 @@ function testReadFields() {
'field_name' => 'field_1',
'type' => 'test_field',
);
- field_create_field($field_definition);
+ entity_create('field_entity', $field_definition)->save();
// Check that 'single column' criteria works.
$fields = field_read_fields(array('field_name' => $field_definition['field_name']));
@@ -217,7 +218,7 @@ function testReadFields() {
'entity_type' => 'test_entity',
'bundle' => 'test_bundle',
);
- field_create_instance($instance_definition);
+ entity_create('field_instance', $instance_definition)->save();
}
/**
@@ -229,7 +230,7 @@ function testFieldIndexes() {
'field_name' => 'field_1',
'type' => 'test_field',
);
- field_create_field($field_definition);
+ entity_create('field_entity', $field_definition)->save();
$field = field_read_field($field_definition['field_name']);
$schema = $field->getSchema();
$expected_indexes = array('value' => array('value'));
@@ -244,7 +245,7 @@ function testFieldIndexes() {
'value' => array(),
),
);
- field_create_field($field_definition);
+ entity_create('field_entity', $field_definition)->save();
$field = field_read_field($field_definition['field_name']);
$schema = $field->getSchema();
$expected_indexes = array('value' => array());
@@ -259,7 +260,7 @@ function testFieldIndexes() {
'value_2' => array('value'),
),
);
- field_create_field($field_definition);
+ entity_create('field_entity', $field_definition)->save();
$field = field_read_field($field_definition['field_name']);
$schema = $field->getSchema();
$expected_indexes = array('value' => array('value'), 'value_2' => array('value'));
@@ -274,9 +275,9 @@ function testDeleteField() {
// Create two fields (so we can test that only one is deleted).
$this->field = array('field_name' => 'field_1', 'type' => 'test_field');
- field_create_field($this->field);
+ entity_create('field_entity', $this->field)->save();
$this->another_field = array('field_name' => 'field_2', 'type' => 'test_field');
- field_create_field($this->another_field);
+ entity_create('field_entity', $this->another_field)->save();
// Create instances for each.
$this->instance_definition = array(
@@ -284,15 +285,15 @@ function testDeleteField() {
'entity_type' => 'test_entity',
'bundle' => 'test_bundle',
);
- field_create_instance($this->instance_definition);
- $this->another_instance_definition = $this->instance_definition;
- $this->another_instance_definition['field_name'] = $this->another_field['field_name'];
- field_create_instance($this->another_instance_definition);
+ entity_create('field_instance', $this->instance_definition)->save();
+ $another_instance_definition = $this->instance_definition;
+ $another_instance_definition['field_name'] = $this->another_field['field_name'];
+ entity_create('field_instance', $another_instance_definition)->save();
// Test that the first field is not deleted, and then delete it.
$field = field_read_field($this->field['field_name'], array('include_deleted' => TRUE));
$this->assertTrue(!empty($field) && empty($field['deleted']), 'A new field is not marked for deletion.');
- field_delete_field($this->field['field_name']);
+ field_info_field($this->field['field_name'])->delete();
// Make sure that the field is marked as deleted when it is specifically
// loaded.
@@ -315,13 +316,13 @@ function testDeleteField() {
// Make sure the other field (and its field instance) are not deleted.
$another_field = field_read_field($this->another_field['field_name']);
$this->assertTrue(!empty($another_field) && empty($another_field['deleted']), 'A non-deleted field is not marked for deletion.');
- $another_instance = field_read_instance('test_entity', $this->another_instance_definition['field_name'], $this->another_instance_definition['bundle']);
+ $another_instance = field_read_instance('test_entity', $another_instance_definition['field_name'], $another_instance_definition['bundle']);
$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.
- field_create_field($this->field);
- field_create_instance($this->instance_definition);
+ entity_create('field_entity', $this->field)->save();
+ entity_create('field_instance', $this->instance_definition)->save();
$field = field_read_field($this->field['field_name']);
$this->assertTrue(!empty($field) && empty($field['deleted']), 'A new field with a previously used name is created.');
$instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']);
@@ -345,12 +346,13 @@ function testDeleteField() {
}
function testUpdateFieldType() {
- $field = array('field_name' => 'field_type', 'type' => 'number_decimal');
- $field = field_create_field($field);
+ $field_definition = array('field_name' => 'field_type', 'type' => 'number_decimal');
+ $field = entity_create('field_entity', $field_definition);
+ $field->save();
- $test_field = array('field_name' => 'field_type', 'type' => 'number_integer');
try {
- field_update_field($test_field);
+ $field['type'] = 'number_integer';
+ $field->save();
$this->fail(t('Cannot update a field to a different type.'));
}
catch (FieldException $e) {
@@ -366,16 +368,18 @@ function testUpdateField() {
// respected. Since cardinality enforcement is consistent across database
// systems, it makes a good test case.
$cardinality = 4;
- $field = field_create_field(array(
+ $field = entity_create('field_entity', array(
'field_name' => 'field_update',
'type' => 'test_field',
'cardinality' => $cardinality,
));
- $instance = field_create_instance(array(
+ $field->save();
+ $instance = entity_create('field_instance', array(
'field_name' => 'field_update',
'entity_type' => 'test_entity',
'bundle' => 'test_bundle',
));
+ $instance->save();
do {
// We need a unique ID for our entity. $cardinality will do.
@@ -397,7 +401,7 @@ function testUpdateField() {
}
// Increase $cardinality and set the field cardinality to the new value.
$field['cardinality'] = ++$cardinality;
- field_update_field($field);
+ $field->save();
} while ($cardinality < 6);
}
@@ -406,10 +410,11 @@ function testUpdateField() {
*/
function testUpdateFieldForbid() {
$field = array('field_name' => 'forbidden', 'type' => 'test_field', 'settings' => array('changeable' => 0, 'unchangeable' => 0));
- $field = field_create_field($field);
+ $field = entity_create('field_entity', $field);
+ $field->save();
$field['settings']['changeable']++;
try {
- field_update_field($field);
+ $field->save();
$this->pass(t("A changeable setting can be updated."));
}
catch (FieldException $e) {
@@ -417,7 +422,7 @@ function testUpdateFieldForbid() {
}
$field['settings']['unchangeable']++;
try {
- field_update_field($field);
+ $field->save();
$this->fail(t("An unchangeable setting can be updated."));
}
catch (FieldException $e) {
diff --git a/core/modules/field/lib/Drupal/field/Tests/DisplayApiTest.php b/core/modules/field/lib/Drupal/field/Tests/DisplayApiTest.php
index 39d9594..570e872 100644
--- a/core/modules/field/lib/Drupal/field/Tests/DisplayApiTest.php
+++ b/core/modules/field/lib/Drupal/field/Tests/DisplayApiTest.php
@@ -52,8 +52,8 @@ function setUp() {
),
);
- field_create_field($this->field);
- field_create_instance($this->instance);
+ entity_create('field_entity', $this->field)->save();
+ entity_create('field_instance', $this->instance)->save();
// Create a display for the default view mode.
entity_get_display($this->instance['entity_type'], $this->instance['bundle'], 'default')
->setComponent($this->field_name, $this->display_options['default'])
diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldAccessTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldAccessTest.php
index b63d48d..3416f31 100644
--- a/core/modules/field/lib/Drupal/field/Tests/FieldAccessTest.php
+++ b/core/modules/field/lib/Drupal/field/Tests/FieldAccessTest.php
@@ -41,13 +41,13 @@ function setUp() {
'field_name' => 'test_view_field',
'type' => 'text',
);
- field_create_field($this->field);
+ entity_create('field_entity', $this->field)->save();
$this->instance = array(
'field_name' => $this->field['field_name'],
'entity_type' => 'node',
'bundle' => $this->content_type,
);
- field_create_instance($this->instance);
+ entity_create('field_instance', $this->instance)->save();
// Assign display properties for the 'default' and 'teaser' view modes.
foreach (array('default', 'teaser') as $view_mode) {
diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php
index 4bc03be..a3558a7 100644
--- a/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php
+++ b/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php
@@ -191,9 +191,10 @@ function testFieldAttachPrepareViewMultiple() {
// hook_field_formatter_prepare_view().
field_test_create_bundle('test_bundle_2');
$formatter_setting = $this->randomName();
- $this->instance2 = $this->instance;
- $this->instance2['bundle'] = 'test_bundle_2';
- field_create_instance($this->instance2);
+ $instance_definition = $this->instance_definition;
+ $instance_definition['bundle'] = 'test_bundle_2';
+ $this->instance2 = entity_create('field_instance', $instance_definition);
+ $this->instance2->save();
$display_2 = entity_get_display('test_entity', 'test_bundle_2', 'full')
->setComponent($this->field['field_name'], array(
@@ -267,9 +268,9 @@ function testFieldAttachCache() {
'fttype' => $this->instance['bundle'],
));
$cid = "field:$entity_type:{$entity_init->ftid}";
- $instance = $this->instance;
- $instance['entity_type'] = $entity_type;
- field_create_instance($instance);
+ $instance_definition = $this->instance_definition;
+ $instance_definition['entity_type'] = $entity_type;
+ entity_create('field_instance', $instance_definition)->save();
// Check that no initial cache entry is present.
$this->assertFalse(cache('field')->get($cid), 'Cached: no initial cache entry');
diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php
index b9e87c7..e1f783a 100644
--- a/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php
+++ b/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php
@@ -14,6 +14,14 @@
* all hook_field_attach_pre_{load,insert,update}() hooks.
*/
class FieldAttachStorageTest extends FieldUnitTestBase {
+
+ /**
+ * The field instance.
+ *
+ * @var \Drupal\field\Plugin\Core\Entity\FieldInstance
+ */
+ protected $instance;
+
public static function getInfo() {
return array(
'name' => 'Field attach tests (storage-related)',
@@ -37,7 +45,7 @@ function testFieldAttachSaveLoad() {
// Configure the instance so that we test hook_field_load() (see
// field_test_field_load() in field_test.module).
$this->instance['settings']['test_hook_field_load'] = TRUE;
- field_update_instance($this->instance);
+ $this->instance->save();
$langcode = LANGUAGE_NOT_SPECIFIED;
$entity_type = 'test_entity';
@@ -115,11 +123,11 @@ function testFieldAttachLoadMultiple() {
);
for ($i = 1; $i <= 3; $i++) {
$field_names[$i] = 'field_' . $i;
- $field = array('field_name' => $field_names[$i], 'type' => 'test_field');
- $field = field_create_field($field);
+ $field = entity_create('field_entity', array('field_name' => $field_names[$i], 'type' => 'test_field'));
+ $field->save();
$field_ids[$i] = $field['uuid'];
foreach ($field_bundles_map[$i] as $bundle) {
- $instance = array(
+ entity_create('field_instance', array(
'field_name' => $field_names[$i],
'entity_type' => 'test_entity',
'bundle' => $bundles[$bundle],
@@ -128,8 +136,7 @@ function testFieldAttachLoadMultiple() {
// (see field_test_field_load() in field_test.module).
'test_hook_field_load' => TRUE,
),
- );
- field_create_instance($instance);
+ ))->save();
}
}
@@ -189,13 +196,13 @@ function testFieldAttachSaveLoadDifferentStorage() {
),
);
foreach ($fields as $field) {
- field_create_field($field);
+ entity_create('field_entity', $field)->save();
$instance = array(
'field_name' => $field['field_name'],
'entity_type' => 'test_entity',
'bundle' => 'test_bundle',
);
- field_create_instance($instance);
+ entity_create('field_instance', $instance)->save();
}
$entity_init = field_test_create_entity();
@@ -224,22 +231,19 @@ function testFieldAttachSaveLoadDifferentStorage() {
*/
function testFieldStorageDetailsAlter() {
$field_name = 'field_test_change_my_details';
- $field = array(
+ $field = entity_create('field_entity', array(
'field_name' => $field_name,
'type' => 'test_field',
'cardinality' => 4,
'storage' => array('type' => 'field_test_storage'),
- );
- $field = field_create_field($field);
- $instance = array(
+ ));
+ $field->save();
+ $instance = entity_create('field_instance', array(
'field_name' => $field_name,
'entity_type' => 'test_entity',
'bundle' => 'test_bundle',
- );
- field_create_instance($instance);
-
- $field = field_info_field($instance['field_name']);
- $instance = field_info_instance($instance['entity_type'], $instance['field_name'], $instance['bundle']);
+ ));
+ $instance->save();
// The storage details are indexed by a storage engine type.
$this->assertTrue(array_key_exists('drupal_variables', $field['storage_details']), 'The storage type is Drupal variables.');
@@ -343,7 +347,7 @@ function testFieldAttachSaveMissingData() {
function testFieldAttachSaveMissingDataDefaultValue() {
// Add a default value function.
$this->instance['default_value_function'] = 'field_test_default_value';
- field_update_instance($this->instance);
+ $this->instance->save();
// Verify that fields are populated with default values.
$entity_type = 'test_entity';
@@ -442,8 +446,8 @@ function testEntityCreateRenameBundle() {
field_test_create_bundle($new_bundle);
// Add an instance to that bundle.
- $this->instance['bundle'] = $new_bundle;
- field_create_instance($this->instance);
+ $this->instance_definition['bundle'] = $new_bundle;
+ entity_create('field_instance', $this->instance_definition)->save();
// Save an entity with data in the field.
$entity = field_test_create_entity(0, 0, $this->instance['bundle']);
@@ -481,13 +485,13 @@ function testEntityDeleteBundle() {
field_test_create_bundle($new_bundle);
// Add an instance to that bundle.
- $this->instance['bundle'] = $new_bundle;
- field_create_instance($this->instance);
+ $this->instance_definition['bundle'] = $new_bundle;
+ entity_create('field_instance', $this->instance_definition)->save();
// Create a second field for the test bundle
$field_name = drupal_strtolower($this->randomName() . '_field_name');
$field = array('field_name' => $field_name, 'type' => 'test_field', 'cardinality' => 1);
- field_create_field($field);
+ entity_create('field_entity', $field)->save();
$instance = array(
'field_name' => $field_name,
'entity_type' => 'test_entity',
@@ -496,7 +500,7 @@ function testEntityDeleteBundle() {
'description' => $this->randomName() . '_description',
'weight' => mt_rand(0, 127),
);
- field_create_instance($instance);
+ entity_create('field_instance', $instance)->save();
// Save an entity with data for both fields
$entity = field_test_create_entity(0, 0, $this->instance['bundle']);
diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldInfoTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldInfoTest.php
index dd093d5..6813162 100644
--- a/core/modules/field/lib/Drupal/field/Tests/FieldInfoTest.php
+++ b/core/modules/field/lib/Drupal/field/Tests/FieldInfoTest.php
@@ -2,7 +2,7 @@
/**
* @file
- * Definition of Drupal\field\Tests\FieldInfoTest.
+ * Contains \Drupal\field\Tests\FieldInfoTest.
*/
namespace Drupal\field\Tests;
@@ -54,11 +54,11 @@ function testFieldInfo() {
// Create a field, verify it shows up.
$core_fields = field_info_fields();
- $field = array(
+ $field = entity_create('field_entity', array(
'field_name' => drupal_strtolower($this->randomName()),
'type' => 'test_field',
- );
- field_create_field($field);
+ ));
+ $field->save();
$fields = field_info_fields();
$this->assertEqual(count($fields), count($core_fields) + 1, 'One new field exists');
$this->assertEqual($fields[$field['field_name']]['field_name'], $field['field_name'], 'info fields contains field name');
@@ -72,7 +72,7 @@ function testFieldInfo() {
$this->assertEqual($fields[$field['field_name']]['active'], TRUE, 'info fields contains active 1');
// Create an instance, verify that it shows up
- $instance = array(
+ $instance_definition = array(
'field_name' => $field['field_name'],
'entity_type' => 'test_entity',
'bundle' => 'test_bundle',
@@ -80,14 +80,15 @@ function testFieldInfo() {
'description' => $this->randomName(),
'weight' => mt_rand(0, 127),
);
- field_create_instance($instance);
+ $instance = entity_create('field_instance', $instance_definition);
+ $instance->save();
$info = entity_get_info('test_entity');
$instances = field_info_instances('test_entity', $instance['bundle']);
$this->assertEqual(count($instances), 1, format_string('One instance shows up in info when attached to a bundle on a @label.', array(
'@label' => $info['label']
)));
- $this->assertTrue($instance < $instances[$instance['field_name']], 'Instance appears in info correctly');
+ $this->assertTrue($instance_definition < $instances[$instance['field_name']], 'Instance appears in info correctly');
// Test a valid entity type but an invalid bundle.
$instances = field_info_instances('test_entity', 'invalid_bundle');
@@ -127,7 +128,8 @@ function testFieldPrepare() {
'field_name' => 'field',
'type' => 'test_field',
);
- $field = field_create_field($field_definition);
+ $field = entity_create('field_entity', $field_definition);
+ $field->save();
// Simulate a stored field definition missing a field setting (e.g. a
// third-party module adding a new field setting has been enabled, and
@@ -153,13 +155,14 @@ function testInstancePrepare() {
'field_name' => 'field',
'type' => 'test_field',
);
- field_create_field($field_definition);
+ entity_create('field_entity', $field_definition)->save();
$instance_definition = array(
'field_name' => $field_definition['field_name'],
'entity_type' => 'test_entity',
'bundle' => 'test_bundle',
);
- $instance = field_create_instance($instance_definition);
+ $instance = entity_create('field_instance', $instance_definition);
+ $instance->save();
// Simulate a stored instance definition missing various settings (e.g. a
// third-party module adding instance or widget settings has been enabled,
@@ -189,13 +192,13 @@ function testInstanceDisabledEntityType() {
'field_name' => 'field',
'type' => 'test_field',
);
- field_create_field($field_definition);
+ entity_create('field_entity', $field_definition)->save();
$instance_definition = array(
'field_name' => 'field',
'entity_type' => 'comment',
'bundle' => 'comment_node_article',
);
- field_create_instance($instance_definition);
+ entity_create('field_instance', $instance_definition)->save();
// Disable coment module. This clears field_info cache.
module_disable(array('comment'));
@@ -224,7 +227,7 @@ function testFieldMap() {
),
);
foreach ($fields as $field) {
- field_create_field($field);
+ entity_create('field_entity', $field)->save();
}
// Create a couple instances.
@@ -251,7 +254,7 @@ function testFieldMap() {
),
);
foreach ($instances as $instance) {
- field_create_instance($instance);
+ entity_create('field_instance', $instance)->save();
}
$expected = array(
@@ -308,11 +311,11 @@ function testFieldInfoCache() {
// Create a test field and ensure it's in the array returned by
// field_info_fields().
$field_name = drupal_strtolower($this->randomName());
- $field = array(
+ $field = entity_create('field_entity', array(
'field_name' => $field_name,
'type' => 'test_field',
- );
- field_create_field($field);
+ ));
+ $field->save();
$fields = field_info_fields();
$this->assertTrue(isset($fields[$field_name]), 'The test field is initially found in the array returned by field_info_fields().');
diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldInstanceCrudTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldInstanceCrudTest.php
index 5f9578a..4e8fff1 100644
--- a/core/modules/field/lib/Drupal/field/Tests/FieldInstanceCrudTest.php
+++ b/core/modules/field/lib/Drupal/field/Tests/FieldInstanceCrudTest.php
@@ -2,18 +2,36 @@
/**
* @file
- * Definition of Drupal\field\Tests\FieldInstanceCrudTest.
+ * Contains \Drupal\field\Tests\FieldInstanceCrudTest.
*/
namespace Drupal\field\Tests;
use Drupal\field\FieldException;
-use Drupal\field\Plugin\Core\Entity\FieldInstance;
class FieldInstanceCrudTest extends FieldUnitTestBase {
+ /**
+ * The field entity.
+ *
+ * @var \Drupal\field\Plugin\Core\Entity\Field
+ */
protected $field;
+ /**
+ * The field entity definition.
+ *
+ * @var array
+ */
+ protected $field_definition;
+
+ /**
+ * The field instance entity definition.
+ *
+ * @var array
+ */
+ protected $instance_definition;
+
public static function getInfo() {
return array(
'name' => 'Field instance CRUD tests',
@@ -25,11 +43,12 @@ public static function getInfo() {
function setUp() {
parent::setUp();
- $this->field = array(
+ $this->field_definition = array(
'field_name' => drupal_strtolower($this->randomName()),
'type' => 'test_field',
);
- field_create_field($this->field);
+ $this->field = entity_create('field_entity', $this->field_definition);
+ $this->field->save();
$this->instance_definition = array(
'field_name' => $this->field['field_name'],
'entity_type' => 'test_entity',
@@ -47,14 +66,15 @@ function setUp() {
* Test the creation of a field instance.
*/
function testCreateFieldInstance() {
- $instance = field_create_instance($this->instance_definition);
+ $instance = entity_create('field_instance', $this->instance_definition);
+ $instance->save();
// 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.
$config = \Drupal::config('field.instance.' . $instance->id())->get();
- $field_type = field_info_field_types($this->field['type']);
+ $field_type = field_info_field_types($this->field_definition['type']);
// Check that default values are set.
$this->assertEqual($config['required'], FALSE, 'Required defaults to false.');
@@ -66,7 +86,7 @@ function testCreateFieldInstance() {
// Guarantee that the field/bundle combination is unique.
try {
- field_create_instance($this->instance_definition);
+ entity_create('field_instance', $this->instance_definition)->save();
$this->fail(t('Cannot create two instances with the same field / bundle combination.'));
}
catch (FieldException $e) {
@@ -76,7 +96,7 @@ function testCreateFieldInstance() {
// Check that the specified field exists.
try {
$this->instance_definition['field_name'] = $this->randomName();
- field_create_instance($this->instance_definition);
+ entity_create('field_instance', $this->instance_definition)->save();
$this->fail(t('Cannot create an instance of a non-existing field.'));
}
catch (FieldException $e) {
@@ -84,20 +104,21 @@ function testCreateFieldInstance() {
}
// Create a field restricted to a specific entity type.
- $field_restricted = array(
+ $field_restricted_definition = array(
'field_name' => drupal_strtolower($this->randomName()),
'type' => 'test_field',
'entity_types' => array('test_cacheable_entity'),
);
- field_create_field($field_restricted);
+ $field_restricted = entity_create('field_entity', $field_restricted_definition);
+ $field_restricted->save();
// Check that an instance can be added to an entity type allowed
// by the field.
try {
$instance = $this->instance_definition;
- $instance['field_name'] = $field_restricted['field_name'];
+ $instance['field_name'] = $field_restricted_definition['field_name'];
$instance['entity_type'] = 'test_cacheable_entity';
- field_create_instance($instance);
+ entity_create('field_instance', $instance)->save();
$this->pass(t('Can create an instance on an entity type allowed by the field.'));
}
catch (FieldException $e) {
@@ -108,8 +129,8 @@ function testCreateFieldInstance() {
// forbidden by the field.
try {
$instance = $this->instance_definition;
- $instance['field_name'] = $field_restricted['field_name'];
- field_create_instance($instance);
+ $instance['field_name'] = $field_restricted_definition['field_name'];
+ entity_create('field_instance', $instance)->save();
$this->fail(t('Cannot create an instance on an entity type forbidden by the field.'));
}
catch (FieldException $e) {
@@ -123,7 +144,7 @@ function testCreateFieldInstance() {
* Test reading back an instance definition.
*/
function testReadFieldInstance() {
- field_create_instance($this->instance_definition);
+ entity_create('field_instance', $this->instance_definition)->save();
// Read the instance back.
$instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']);
@@ -136,7 +157,7 @@ function testReadFieldInstance() {
* Test the update of a field instance.
*/
function testUpdateFieldInstance() {
- field_create_instance($this->instance_definition);
+ entity_create('field_instance', $this->instance_definition)->save();
// Check that basic changes are saved.
$instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']);
@@ -144,7 +165,7 @@ function testUpdateFieldInstance() {
$instance['label'] = $this->randomName();
$instance['description'] = $this->randomName();
$instance['settings']['test_instance_setting'] = $this->randomName();
- field_update_instance($instance);
+ $instance->save();
$instance_new = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']);
$this->assertEqual($instance['required'], $instance_new['required'], '"required" change is saved');
@@ -164,15 +185,15 @@ function testDeleteFieldInstance() {
// Create two instances for the same field so we can test that only one
// is deleted.
- field_create_instance($this->instance_definition);
- $this->another_instance_definition = $this->instance_definition;
- $this->another_instance_definition['bundle'] .= '_another_bundle';
- $instance = field_create_instance($this->another_instance_definition);
+ entity_create('field_instance', $this->instance_definition)->save();
+ $another_instance_definition = $this->instance_definition;
+ $another_instance_definition['bundle'] .= '_another_bundle';
+ entity_create('field_instance', $another_instance_definition)->save();
// Test that the first instance is not deleted, and then delete it.
$instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle'], array('include_deleted' => TRUE));
$this->assertTrue(!empty($instance) && empty($instance['deleted']), 'A new field instance is not marked for deletion.');
- field_delete_instance($instance);
+ $instance->delete();
// Make sure the instance is marked as deleted when the instance is
// specifically loaded.
@@ -184,11 +205,11 @@ function testDeleteFieldInstance() {
$this->assertTrue(empty($instance), 'A deleted field instance is not loaded by default.');
// Make sure the other field instance is not deleted.
- $another_instance = field_read_instance('test_entity', $this->another_instance_definition['field_name'], $this->another_instance_definition['bundle']);
+ $another_instance = field_read_instance('test_entity', $another_instance_definition['field_name'], $another_instance_definition['bundle']);
$this->assertTrue(!empty($another_instance) && empty($another_instance['deleted']), 'A non-deleted field instance is not marked for deletion.');
// Make sure the field is deleted when its last instance is deleted.
- field_delete_instance($another_instance);
+ $another_instance->delete();
$deleted_fields = \Drupal::state()->get('field.field.deleted');
$this->assertTrue(isset($deleted_fields[$another_instance['field_id']]), 'A deleted field is marked for deletion.');
$field = field_read_field($another_instance['field_name']);
diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldUnitTestBase.php b/core/modules/field/lib/Drupal/field/Tests/FieldUnitTestBase.php
index ed3c151..1199d2c 100644
--- a/core/modules/field/lib/Drupal/field/Tests/FieldUnitTestBase.php
+++ b/core/modules/field/lib/Drupal/field/Tests/FieldUnitTestBase.php
@@ -54,12 +54,13 @@ function createFieldWithInstance($suffix = '') {
$field = 'field' . $suffix;
$field_id = 'field_id' . $suffix;
$instance = 'instance' . $suffix;
+ $instance_definition = 'instance_definition' . $suffix;
$this->$field_name = drupal_strtolower($this->randomName() . '_field_name' . $suffix);
- $this->$field = array('field_name' => $this->$field_name, 'type' => 'test_field', 'cardinality' => 4);
- $this->$field = field_create_field($this->$field);
+ $this->$field = entity_create('field_entity', array('field_name' => $this->$field_name, 'type' => 'test_field', 'cardinality' => 4));
+ $this->$field->save();
$this->$field_id = $this->{$field}['uuid'];
- $this->$instance = array(
+ $this->$instance_definition = array(
'field_name' => $this->$field_name,
'entity_type' => 'test_entity',
'bundle' => 'test_bundle',
@@ -70,7 +71,8 @@ function createFieldWithInstance($suffix = '') {
'test_instance_setting' => $this->randomName(),
),
);
- field_create_instance($this->$instance);
+ $this->$instance = entity_create('field_instance', $this->$instance_definition);
+ $this->$instance->save();
entity_get_form_display('test_entity', 'test_bundle', 'default')
->setComponent($this->$field_name, array(
diff --git a/core/modules/field/lib/Drupal/field/Tests/FormTest.php b/core/modules/field/lib/Drupal/field/Tests/FormTest.php
index 3d2aac3..8903006 100644
--- a/core/modules/field/lib/Drupal/field/Tests/FormTest.php
+++ b/core/modules/field/lib/Drupal/field/Tests/FormTest.php
@@ -50,8 +50,8 @@ function testFieldFormSingle() {
$this->field = $this->field_single;
$this->field_name = $this->field['field_name'];
$this->instance['field_name'] = $this->field_name;
- field_create_field($this->field);
- field_create_instance($this->instance);
+ entity_create('field_entity', $this->field)->save();
+ entity_create('field_instance', $this->instance)->save();
entity_get_form_display($this->instance['entity_type'], $this->instance['bundle'], 'default')
->setComponent($this->field_name)
->save();
@@ -119,8 +119,8 @@ function testFieldFormDefaultValue() {
$this->instance['field_name'] = $this->field_name;
$default = rand(1, 127);
$this->instance['default_value'] = array(array('value' => $default));
- field_create_field($this->field);
- field_create_instance($this->instance);
+ entity_create('field_entity', $this->field)->save();
+ entity_create('field_instance', $this->instance)->save();
entity_get_form_display($this->instance['entity_type'], $this->instance['bundle'], 'default')
->setComponent($this->field_name)
->save();
@@ -146,8 +146,8 @@ function testFieldFormSingleRequired() {
$this->field_name = $this->field['field_name'];
$this->instance['field_name'] = $this->field_name;
$this->instance['required'] = TRUE;
- field_create_field($this->field);
- field_create_instance($this->instance);
+ entity_create('field_entity', $this->field)->save();
+ entity_create('field_instance', $this->instance)->save();
entity_get_form_display($this->instance['entity_type'], $this->instance['bundle'], 'default')
->setComponent($this->field_name)
->save();
@@ -179,16 +179,16 @@ function testFieldFormSingleRequired() {
// $this->field = $this->field_multiple;
// $this->field_name = $this->field['field_name'];
// $this->instance['field_name'] = $this->field_name;
-// field_create_field($this->field);
-// field_create_instance($this->instance);
+// entity_create('field_entity', $this->field)->save();
+// entity_create('field_instance', $this->instance)->save();
// }
function testFieldFormUnlimited() {
$this->field = $this->field_unlimited;
$this->field_name = $this->field['field_name'];
$this->instance['field_name'] = $this->field_name;
- field_create_field($this->field);
- field_create_instance($this->instance);
+ entity_create('field_entity', $this->field)->save();
+ entity_create('field_instance', $this->instance)->save();
entity_get_form_display($this->instance['entity_type'], $this->instance['bundle'], 'default')
->setComponent($this->field_name)
->save();
@@ -270,28 +270,28 @@ function testFieldFormMultivalueWithRequiredRadio() {
$this->field = $this->field_unlimited;
$this->field_name = $this->field['field_name'];
$this->instance['field_name'] = $this->field_name;
- field_create_field($this->field);
- field_create_instance($this->instance);
+ entity_create('field_entity', $this->field)->save();
+ entity_create('field_instance', $this->instance)->save();
entity_get_form_display($this->instance['entity_type'], $this->instance['bundle'], 'default')
->setComponent($this->field_name)
->save();
$langcode = LANGUAGE_NOT_SPECIFIED;
// Add a required radio field.
- field_create_field(array(
+ entity_create('field_entity', array(
'field_name' => 'required_radio_test',
'type' => 'list_text',
'settings' => array(
'allowed_values' => array('yes' => 'yes', 'no' => 'no'),
),
- ));
+ ))->save();
$instance = array(
'field_name' => 'required_radio_test',
'entity_type' => 'test_entity',
'bundle' => 'test_bundle',
'required' => TRUE,
);
- field_create_instance($instance);
+ entity_create('field_instance', $instance)->save();
entity_get_form_display($instance['entity_type'], $instance['bundle'], 'default')
->setComponent($instance['field_name'], array(
'type' => 'options_buttons',
@@ -317,8 +317,8 @@ function testFieldFormJSAddMore() {
$this->field = $this->field_unlimited;
$this->field_name = $this->field['field_name'];
$this->instance['field_name'] = $this->field_name;
- field_create_field($this->field);
- field_create_instance($this->instance);
+ entity_create('field_entity', $this->field)->save();
+ entity_create('field_instance', $this->instance)->save();
entity_get_form_display($this->instance['entity_type'], $this->instance['bundle'], 'default')
->setComponent($this->field_name)
->save();
@@ -379,8 +379,8 @@ function testFieldFormMultipleWidget() {
$this->field = $this->field_multiple;
$this->field_name = $this->field['field_name'];
$this->instance['field_name'] = $this->field_name;
- field_create_field($this->field);
- field_create_instance($this->instance);
+ entity_create('field_entity', $this->field)->save();
+ entity_create('field_instance', $this->instance)->save();
entity_get_form_display($this->instance['entity_type'], $this->instance['bundle'], 'default')
->setComponent($this->field_name, array(
'type' => 'test_field_widget_multiple',
@@ -423,8 +423,8 @@ function testFieldFormAccess() {
$field_name = $field['field_name'];
$instance = $this->instance;
$instance['field_name'] = $field_name;
- field_create_field($field);
- field_create_instance($instance);
+ entity_create('field_entity', $field)->save();
+ entity_create('field_instance', $instance)->save();
entity_get_form_display($this->instance['entity_type'], $this->instance['bundle'], 'default')
->setComponent($field_name)
->save();
@@ -441,8 +441,8 @@ function testFieldFormAccess() {
'bundle' => 'test_bundle',
'default_value' => array(0 => array('value' => 99)),
);
- field_create_field($field_no_access);
- field_create_instance($instance_no_access);
+ entity_create('field_entity', $field_no_access)->save();
+ entity_create('field_instance', $instance_no_access)->save();
entity_get_form_display($instance_no_access['entity_type'], $instance_no_access['bundle'], 'default')
->setComponent($field_name_no_access)
->save();
@@ -498,17 +498,17 @@ function testFieldFormAccess() {
*/
function testNestedFieldForm() {
// Add two instances on the 'test_bundle'
- field_create_field($this->field_single);
- field_create_field($this->field_unlimited);
+ entity_create('field_entity', $this->field_single)->save();
+ entity_create('field_entity', $this->field_unlimited)->save();
$this->instance['field_name'] = 'field_single';
$this->instance['label'] = 'Single field';
- field_create_instance($this->instance);
+ entity_create('field_instance', $this->instance)->save();
entity_get_form_display($this->instance['entity_type'], $this->instance['bundle'], 'default')
->setComponent($this->instance['field_name'])
->save();
$this->instance['field_name'] = 'field_unlimited';
$this->instance['label'] = 'Unlimited field';
- field_create_instance($this->instance);
+ entity_create('field_instance', $this->instance)->save();
entity_get_form_display($this->instance['entity_type'], $this->instance['bundle'], 'default')
->setComponent($this->instance['field_name'])
->save();
@@ -616,8 +616,9 @@ function testFieldFormHiddenWidget() {
$this->field_name = $this->field['field_name'];
$this->instance['field_name'] = $this->field_name;
$this->instance['default_value'] = array(0 => array('value' => 99));
- field_create_field($this->field);
- field_create_instance($this->instance);
+ entity_create('field_entity', $this->field)->save();
+ $this->instance = entity_create('field_instance', $this->instance);
+ $this->instance->save();
entity_get_form_display($this->instance['entity_type'], $this->instance['bundle'], 'default')
->setComponent($this->instance['field_name'], array(
'type' => 'hidden',
@@ -641,7 +642,7 @@ function testFieldFormHiddenWidget() {
// Update the instance to remove the default value and switch to the
// default widget.
$this->instance['default_value'] = NULL;
- field_update_instance($this->instance);
+ $this->instance->save();
entity_get_form_display($this->instance['entity_type'], $this->instance['bundle'], 'default')
->setComponent($this->instance['field_name'], array(
'type' => 'test_field_widget',
diff --git a/core/modules/field/lib/Drupal/field/Tests/ShapeItemTest.php b/core/modules/field/lib/Drupal/field/Tests/ShapeItemTest.php
index 4e92d7e..3437924 100644
--- a/core/modules/field/lib/Drupal/field/Tests/ShapeItemTest.php
+++ b/core/modules/field/lib/Drupal/field/Tests/ShapeItemTest.php
@@ -38,13 +38,13 @@ public function setUp() {
'field_name' => 'field_shape',
'type' => 'shape',
);
- field_create_field($this->field);
+ entity_create('field_entity', $this->field)->save();
$this->instance = array(
'entity_type' => 'entity_test',
'field_name' => 'field_shape',
'bundle' => 'entity_test',
);
- field_create_instance($this->instance);
+ entity_create('field_instance', $this->instance)->save();
}
/**
diff --git a/core/modules/field/lib/Drupal/field/Tests/TestItemTest.php b/core/modules/field/lib/Drupal/field/Tests/TestItemTest.php
index c8ff8fa..063dca4 100644
--- a/core/modules/field/lib/Drupal/field/Tests/TestItemTest.php
+++ b/core/modules/field/lib/Drupal/field/Tests/TestItemTest.php
@@ -38,13 +38,13 @@ public function setUp() {
'field_name' => 'field_test',
'type' => 'test_field',
);
- field_create_field($this->field);
+ entity_create('field_entity', $this->field)->save();
$this->instance = array(
'entity_type' => 'entity_test',
'field_name' => 'field_test',
'bundle' => 'entity_test',
);
- field_create_instance($this->instance);
+ entity_create('field_instance', $this->instance)->save();
}
/**
diff --git a/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php b/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php
index 24b7063..0636e96 100644
--- a/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php
+++ b/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php
@@ -49,7 +49,7 @@ function setUp() {
'cardinality' => 4,
'translatable' => TRUE,
);
- field_create_field($this->field_definition);
+ entity_create('field_entity', $this->field_definition)->save();
$this->field = field_read_field($this->field_name);
$this->instance_definition = array(
@@ -57,7 +57,7 @@ function setUp() {
'entity_type' => $this->entity_type,
'bundle' => 'test_bundle',
);
- field_create_instance($this->instance_definition);
+ entity_create('field_instance', $this->instance_definition)->save();
$this->instance = field_read_instance('test_entity', $this->field_name, 'test_bundle');
for ($i = 0; $i < 3; ++$i) {
@@ -95,7 +95,7 @@ function testFieldAvailableLanguages() {
// Test field_available_languages() behavior for untranslatable fields.
$this->field['translatable'] = FALSE;
- field_update_field($this->field);
+ $this->field->save();
$available_langcodes = field_available_languages($this->entity_type, $this->field);
$this->assertTrue(count($available_langcodes) == 1 && $available_langcodes[0] === LANGUAGE_NOT_SPECIFIED, 'For untranslatable fields only LANGUAGE_NOT_SPECIFIED is available.');
}
@@ -251,12 +251,13 @@ function testTranslatableFieldSaveLoad() {
$field_name_default = drupal_strtolower($this->randomName() . '_field_name');
$field_definition = $this->field_definition;
$field_definition['field_name'] = $field_name_default;
- $field = field_create_field($field_definition);
+ entity_create('field_entity', $field_definition)->save();
$instance_definition = $this->instance_definition;
$instance_definition['field_name'] = $field_name_default;
$instance_definition['default_value'] = array(array('value' => rand(1, 127)));
- $instance = field_create_instance($instance_definition);
+ $instance = entity_create('field_instance', $instance_definition);
+ $instance->save();
$translation_langcodes = array_slice($available_langcodes, 0, 2);
asort($translation_langcodes);
@@ -310,14 +311,14 @@ function testFieldDisplayLanguage() {
'cardinality' => 2,
'translatable' => TRUE,
);
- field_create_field($field);
+ entity_create('field_entity', $field)->save();
$instance = array(
'field_name' => $field['field_name'],
'entity_type' => $entity_type,
'bundle' => 'test_bundle',
);
- field_create_instance($instance);
+ entity_create('field_instance', $instance)->save();
$entity = field_test_create_entity(1, 1, $this->instance['bundle']);
$instances = field_info_instances($entity_type, $this->instance['bundle']);
diff --git a/core/modules/field/lib/Drupal/field/Tests/TranslationWebTest.php b/core/modules/field/lib/Drupal/field/Tests/TranslationWebTest.php
index a32cc81..248ebe6 100644
--- a/core/modules/field/lib/Drupal/field/Tests/TranslationWebTest.php
+++ b/core/modules/field/lib/Drupal/field/Tests/TranslationWebTest.php
@@ -42,7 +42,7 @@ function setUp() {
'cardinality' => 4,
'translatable' => TRUE,
);
- field_create_field($field);
+ entity_create('field_entity', $field)->save();
$this->field = field_read_field($this->field_name);
$instance = array(
@@ -50,7 +50,7 @@ function setUp() {
'entity_type' => $this->entity_type,
'bundle' => 'test_bundle',
);
- field_create_instance($instance);
+ entity_create('field_instance', $instance)->save();
$this->instance = field_read_instance('test_entity', $this->field_name, 'test_bundle');
entity_get_form_display($this->entity_type, 'test_bundle', 'default')
diff --git a/core/modules/field/lib/Drupal/field/Tests/Views/ApiDataTest.php b/core/modules/field/lib/Drupal/field/Tests/Views/ApiDataTest.php
index 54404b6..c6920c7 100644
--- a/core/modules/field/lib/Drupal/field/Tests/Views/ApiDataTest.php
+++ b/core/modules/field/lib/Drupal/field/Tests/Views/ApiDataTest.php
@@ -36,7 +36,7 @@ function setUp() {
'entity_type' => 'node',
'bundle' => 'page',
);
- field_create_instance($instance);
+ entity_create('field_instance', $instance)->save();
// The second one will be attached to users only.
$instance = array(
@@ -44,7 +44,7 @@ function setUp() {
'entity_type' => 'user',
'bundle' => 'user',
);
- field_create_instance($instance);
+ entity_create('field_instance', $instance)->save();
// The third will be attached to both nodes and users.
$instance = array(
@@ -52,13 +52,13 @@ function setUp() {
'entity_type' => 'node',
'bundle' => 'page',
);
- field_create_instance($instance);
+ entity_create('field_instance', $instance)->save();
$instance = array(
'field_name' => $field_names[2],
'entity_type' => 'user',
'bundle' => 'user',
);
- field_create_instance($instance);
+ entity_create('field_instance', $instance)->save();
// Now create some example nodes/users for the view result.
for ($i = 0; $i < 5; $i++) {
diff --git a/core/modules/field/lib/Drupal/field/Tests/Views/FieldTestBase.php b/core/modules/field/lib/Drupal/field/Tests/Views/FieldTestBase.php
index c0f500b..dcc43ae 100644
--- a/core/modules/field/lib/Drupal/field/Tests/Views/FieldTestBase.php
+++ b/core/modules/field/lib/Drupal/field/Tests/Views/FieldTestBase.php
@@ -58,7 +58,8 @@ function setUpFields($amount = 3) {
$field_names[$i] = 'field_name_' . $i;
$field = array('field_name' => $field_names[$i], 'type' => 'text');
- $this->fields[$i] = $field = field_create_field($field);
+ $this->fields[$i] = $field = entity_create('field_entity', $field);
+ $field->save();
}
return $field_names;
}
@@ -70,7 +71,8 @@ function setUpInstances($bundle = 'page') {
'entity_type' => 'node',
'bundle' => 'page',
);
- $this->instances[$key] = field_create_instance($instance);
+ $this->instances[$key] = entity_create('field_instance', $instance);
+ $this->instances[$key]->save();
}
}
diff --git a/core/modules/field/lib/Drupal/field/Tests/Views/HandlerFieldFieldTest.php b/core/modules/field/lib/Drupal/field/Tests/Views/HandlerFieldFieldTest.php
index 6d1975e..87df01c 100644
--- a/core/modules/field/lib/Drupal/field/Tests/Views/HandlerFieldFieldTest.php
+++ b/core/modules/field/lib/Drupal/field/Tests/Views/HandlerFieldFieldTest.php
@@ -46,9 +46,11 @@ protected function setUp() {
$this->setUpFields(3);
// Setup a field with cardinality > 1.
- $this->fields[3] = $field = field_create_field(array('field_name' => 'field_name_3', 'type' => 'text', 'cardinality' => FIELD_CARDINALITY_UNLIMITED));
+ $this->fields[3] = $field = entity_create('field_entity', array('field_name' => 'field_name_3', 'type' => 'text', 'cardinality' => FIELD_CARDINALITY_UNLIMITED));
+ $field->save();
// Setup a field that will have no value.
- $this->fields[4] = $field = field_create_field(array('field_name' => 'field_name_4', 'type' => 'text', 'cardinality' => FIELD_CARDINALITY_UNLIMITED));
+ $this->fields[4] = $field = entity_create('field_entity', array('field_name' => 'field_name_4', 'type' => 'text', 'cardinality' => FIELD_CARDINALITY_UNLIMITED));
+ $field->save();
$this->setUpInstances();
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 2e62f77..6e7b73f 100644
--- a/core/modules/field/tests/modules/field_test/field_test.module
+++ b/core/modules/field/tests/modules/field_test/field_test.module
@@ -147,7 +147,7 @@ function field_test_field_language_alter(&$display_langcode, $context) {
* field_test_memorize();
*
* // call some Field API functions that invoke field_test hooks
- * $field = field_create_field(...);
+ * entity_create('field_entity', $field_definition)->save();
*
* // retrieve and reset the memorized hook call data
* $mem = field_test_memorize();
diff --git a/core/modules/field_sql_storage/lib/Drupal/field_sql_storage/Tests/FieldSqlStorageTest.php b/core/modules/field_sql_storage/lib/Drupal/field_sql_storage/Tests/FieldSqlStorageTest.php
index b7cf45e..e430120 100644
--- a/core/modules/field_sql_storage/lib/Drupal/field_sql_storage/Tests/FieldSqlStorageTest.php
+++ b/core/modules/field_sql_storage/lib/Drupal/field_sql_storage/Tests/FieldSqlStorageTest.php
@@ -40,14 +40,18 @@ function setUp() {
$this->installSchema('field_test', array('test_entity', 'test_entity_revision', 'test_entity_bundle'));
$this->field_name = strtolower($this->randomName());
- $this->field = array('field_name' => $this->field_name, 'type' => 'test_field', 'cardinality' => 4);
- $this->field = field_create_field($this->field);
- $this->instance = array(
+ $this->field = entity_create('field_entity', array(
+ 'field_name' => $this->field_name,
+ 'type' => 'test_field',
+ 'cardinality' => 4,
+ ));
+ $this->field->save();
+ $this->instance = entity_create('field_instance', array(
'field_name' => $this->field_name,
'entity_type' => 'test_entity',
'bundle' => 'test_bundle'
- );
- $this->instance = field_create_instance($this->instance);
+ ));
+ $this->instance->save();
$this->table = _field_sql_storage_tablename($this->field);
$this->revision_table = _field_sql_storage_revision_tablename($this->field);
@@ -304,10 +308,18 @@ function testFieldAttachSaveMissingData() {
*/
function testUpdateFieldSchemaWithData() {
// Create a decimal 5.2 field and add some data.
- $field = array('field_name' => 'decimal52', 'type' => 'number_decimal', 'settings' => array('precision' => 5, 'scale' => 2));
- $field = field_create_field($field);
- $instance = array('field_name' => 'decimal52', 'entity_type' => 'test_entity', 'bundle' => 'test_bundle');
- $instance = field_create_instance($instance);
+ $field = entity_create('field_entity', array(
+ 'field_name' => 'decimal52',
+ 'type' => 'number_decimal',
+ 'settings' => array('precision' => 5, 'scale' => 2),
+ ));
+ $field->save();
+ $instance = entity_create('field_instance', array(
+ 'field_name' => 'decimal52',
+ 'entity_type' => 'test_entity',
+ 'bundle' => 'test_bundle',
+ ));
+ $instance->save();
$entity = field_test_create_entity(0, 0, $instance['bundle']);
$entity->decimal52[LANGUAGE_NOT_SPECIFIED][0]['value'] = '1.235';
$entity->save();
@@ -315,7 +327,7 @@ function testUpdateFieldSchemaWithData() {
// Attempt to update the field in a way that would work without data.
$field['settings']['scale'] = 3;
try {
- field_update_field($field);
+ $field->save();
$this->fail(t('Cannot update field schema with data.'));
}
catch (FieldException $e) {
@@ -328,14 +340,18 @@ function testUpdateFieldSchemaWithData() {
*/
function testFieldUpdateFailure() {
// Create a text field.
- $field = array('field_name' => 'test_text', 'type' => 'text', 'settings' => array('max_length' => 255));
- $field = field_create_field($field);
+ $field = entity_create('field_entity', array(
+ 'field_name' => 'test_text',
+ 'type' => 'text',
+ 'settings' => array('max_length' => 255),
+ ));
+ $field->save();
// Attempt to update the field in a way that would break the storage.
$prior_field = $field;
$field['settings']['max_length'] = -1;
try {
- field_update_field($field);
+ $field->save();
$this->fail(t('Update succeeded.'));
}
catch (\Exception $e) {
@@ -355,10 +371,14 @@ function testFieldUpdateIndexesWithData() {
// Create a decimal field.
$field_name = 'testfield';
- $field = array('field_name' => $field_name, 'type' => 'text');
- $field = field_create_field($field);
- $instance = array('field_name' => $field_name, 'entity_type' => 'test_entity', 'bundle' => 'test_bundle');
- $instance = field_create_instance($instance);
+ $field = entity_create('field_entity', array('field_name' => $field_name, 'type' => 'text'));
+ $field->save();
+ $instance = entity_create('field_instance', array(
+ 'field_name' => $field_name,
+ 'entity_type' => 'test_entity',
+ 'bundle' => 'test_bundle',
+ ));
+ $instance->save();
$tables = array(_field_sql_storage_tablename($field), _field_sql_storage_revision_tablename($field));
// Verify the indexes we will create do not exist yet.
@@ -372,16 +392,16 @@ function testFieldUpdateIndexesWithData() {
$entity->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['value'] = 'field data';
$entity->save();
- // Add an index
- $field = array('field_name' => $field_name, 'indexes' => array('value' => array(array('value', 255))));
- field_update_field($field);
+ // Add an index.
+ $field['indexes'] = array('value' => array(array('value', 255)));
+ $field->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 = array('field_name' => $field_name, 'indexes' => array('value_format' => array(array('value', 127), array('format', 127))));
- field_update_field($field);
+ $field['indexes'] = array('value_format' => array(array('value', 127), array('format', 127)));
+ $field->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"));
@@ -429,18 +449,21 @@ function testFieldSqlStorageForeignKeys() {
// field_test_field_schema()).
$field_name = 'testfield';
$foreign_key_name = 'shape';
- $field = array('field_name' => $field_name, 'type' => 'shape', 'settings' => array('foreign_key_name' => $foreign_key_name));
- field_create_field($field);
+ $field = entity_create('field_entity', array(
+ 'field_name' => $field_name,
+ 'type' => 'shape',
+ 'settings' => array('foreign_key_name' => $foreign_key_name),
+ ));
+ $field->save();
// Retrieve the field definition and check that the foreign key is in place.
- $field = field_info_field($field_name);
$this->assertEqual($field['foreign keys'][$foreign_key_name]['table'], $foreign_key_name, 'Foreign key table name preserved through CRUD');
$this->assertEqual($field['foreign keys'][$foreign_key_name]['columns'][$foreign_key_name], 'id', 'Foreign key column name preserved through CRUD');
// 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_update_field($field);
+ $field->save();
// Retrieve the field definition and check that the foreign key is in place.
$field = field_info_field($field_name);
diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageDisplayTest.php b/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageDisplayTest.php
index 51dc8b1..7c89cce 100644
--- a/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageDisplayTest.php
+++ b/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageDisplayTest.php
@@ -207,7 +207,7 @@ function testNoFieldsDisplayOverview() {
$this->drupalCreateContentType(array('type' => 'no_fields', 'name' => 'No fields'));
// Remove the 'body' field.
- field_delete_instance(field_info_instance('node', 'body', 'no_fields'));
+ field_info_instance('node', 'body', 'no_fields')->delete();
$this->drupalGet('admin/structure/types/manage/no_fields/display');
$this->assertRaw(t('There are no fields yet added. You can add new fields on the Manage fields page.', array('@link' => url('admin/structure/types/manage/no_fields/fields'))));
diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php b/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php
index 582e478..d12ef79 100644
--- a/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php
+++ b/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php
@@ -43,7 +43,7 @@ function setUp() {
'field_name' => 'field_' . $vocabulary->id(),
'type' => 'taxonomy_term_reference',
);
- field_create_field($field);
+ entity_create('field_entity', $field)->save();
$instance = array(
'field_name' => 'field_' . $vocabulary->id(),
@@ -51,7 +51,7 @@ function setUp() {
'label' => 'Tags',
'bundle' => 'article',
);
- field_create_instance($instance);
+ entity_create('field_instance', $instance)->save();
entity_get_form_display('node', 'article', 'default')
->setComponent('field_' . $vocabulary->id())
@@ -248,17 +248,16 @@ function assertFieldSettings($bundle, $field_name, $string = 'dummy test string'
function testDefaultValue() {
// Create a test field and instance.
$field_name = 'test';
- $field = array(
+ entity_create('field_entity', array(
'field_name' => $field_name,
'type' => 'test_field'
- );
- field_create_field($field);
- $instance = array(
+ ))->save();
+ $instance = entity_create('field_instance', array(
'field_name' => $field_name,
'entity_type' => 'node',
'bundle' => $this->type,
- );
- $instance = field_create_instance($instance);
+ ));
+ $instance->save();
entity_get_form_display('node', $this->type, 'default')
->setComponent($field_name)
@@ -399,14 +398,14 @@ function testHiddenFields() {
// Create a field and an instance programmatically.
$field_name = 'hidden_test_field';
- field_create_field(array('field_name' => $field_name, 'type' => $field_name));
+ entity_create('field_entity', array('field_name' => $field_name, 'type' => $field_name))->save();
$instance = array(
'field_name' => $field_name,
'bundle' => $this->type,
'entity_type' => 'node',
'label' => t('Hidden field'),
);
- field_create_instance($instance);
+ entity_create('field_instance', $instance)->save();
entity_get_form_display('node', $this->type, 'default')
->setComponent($field_name)
->save();
diff --git a/core/modules/file/file.install b/core/modules/file/file.install
index 3ca855e..8927e26 100644
--- a/core/modules/file/file.install
+++ b/core/modules/file/file.install
@@ -273,7 +273,7 @@ function file_update_8002() {
else {
$field['settings']['default_image'] = array();
}
- field_update_field($field);
+ $field->save();
$instances = field_read_instances(array('field_name' => $field['field_name']));
foreach ($instances as $instance) {
@@ -283,7 +283,7 @@ function file_update_8002() {
else {
$instance['settings']['default_image'] = array();
}
- field_update_instance($instance);
+ $instance->save();
}
}
}
diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldTestBase.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldTestBase.php
index ac2f428..33d2901 100644
--- a/core/modules/file/lib/Drupal/file/Tests/FileFieldTestBase.php
+++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldTestBase.php
@@ -65,14 +65,15 @@ function getLastFileId() {
* A list of widget settings that will be added to the widget defaults.
*/
function createFileField($name, $type_name, $field_settings = array(), $instance_settings = array(), $widget_settings = array()) {
- $field = array(
+ $field_definition = array(
'field_name' => $name,
'type' => 'file',
'settings' => array(),
'cardinality' => !empty($field_settings['cardinality']) ? $field_settings['cardinality'] : 1,
);
- $field['settings'] = array_merge($field['settings'], $field_settings);
- $field = field_create_field($field);
+ $field_definition['settings'] = array_merge($field_definition['settings'], $field_settings);
+ $field = entity_create('field_entity', $field_definition);
+ $field->save();
$this->attachFileField($name, 'node', $type_name, $instance_settings, $widget_settings);
return $field;
@@ -104,7 +105,7 @@ function attachFileField($name, $entity_type, $bundle, $instance_settings = arra
'settings' => array(),
);
$instance['settings'] = array_merge($instance['settings'], $instance_settings);
- field_create_instance($instance);
+ entity_create('field_instance', $instance)->save();
entity_get_form_display($entity_type, $bundle, 'default')
->setComponent($name, array(
@@ -121,7 +122,7 @@ function updateFileField($name, $type_name, $instance_settings = array(), $widge
$instance = field_info_instance('node', $name, $type_name);
$instance['settings'] = array_merge($instance['settings'], $instance_settings);
- field_update_instance($instance);
+ $instance->save();
entity_get_form_display($instance['entity_type'], $instance['bundle'], 'default')
->setComponent($instance['field_name'], array(
diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldValidateTest.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldValidateTest.php
index faceb99..37633e1 100644
--- a/core/modules/file/lib/Drupal/file/Tests/FileFieldValidateTest.php
+++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldValidateTest.php
@@ -50,7 +50,7 @@ function testRequired() {
$this->assertFileEntryExists($node_file, t('File entry exists after uploading to the required field.'));
// Try again with a multiple value field.
- field_delete_field($field_name);
+ $field->delete();
$this->createFileField($field_name, $type_name, array('cardinality' => FIELD_CARDINALITY_UNLIMITED), array('required' => '1'));
// Try to post a new node without uploading a file in the multivalue field.
@@ -151,4 +151,5 @@ function testFileExtension() {
$this->assertFileExists($node_file, t('File exists after uploading a file with extension checking.'));
$this->assertFileEntryExists($node_file, t('File entry exists after uploading a file with extension checking.'));
}
+
}
diff --git a/core/modules/file/lib/Drupal/file/Tests/FileItemTest.php b/core/modules/file/lib/Drupal/file/Tests/FileItemTest.php
index 2ec9dfa..674553c 100644
--- a/core/modules/file/lib/Drupal/file/Tests/FileItemTest.php
+++ b/core/modules/file/lib/Drupal/file/Tests/FileItemTest.php
@@ -49,13 +49,13 @@ public function setUp() {
'type' => 'file',
'cardinality' => FIELD_CARDINALITY_UNLIMITED,
);
- field_create_field($field);
+ entity_create('field_entity', $field)->save();
$instance = array(
'entity_type' => 'entity_test',
'field_name' => 'file_test',
'bundle' => 'entity_test',
);
- field_create_instance($instance);
+ entity_create('field_instance', $instance)->save();
file_put_contents('public://example.txt', $this->randomName());
$this->file = entity_create('file', array(
'uri' => 'public://example.txt',
diff --git a/core/modules/forum/forum.install b/core/modules/forum/forum.install
index a6641a2..37c4248 100644
--- a/core/modules/forum/forum.install
+++ b/core/modules/forum/forum.install
@@ -65,7 +65,7 @@ function forum_enable() {
),
),
);
- field_create_field($field);
+ entity_create('field_entity', $field)->save();
// Create a default forum so forum posts can be created.
$term = entity_create('taxonomy_term', array(
@@ -85,7 +85,7 @@ function forum_enable() {
'bundle' => 'forum',
'required' => TRUE,
);
- field_create_instance($instance);
+ entity_create('field_instance', $instance)->save();
// Assign form display settings for the 'default' form mode.
entity_get_form_display('node', 'forum', 'default')
@@ -124,7 +124,7 @@ function forum_uninstall() {
variable_del('node_options_forum');
- field_delete_field('taxonomy_forums');
+ field_info_field('taxonomy_forums')->delete();
// Purge field data now to allow taxonomy module to be uninstalled
// if this is the only field remaining.
field_purge_batch(10);
diff --git a/core/modules/hal/lib/Drupal/hal/Tests/NormalizerTestBase.php b/core/modules/hal/lib/Drupal/hal/Tests/NormalizerTestBase.php
index 2d73a24..990e33e 100644
--- a/core/modules/hal/lib/Drupal/hal/Tests/NormalizerTestBase.php
+++ b/core/modules/hal/lib/Drupal/hal/Tests/NormalizerTestBase.php
@@ -83,13 +83,13 @@ function setUp() {
'type' => 'text',
'translatable' => FALSE,
);
- field_create_field($field);
+ entity_create('field_entity', $field)->save();
$instance = array(
'entity_type' => 'entity_test',
'field_name' => 'field_test_text',
'bundle' => 'entity_test',
);
- field_create_instance($instance);
+ entity_create('field_instance', $instance)->save();
// Create the test translatable field.
$field = array(
@@ -97,13 +97,13 @@ function setUp() {
'type' => 'text',
'translatable' => TRUE,
);
- field_create_field($field);
+ entity_create('field_entity', $field)->save();
$instance = array(
'entity_type' => 'entity_test',
'field_name' => 'field_test_translatable_text',
'bundle' => 'entity_test',
);
- field_create_instance($instance);
+ entity_create('field_instance', $instance)->save();
// Create the test entity reference field.
$field = array(
@@ -114,13 +114,13 @@ function setUp() {
'field_name' => 'field_test_entity_reference',
'type' => 'entity_reference',
);
- field_create_field($field);
+ entity_create('field_entity', $field)->save();
$instance = array(
'entity_type' => 'entity_test',
'field_name' => 'field_test_entity_reference',
'bundle' => 'entity_test',
);
- field_create_instance($instance);
+ entity_create('field_instance', $instance)->save();
// Set up the mock serializer.
$normalizers = array(
diff --git a/core/modules/image/lib/Drupal/image/Tests/ImageFieldDefaultImagesTest.php b/core/modules/image/lib/Drupal/image/Tests/ImageFieldDefaultImagesTest.php
index 40e380d..c679cef 100644
--- a/core/modules/image/lib/Drupal/image/Tests/ImageFieldDefaultImagesTest.php
+++ b/core/modules/image/lib/Drupal/image/Tests/ImageFieldDefaultImagesTest.php
@@ -51,12 +51,11 @@ function testDefaultImages() {
$widget_settings = array(
'preview_image_style' => 'medium',
);
- $this->createImageField($field_name, 'article', $field_settings, $instance_settings, $widget_settings);
+ $instance = $this->createImageField($field_name, 'article', $field_settings, $instance_settings, $widget_settings);
$field = field_info_field($field_name);
- $instance = field_info_instance('node', $field_name, 'article');
// Add another instance with another default image to the page content type.
- $instance2 = array(
+ $instance2 = entity_create('field_instance', array(
'field_name' => $field['field_name'],
'entity_type' => 'node',
'bundle' => 'page',
@@ -65,9 +64,8 @@ function testDefaultImages() {
'settings' => array(
'default_image' => array($default_images['instance2']->fid),
),
- );
- field_create_instance($instance2);
- $instance2 = field_info_instance('node', $field_name, 'page');
+ ));
+ $instance2->save();
$widget_settings = entity_get_form_display($instance['entity_type'], $instance['bundle'], 'default')->getComponent($field['field_name']);
entity_get_form_display('node', 'page', 'default')
@@ -145,7 +143,7 @@ function testDefaultImages() {
// Upload a new default for the field.
$field['settings']['default_image'] = array($default_images['field_new']->fid);
- field_update_field($field);
+ $field->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");
@@ -180,7 +178,7 @@ function testDefaultImages() {
// Upload a new default for the article's field instance.
$instance['settings']['default_image'] = array($default_images['instance_new']->fid);
- field_update_instance($instance);
+ $instance->save();
// Confirm the new field instance default is used on the article field
// admin form.
@@ -219,7 +217,7 @@ function testDefaultImages() {
// Remove the instance default from articles.
$instance['settings']['default_image'] = NULL;
- field_update_instance($instance);
+ $instance->save();
// Confirm the article field instance default has been removed.
$this->drupalGet("admin/structure/types/manage/article/fields/$instance->id");
@@ -251,4 +249,5 @@ function testDefaultImages() {
)
);
}
+
}
diff --git a/core/modules/image/lib/Drupal/image/Tests/ImageFieldTestBase.php b/core/modules/image/lib/Drupal/image/Tests/ImageFieldTestBase.php
index 508c9bc..29a5b2b 100644
--- a/core/modules/image/lib/Drupal/image/Tests/ImageFieldTestBase.php
+++ b/core/modules/image/lib/Drupal/image/Tests/ImageFieldTestBase.php
@@ -75,7 +75,7 @@ function createImageField($name, $type_name, $field_settings = array(), $instanc
'cardinality' => !empty($field_settings['cardinality']) ? $field_settings['cardinality'] : 1,
);
$field['settings'] = array_merge($field['settings'], $field_settings);
- field_create_field($field);
+ entity_create('field_entity', $field)->save();
$instance = array(
'field_name' => $field['field_name'],
@@ -87,7 +87,8 @@ function createImageField($name, $type_name, $field_settings = array(), $instanc
'settings' => array(),
);
$instance['settings'] = array_merge($instance['settings'], $instance_settings);
- $field_instance = field_create_instance($instance);
+ $field_instance = entity_create('field_instance', $instance);
+ $field_instance->save();
entity_get_form_display('node', $type_name, 'default')
->setComponent($field['field_name'], array(
diff --git a/core/modules/image/lib/Drupal/image/Tests/ImageItemTest.php b/core/modules/image/lib/Drupal/image/Tests/ImageItemTest.php
index 709073d..4ea7dd9 100644
--- a/core/modules/image/lib/Drupal/image/Tests/ImageItemTest.php
+++ b/core/modules/image/lib/Drupal/image/Tests/ImageItemTest.php
@@ -48,13 +48,13 @@ public function setUp() {
'type' => 'image',
'cardinality' => FIELD_CARDINALITY_UNLIMITED,
);
- field_create_field($field);
+ entity_create('field_entity', $field)->save();
$instance = array(
'entity_type' => 'entity_test',
'field_name' => 'image_test',
'bundle' => 'entity_test',
);
- field_create_instance($instance);
+ entity_create('field_instance', $instance)->save();
file_unmanaged_copy(DRUPAL_ROOT . '/core/misc/druplicon.png', 'public://example.jpg');
$this->image = entity_create('file', array(
'uri' => 'public://example.jpg',
diff --git a/core/modules/link/lib/Drupal/link/Tests/LinkFieldTest.php b/core/modules/link/lib/Drupal/link/Tests/LinkFieldTest.php
index 0a6dc0b..1070c08 100644
--- a/core/modules/link/lib/Drupal/link/Tests/LinkFieldTest.php
+++ b/core/modules/link/lib/Drupal/link/Tests/LinkFieldTest.php
@@ -48,7 +48,7 @@ function testURLValidation() {
'field_name' => drupal_strtolower($this->randomName()),
'type' => 'link',
);
- field_create_field($this->field);
+ entity_create('field_entity', $this->field)->save();
$this->instance = array(
'field_name' => $this->field['field_name'],
'entity_type' => 'test_entity',
@@ -57,7 +57,7 @@ function testURLValidation() {
'title' => DRUPAL_DISABLED,
),
);
- field_create_instance($this->instance);
+ entity_create('field_instance', $this->instance)->save();
entity_get_form_display('test_entity', 'test_bundle', 'default')
->setComponent($this->field['field_name'], array(
'type' => 'link_default',
@@ -118,8 +118,8 @@ function testLinkTitle() {
'field_name' => drupal_strtolower($this->randomName()),
'type' => 'link',
);
- field_create_field($this->field);
- $this->instance = array(
+ entity_create('field_entity', $this->field)->save();
+ $this->instance = entity_create('field_instance', array(
'field_name' => $this->field['field_name'],
'entity_type' => 'test_entity',
'bundle' => 'test_bundle',
@@ -127,8 +127,8 @@ function testLinkTitle() {
'settings' => array(
'title' => DRUPAL_OPTIONAL,
),
- );
- field_create_instance($this->instance);
+ ));
+ $this->instance->save();
entity_get_form_display('test_entity', 'test_bundle', 'default')
->setComponent($this->field['field_name'], array(
'type' => 'link_default',
@@ -151,7 +151,7 @@ function testLinkTitle() {
foreach (array(DRUPAL_DISABLED, DRUPAL_REQUIRED, DRUPAL_OPTIONAL) as $title_setting) {
// Update the title field setting.
$this->instance['settings']['title'] = $title_setting;
- field_update_instance($this->instance);
+ $this->instance->save();
// Display creation form.
$this->drupalGet('test-entity/add/test_bundle');
@@ -233,7 +233,7 @@ function testLinkFormatter() {
'type' => 'link',
'cardinality' => 2,
);
- field_create_field($this->field);
+ entity_create('field_entity', $this->field)->save();
$this->instance = array(
'field_name' => $this->field['field_name'],
'entity_type' => 'test_entity',
@@ -247,7 +247,7 @@ function testLinkFormatter() {
'type' => 'link',
'label' => 'hidden',
);
- field_create_instance($this->instance);
+ entity_create('field_instance', $this->instance)->save();
entity_get_form_display('test_entity', 'test_bundle', 'default')
->setComponent($this->field['field_name'], array(
'type' => 'link_default',
@@ -374,7 +374,7 @@ function testLinkSeparateFormatter() {
'type' => 'link',
'cardinality' => 2,
);
- field_create_field($this->field);
+ entity_create('field_entity', $this->field)->save();
$this->instance = array(
'field_name' => $this->field['field_name'],
'entity_type' => 'test_entity',
@@ -387,7 +387,7 @@ function testLinkSeparateFormatter() {
'type' => 'link_separate',
'label' => 'hidden',
);
- field_create_instance($this->instance);
+ entity_create('field_instance', $this->instance)->save();
entity_get_form_display('test_entity', 'test_bundle', 'default')
->setComponent($this->field['field_name'], array(
'type' => 'link_default',
diff --git a/core/modules/link/lib/Drupal/link/Tests/LinkItemTest.php b/core/modules/link/lib/Drupal/link/Tests/LinkItemTest.php
index eb40cbc..ea94a6b 100644
--- a/core/modules/link/lib/Drupal/link/Tests/LinkItemTest.php
+++ b/core/modules/link/lib/Drupal/link/Tests/LinkItemTest.php
@@ -35,17 +35,17 @@ public function setUp() {
parent::setUp();
// Create an link field and instance for validation.
- $this->field = array(
+ $this->field = entity_create('field_entity', array(
'field_name' => 'field_test',
'type' => 'link',
- );
- field_create_field($this->field);
- $this->instance = array(
+ ));
+ $this->field->save();
+ $this->instance = entity_create('field_instance', array(
'entity_type' => 'entity_test',
'field_name' => 'field_test',
'bundle' => 'entity_test',
- );
- field_create_instance($this->instance);
+ ));
+ $this->instance->save();
}
/**
diff --git a/core/modules/node/lib/Drupal/node/Tests/MultiStepNodeFormBasicOptionsTest.php b/core/modules/node/lib/Drupal/node/Tests/MultiStepNodeFormBasicOptionsTest.php
index 465a492..4429df8 100644
--- a/core/modules/node/lib/Drupal/node/Tests/MultiStepNodeFormBasicOptionsTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/MultiStepNodeFormBasicOptionsTest.php
@@ -43,7 +43,7 @@ function testMultiStepNodeFormBasicOptions() {
'type' => 'text',
'cardinality' => -1,
);
- field_create_field($this->field);
+ entity_create('field_entity', $this->field)->save();
// Attach an instance of the field to the page content type.
$this->instance = array(
@@ -55,7 +55,7 @@ function testMultiStepNodeFormBasicOptions() {
'text_processing' => TRUE,
),
);
- field_create_instance($this->instance);
+ entity_create('field_instance', $this->instance)->save();
entity_get_form_display('node', 'page', 'default')
->setComponent($this->field_name, array(
'type' => 'text_textfield',
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessFieldTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessFieldTest.php
index 9c9c52e..c6793ac 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessFieldTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessFieldTest.php
@@ -38,13 +38,15 @@ public function setUp() {
// Add a custom field to the page content type.
$this->field_name = drupal_strtolower($this->randomName() . '_field_name');
- $this->field = field_create_field(array('field_name' => $this->field_name, 'type' => 'text'));
+ $this->field = entity_create('field_entity', array('field_name' => $this->field_name, 'type' => 'text'));
+ $this->field->save();
$instance = array(
'field_name' => $this->field_name,
'entity_type' => 'node',
'bundle' => 'page',
);
- $this->instance = field_create_instance($instance);
+ $this->instance = entity_create('field_instance', $instance);
+ $this->instance->save();
entity_get_display('node', 'page', 'default')
->setComponent($this->field_name)
->save();
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php b/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php
index 930bdf3..3d1b617 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php
@@ -61,7 +61,7 @@ function setUp() {
// Make node body translatable.
$field = field_info_field('body');
$field['translatable'] = TRUE;
- field_update_field($field);
+ $field->save();
}
/**
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php b/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php
index 3632867..cceee63 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php
@@ -169,7 +169,7 @@ function testFieldTranslationForm() {
$this->assertRaw('Not translated');
// Delete the only translatable field.
- field_delete_field('field_test_et_ui_test');
+ field_info_field('field_test_et_ui_test')->delete();
// Visit translation page.
$this->drupalGet('node/' . $article->nid . '/translations');
diff --git a/core/modules/node/lib/Drupal/node/Tests/PagePreviewTest.php b/core/modules/node/lib/Drupal/node/Tests/PagePreviewTest.php
index 81456a3..31424d0 100644
--- a/core/modules/node/lib/Drupal/node/Tests/PagePreviewTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/PagePreviewTest.php
@@ -72,13 +72,13 @@ function setUp() {
'cardinality' => '-1',
);
- field_create_field($this->field);
+ entity_create('field_entity', $this->field)->save();
$this->instance = array(
'field_name' => $this->field_name,
'entity_type' => 'node',
'bundle' => 'page',
);
- field_create_instance($this->instance);
+ entity_create('field_instance', $this->instance)->save();
entity_get_form_display('node', 'page', 'default')
->setComponent($this->field['field_name'], array(
diff --git a/core/modules/node/node.module b/core/modules/node/node.module
index 5c934df..3f3a95a 100644
--- a/core/modules/node/node.module
+++ b/core/modules/node/node.module
@@ -537,7 +537,8 @@ function node_add_body_field($type, $label = 'Body') {
'type' => 'text_with_summary',
'entity_types' => array('node'),
);
- $field = field_create_field($field);
+ $field = entity_create('field_entity', $field);
+ $field->save();
}
if (empty($instance)) {
$instance = array(
@@ -547,7 +548,8 @@ function node_add_body_field($type, $label = 'Body') {
'label' => $label,
'settings' => array('display_summary' => TRUE),
);
- $instance = field_create_instance($instance);
+ $instance = entity_create('field_instance', $instance);
+ $instance->save();
// Assign widget settings for the 'default' form mode.
entity_get_form_display('node', $type->type, 'default')
diff --git a/core/modules/node/tests/modules/node_access_test_language/node_access_test_language.module b/core/modules/node/tests/modules/node_access_test_language/node_access_test_language.module
index 3d67454..b3db641 100644
--- a/core/modules/node/tests/modules/node_access_test_language/node_access_test_language.module
+++ b/core/modules/node/tests/modules/node_access_test_language/node_access_test_language.module
@@ -58,7 +58,8 @@ function node_access_test_language_enable() {
'allowed_values' => array(0 => 'Not private', 1 => 'Private'),
),
);
- $field_private = field_create_field($field_private);
+ $field_private = entity_create('field_entity', $field_private);
+ $field_private->save();
$instance = array(
'field_name' => $field_private['field_name'],
@@ -68,12 +69,13 @@ function node_access_test_language_enable() {
'type' => 'options_buttons',
),
);
- $instance = field_create_instance($instance);
+ $instance = entity_create('field_instance', $instance);
+ $instance->save();
}
/**
* Implements hook_disable().
*/
function node_access_test_language_disable() {
- field_delete_instance(field_read_instance('node', 'field_private', 'page'));
+ field_read_instance('node', 'field_private', 'page')->delete();
}
diff --git a/core/modules/number/lib/Drupal/number/Tests/NumberFieldTest.php b/core/modules/number/lib/Drupal/number/Tests/NumberFieldTest.php
index d0b98ac..68f6436 100644
--- a/core/modules/number/lib/Drupal/number/Tests/NumberFieldTest.php
+++ b/core/modules/number/lib/Drupal/number/Tests/NumberFieldTest.php
@@ -52,13 +52,13 @@ function testNumberDecimalField() {
'precision' => 8, 'scale' => 4, 'decimal_separator' => '.',
)
);
- field_create_field($this->field);
+ entity_create('field_entity', $this->field)->save();
$this->instance = array(
'field_name' => $this->field['field_name'],
'entity_type' => 'test_entity',
'bundle' => 'test_bundle',
);
- field_create_instance($this->instance);
+ entity_create('field_instance', $this->instance)->save();
entity_get_form_display('test_entity', 'test_bundle', 'default')
->setComponent($this->field['field_name'], array(
diff --git a/core/modules/number/lib/Drupal/number/Tests/NumberItemTest.php b/core/modules/number/lib/Drupal/number/Tests/NumberItemTest.php
index fa7e0fa..b708530 100644
--- a/core/modules/number/lib/Drupal/number/Tests/NumberItemTest.php
+++ b/core/modules/number/lib/Drupal/number/Tests/NumberItemTest.php
@@ -40,13 +40,13 @@ public function setUp() {
'field_name' => 'field_' . $type,
'type' => 'number_' . $type,
);
- field_create_field($this->field[$type]);
+ entity_create('field_entity', $this->field[$type])->save();
$this->instance[$type] = array(
'entity_type' => 'entity_test',
'field_name' => 'field_' . $type,
'bundle' => 'entity_test',
);
- field_create_instance($this->instance[$type]);
+ entity_create('field_instance', $this->instance[$type])->save();
}
}
diff --git a/core/modules/options/lib/Drupal/options/Tests/OptionsDynamicValuesTest.php b/core/modules/options/lib/Drupal/options/Tests/OptionsDynamicValuesTest.php
index 4e97dbe..042f01d 100644
--- a/core/modules/options/lib/Drupal/options/Tests/OptionsDynamicValuesTest.php
+++ b/core/modules/options/lib/Drupal/options/Tests/OptionsDynamicValuesTest.php
@@ -33,7 +33,8 @@ function setUp() {
'allowed_values_function' => 'options_test_dynamic_values_callback',
),
);
- $this->field = field_create_field($this->field);
+ $this->field = entity_create('field_entity', $this->field);
+ $this->field->save();
$this->instance = array(
'field_name' => $this->field_name,
@@ -41,7 +42,8 @@ function setUp() {
'bundle' => 'test_bundle',
'required' => TRUE,
);
- $this->instance = field_create_instance($this->instance);
+ $this->instance = entity_create('field_instance', $this->instance);
+ $this->instance->save();
entity_get_form_display('test_entity', 'test_bundle', 'default')
->setComponent($this->field_name, array(
'type' => 'options_select',
diff --git a/core/modules/options/lib/Drupal/options/Tests/OptionsFieldTest.php b/core/modules/options/lib/Drupal/options/Tests/OptionsFieldTest.php
index efd8d5c..0472d99 100644
--- a/core/modules/options/lib/Drupal/options/Tests/OptionsFieldTest.php
+++ b/core/modules/options/lib/Drupal/options/Tests/OptionsFieldTest.php
@@ -49,7 +49,7 @@ function testUpdateAllowedValues() {
$entity->save();
$this->field['settings']['allowed_values'] = array(2 => 'Two');
try {
- field_update_field($this->field);
+ $this->field->save();
$this->fail(t('Cannot update a list field to not include keys with existing data.'));
}
catch (FieldException $e) {
@@ -61,7 +61,7 @@ function testUpdateAllowedValues() {
// Removed options do not appear.
$this->field['settings']['allowed_values'] = array(2 => 'Two');
- field_update_field($this->field);
+ $this->field->save();
$entity = entity_create('entity_test', array());
$form = entity_get_form($entity);
$this->assertTrue(empty($form[$this->fieldName][$langcode][1]), 'Option 1 does not exist');
@@ -70,7 +70,7 @@ function testUpdateAllowedValues() {
// Completely new options appear.
$this->field['settings']['allowed_values'] = array(10 => 'Update', 20 => 'Twenty');
- field_update_field($this->field);
+ $this->field->save();
$form = entity_get_form($entity);
$this->assertTrue(empty($form[$this->fieldName][$langcode][1]), 'Option 1 does not exist');
$this->assertTrue(empty($form[$this->fieldName][$langcode][2]), 'Option 2 does not exist');
@@ -79,15 +79,14 @@ function testUpdateAllowedValues() {
$this->assertTrue(!empty($form[$this->fieldName][$langcode][20]), 'Option 20 exists');
// Options are reset when a new field with the same name is created.
- field_delete_field($this->fieldName);
- unset($this->field['id']);
- field_create_field($this->fieldDefinition);
+ $this->field->delete();
+ entity_create('field_entity', $this->fieldDefinition)->save();
$this->instance = array(
'field_name' => $this->fieldName,
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
);
- field_create_instance($this->instance);
+ entity_create('field_instance', $this->instance)->save();
entity_get_form_display('entity_test', 'entity_test', 'default')
->setComponent($this->fieldName, array(
'type' => 'options_buttons',
diff --git a/core/modules/options/lib/Drupal/options/Tests/OptionsFieldUITest.php b/core/modules/options/lib/Drupal/options/Tests/OptionsFieldUITest.php
index 3d54c81..6e92105 100644
--- a/core/modules/options/lib/Drupal/options/Tests/OptionsFieldUITest.php
+++ b/core/modules/options/lib/Drupal/options/Tests/OptionsFieldUITest.php
@@ -262,13 +262,13 @@ protected function createOptionsField($type) {
'field_name' => $this->field_name,
'type' => $type,
);
- field_create_field($field);
+ entity_create('field_entity', $field)->save();
$instance = array(
'field_name' => $this->field_name,
'entity_type' => 'node',
'bundle' => $this->type,
);
- field_create_instance($instance);
+ entity_create('field_instance', $instance)->save();
entity_get_form_display('node', $this->type, 'default')->setComponent($this->field_name)->save();
diff --git a/core/modules/options/lib/Drupal/options/Tests/OptionsWidgetsTest.php b/core/modules/options/lib/Drupal/options/Tests/OptionsWidgetsTest.php
index cbb3c7f..bdff668 100644
--- a/core/modules/options/lib/Drupal/options/Tests/OptionsWidgetsTest.php
+++ b/core/modules/options/lib/Drupal/options/Tests/OptionsWidgetsTest.php
@@ -33,7 +33,7 @@ function setUp() {
parent::setUp();
// Field with cardinality 1.
- $this->card_1 = array(
+ $this->card_1 = entity_create('field_entity', array(
'field_name' => 'card_1',
'type' => 'list_integer',
'cardinality' => 1,
@@ -41,11 +41,11 @@ function setUp() {
// Make sure that 0 works as an option.
'allowed_values' => array(0 => 'Zero', 1 => 'One', 2 => 'Some & unescaped markup'),
),
- );
- $this->card_1 = field_create_field($this->card_1);
+ ));
+ $this->card_1->save();
// Field with cardinality 2.
- $this->card_2 = array(
+ $this->card_2 = entity_create('field_entity', array(
'field_name' => 'card_2',
'type' => 'list_integer',
'cardinality' => 2,
@@ -53,19 +53,19 @@ function setUp() {
// Make sure that 0 works as an option.
'allowed_values' => array(0 => 'Zero', 1 => 'One', 2 => 'Some & unescaped markup'),
),
- );
- $this->card_2 = field_create_field($this->card_2);
+ ));
+ $this->card_2->save();
// Boolean field.
- $this->bool = array(
+ $this->bool = entity_create('field_entity', array(
'field_name' => 'bool',
'type' => 'list_boolean',
'cardinality' => 1,
'settings' => array(
'allowed_values' => array(0 => 'Zero', 1 => 'Some & unescaped markup'),
),
- );
- $this->bool = field_create_field($this->bool);
+ ));
+ $this->bool->save();
// Create a web user.
$this->web_user = $this->drupalCreateUser(array('access field_test content', 'administer field_test content'));
@@ -77,12 +77,12 @@ function setUp() {
*/
function testRadioButtons() {
// Create an instance of the 'single value' field.
- $instance = array(
+ $instance = entity_create('field_instance', array(
'field_name' => $this->card_1['field_name'],
'entity_type' => 'test_entity',
'bundle' => 'test_bundle',
- );
- $instance = field_create_instance($instance);
+ ));
+ $instance->save();
entity_get_form_display('test_entity', 'test_bundle', 'default')
->setComponent($this->card_1['field_name'], array(
'type' => 'options_buttons',
@@ -122,9 +122,9 @@ function testRadioButtons() {
// Check that required radios with one option is auto-selected.
$this->card_1['settings']['allowed_values'] = array(99 => 'Only allowed value');
- field_update_field($this->card_1);
+ $this->card_1->save();
$instance['required'] = TRUE;
- field_update_instance($instance);
+ $instance->save();
$this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit');
$this->assertFieldChecked("edit-card-1-$langcode-99");
}
@@ -134,12 +134,12 @@ function testRadioButtons() {
*/
function testCheckBoxes() {
// Create an instance of the 'multiple values' field.
- $instance = array(
+ $instance = entity_create('field_instance', array(
'field_name' => $this->card_2['field_name'],
'entity_type' => 'test_entity',
'bundle' => 'test_bundle',
- );
- $instance = field_create_instance($instance);
+ ));
+ $instance->save();
entity_get_form_display('test_entity', 'test_bundle', 'default')
->setComponent($this->card_2['field_name'], array(
'type' => 'options_buttons',
@@ -212,9 +212,9 @@ function testCheckBoxes() {
// Required checkbox with one option is auto-selected.
$this->card_2['settings']['allowed_values'] = array(99 => 'Only allowed value');
- field_update_field($this->card_2);
+ $this->card_2->save();
$instance['required'] = TRUE;
- field_update_instance($instance);
+ $instance->save();
$this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit');
$this->assertFieldChecked("edit-card-2-$langcode-99");
}
@@ -224,13 +224,13 @@ function testCheckBoxes() {
*/
function testSelectListSingle() {
// Create an instance of the 'single value' field.
- $instance = array(
+ $instance = entity_create('field_instance', array(
'field_name' => $this->card_1['field_name'],
'entity_type' => 'test_entity',
'bundle' => 'test_bundle',
'required' => TRUE,
- );
- $instance = field_create_instance($instance);
+ ));
+ $instance->save();
entity_get_form_display('test_entity', 'test_bundle', 'default')
->setComponent($this->card_1['field_name'], array(
'type' => 'options_select',
@@ -277,7 +277,7 @@ function testSelectListSingle() {
// Make the field non required.
$instance['required'] = FALSE;
- field_update_instance($instance);
+ $instance->save();
// Display form.
$this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit');
@@ -292,7 +292,7 @@ function testSelectListSingle() {
$this->card_1['settings']['allowed_values'] = array();
$this->card_1['settings']['allowed_values_function'] = 'options_test_allowed_values_callback';
- field_update_field($this->card_1);
+ $this->card_1->save();
// Display form: with no field data, nothing is selected
$this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit');
@@ -324,12 +324,12 @@ function testSelectListSingle() {
*/
function testSelectListMultiple() {
// Create an instance of the 'multiple values' field.
- $instance = array(
+ $instance = entity_create('field_instance', array(
'field_name' => $this->card_2['field_name'],
'entity_type' => 'test_entity',
'bundle' => 'test_bundle',
- );
- $instance = field_create_instance($instance);
+ ));
+ $instance->save();
entity_get_form_display('test_entity', 'test_bundle', 'default')
->setComponent($this->card_2['field_name'], array(
'type' => 'options_select',
@@ -398,7 +398,7 @@ function testSelectListMultiple() {
// A required select list does not have an empty key.
$instance['required'] = TRUE;
- field_update_instance($instance);
+ $instance->save();
$this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit');
$this->assertFalse($this->xpath('//select[@id=:id]//option[@value=""]', array(':id' => 'edit-card-2-' . $langcode)), 'A required select list does not have an empty key.');
@@ -410,9 +410,9 @@ function testSelectListMultiple() {
// Use a callback function defining optgroups.
$this->card_2['settings']['allowed_values'] = array();
$this->card_2['settings']['allowed_values_function'] = 'options_test_allowed_values_callback';
- field_update_field($this->card_2);
+ $this->card_2->save();
$instance['required'] = FALSE;
- field_update_instance($instance);
+ $instance->save();
// Display form: with no field data, nothing is selected.
$this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit');
@@ -444,12 +444,11 @@ function testSelectListMultiple() {
*/
function testOnOffCheckbox() {
// Create an instance of the 'boolean' field.
- $instance = array(
+ entity_create('field_instance', array(
'field_name' => $this->bool['field_name'],
'entity_type' => 'test_entity',
'bundle' => 'test_bundle',
- );
- $instance = field_create_instance($instance);
+ ))->save();
entity_get_form_display('test_entity', 'test_bundle', 'default')
->setComponent($this->bool['field_name'], array(
'type' => 'options_onoff',
@@ -497,13 +496,12 @@ function testOnOffCheckbox() {
// Create a test field instance.
$fieldUpdate = $this->bool;
$fieldUpdate['settings']['allowed_values'] = array(0 => 0, 1 => 'MyOnValue');
- field_update_field($fieldUpdate);
- $instance = array(
+ $fieldUpdate->save();
+ entity_create('field_instance', array(
'field_name' => $this->bool['field_name'],
'entity_type' => 'node',
'bundle' => 'page',
- );
- field_create_instance($instance);
+ ))->save();
entity_get_form_display('node', 'page', 'default')
->setComponent($this->bool['field_name'], array(
diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/RdfaMarkupTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/RdfaMarkupTest.php
index 5d917a4..5a66727 100644
--- a/core/modules/rdf/lib/Drupal/rdf/Tests/RdfaMarkupTest.php
+++ b/core/modules/rdf/lib/Drupal/rdf/Tests/RdfaMarkupTest.php
@@ -110,13 +110,13 @@ function testAttributesInMarkupFile() {
'field_name' => $field_name,
'type' => 'file',
);
- field_create_field($field);
+ entity_create('field_entity', $field)->save();
$instance = array(
'field_name' => $field_name,
'entity_type' => 'node',
'bundle' => $bundle_name,
);
- field_create_instance($instance);
+ entity_create('field_instance', $instance)->save();
entity_get_form_display('node', $bundle_name, 'default')
->setComponent($field_name, array(
diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchMultilingualEntityTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchMultilingualEntityTest.php
index e9526d8..b392277 100644
--- a/core/modules/search/lib/Drupal/search/Tests/SearchMultilingualEntityTest.php
+++ b/core/modules/search/lib/Drupal/search/Tests/SearchMultilingualEntityTest.php
@@ -50,7 +50,7 @@ function setUp() {
// The parent class has already created the article and page content types.
$field = field_info_field('body');
$field['translatable'] = TRUE;
- field_update_field($field);
+ $field->save();
// Create a few page nodes with multilingual body values.
$default_format = filter_default_format();
diff --git a/core/modules/serialization/lib/Drupal/serialization/Tests/EntityResolverTest.php b/core/modules/serialization/lib/Drupal/serialization/Tests/EntityResolverTest.php
index dfbb7ba..48d0293 100644
--- a/core/modules/serialization/lib/Drupal/serialization/Tests/EntityResolverTest.php
+++ b/core/modules/serialization/lib/Drupal/serialization/Tests/EntityResolverTest.php
@@ -34,22 +34,20 @@ protected function setUp() {
parent::setUp();
// Create the test field.
- $field = array(
+ entity_create('field_entity', array(
'settings' => array(
'target_type' => 'entity_test_mulrev',
),
'field_name' => 'field_test_entity_reference',
'type' => 'entity_reference',
- );
- field_create_field($field);
+ ))->save();
// Create the test field instance.
- $instance = array(
+ entity_create('field_instance', array(
'entity_type' => 'entity_test_mulrev',
'field_name' => 'field_test_entity_reference',
'bundle' => 'entity_test_mulrev',
- );
- field_create_instance($instance);
+ ))->save();
}
/**
diff --git a/core/modules/serialization/lib/Drupal/serialization/Tests/NormalizerTestBase.php b/core/modules/serialization/lib/Drupal/serialization/Tests/NormalizerTestBase.php
index 1d9bff6..74fa8d9 100644
--- a/core/modules/serialization/lib/Drupal/serialization/Tests/NormalizerTestBase.php
+++ b/core/modules/serialization/lib/Drupal/serialization/Tests/NormalizerTestBase.php
@@ -26,13 +26,13 @@ protected function setUp() {
$this->installConfig(array('field'));
// Auto-create a field for testing.
- field_create_field(array(
+ entity_create('field_entity', array(
'field_name' => 'field_test_text',
'type' => 'text',
'cardinality' => 1,
'translatable' => FALSE,
- ));
- $instance = array(
+ ))->save();
+ entity_create('field_instance', array(
'entity_type' => 'entity_test_mulrev',
'field_name' => 'field_test_text',
'bundle' => 'entity_test_mulrev',
@@ -41,7 +41,7 @@ protected function setUp() {
'type' => 'text_textfield',
'weight' => 0,
),
- );
- field_create_instance($instance);
+ ))->save();
}
+
}
diff --git a/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php b/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php
index 242bcd6..1e872aa 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php
@@ -235,13 +235,13 @@ function testEnableModulesFixedList() {
'field_name' => 'test_field',
'type' => 'test_field'
);
- field_create_field($field);
+ entity_create('field_entity', $field)->save();
$instance = array(
'field_name' => $field['field_name'],
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
);
- field_create_instance($instance);
+ entity_create('field_instance', $instance)->save();
}
/**
diff --git a/core/modules/system/lib/Drupal/system/Tests/Ajax/MultiFormTest.php b/core/modules/system/lib/Drupal/system/Tests/Ajax/MultiFormTest.php
index d3ba0b7..c663fa3 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Ajax/MultiFormTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Ajax/MultiFormTest.php
@@ -39,13 +39,13 @@ function setUp() {
'type' => 'text',
'cardinality' => FIELD_CARDINALITY_UNLIMITED,
);
- field_create_field($field);
+ entity_create('field_entity', $field)->save();
$instance = array(
'field_name' => $field_name,
'entity_type' => 'node',
'bundle' => 'page',
);
- field_create_instance($instance);
+ entity_create('field_instance', $instance)->save();
entity_get_form_display('node', 'page', 'default')
->setComponent($field_name, array('type' => 'text_default'))
->save();
diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php
index fabbcfe..90c03e9 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php
@@ -598,7 +598,7 @@ protected function assertComputedProperties($entity_type) {
// Make the test text field processed.
$instance = field_info_instance($entity_type, 'field_test_text', $entity_type);
$instance['settings']['text_processing'] = 1;
- field_update_instance($instance);
+ $instance->save();
$entity = $this->createTestEntity($entity_type);
$entity->field_test_text->value = "The text text to filter.";
diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryAggregateTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryAggregateTest.php
index 54c6934..76cf7bd 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryAggregateTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryAggregateTest.php
@@ -65,13 +65,13 @@ public function setUp() {
'type' => 'number_integer',
'cardinality' => 2,
);
- field_create_field($field);
+ entity_create('field_entity', $field)->save();
$instance = array(
'field_name' => $field['field_name'],
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
);
- field_create_instance($instance);
+ entity_create('field_instance', $instance)->save();
}
$entity = $this->entityStorageController->create(array(
diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryRelationshipTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryRelationshipTest.php
index f36fca7..ee5a226 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryRelationshipTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryRelationshipTest.php
@@ -85,14 +85,14 @@ public function setUp() {
'type' => 'taxonomy_term_reference',
);
$field['settings']['allowed_values']['vocabulary'] = $vocabulary->id();
- field_create_field($field);
+ entity_create('field_entity', $field)->save();
// Third, create the instance.
$instance = array(
'entity_type' => 'entity_test',
'field_name' => $this->fieldName,
'bundle' => 'entity_test',
);
- field_create_instance($instance);
+ entity_create('field_instance', $instance)->save();
// Create two terms and also two accounts.
for ($i = 0; $i <= 1; $i++) {
$term = entity_create('taxonomy_term', array(
diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryTest.php
index 958bfb5..25e3339 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryTest.php
@@ -57,12 +57,13 @@ function setUp() {
$figures = drupal_strtolower($this->randomName());
$greetings = drupal_strtolower($this->randomName());
foreach (array($figures => 'shape', $greetings => 'text') as $field_name => $field_type) {
- $field = array(
+ $field = entity_create('field_entity', array(
'field_name' => $field_name,
'type' => $field_type,
'cardinality' => 2,
- );
- $fields[] = field_create_field($field);
+ ));
+ $field->save();
+ $fields[] = $field;
}
$bundles = array();
for ($i = 0; $i < 2; $i++) {
@@ -78,7 +79,7 @@ function setUp() {
'entity_type' => 'test_entity',
'bundle' => $bundle,
);
- field_create_instance($instance);
+ entity_create('field_instance', $instance)->save();
}
$bundles[] = $bundle;
}
@@ -393,7 +394,7 @@ protected function testCount() {
'entity_type' => 'test_entity_bundle',
'bundle' => $bundle,
);
- field_create_instance($instance);
+ entity_create('field_instance', $instance)->save();
$entity = entity_create('test_entity_bundle', array(
'ftid' => 1,
diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php
index 012b909..ab07d74 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php
@@ -106,7 +106,7 @@ function testEntityFormLanguage() {
// Make body translatable.
$field = field_info_field('body');
$field['translatable'] = TRUE;
- field_update_field($field);
+ $field->save();
$field = field_info_field('body');
$this->assertTrue($field['translatable'], 'Field body is translatable.');
diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php
index f5c1c52..6730fac 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php
@@ -56,7 +56,7 @@ function setUp() {
'cardinality' => 4,
'translatable' => TRUE,
);
- field_create_field($field);
+ entity_create('field_entity', $field)->save();
$this->field = field_read_field($this->field_name);
// Create instance in all entity variations.
@@ -66,7 +66,7 @@ function setUp() {
'entity_type' => $entity_type,
'bundle' => $entity_type,
);
- field_create_instance($instance);
+ entity_create('field_instance', $instance)->save();
$this->instance[$entity_type] = field_read_instance($entity_type, $this->field_name, $entity_type);
}
diff --git a/core/modules/system/lib/Drupal/system/Tests/Form/ArbitraryRebuildTest.php b/core/modules/system/lib/Drupal/system/Tests/Form/ArbitraryRebuildTest.php
index f049ac8..01a9fda 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Form/ArbitraryRebuildTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Form/ArbitraryRebuildTest.php
@@ -39,7 +39,7 @@ function setUp() {
'cardinality' => -1,
'translatable' => FALSE,
);
- field_create_field($field);
+ entity_create('field_entity', $field)->save();
$instance = array(
'entity_type' => 'user',
@@ -50,7 +50,7 @@ function setUp() {
'user_register_form' => TRUE,
),
);
- field_create_instance($instance);
+ entity_create('field_instance', $instance)->save();
entity_get_form_display('user', 'user', 'default')
->setComponent('test_multiple', array(
'type' => 'text_textfield',
diff --git a/core/modules/system/lib/Drupal/system/Tests/Form/RebuildTest.php b/core/modules/system/lib/Drupal/system/Tests/Form/RebuildTest.php
index 8e9f649..c580e88 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Form/RebuildTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Form/RebuildTest.php
@@ -76,13 +76,13 @@ function testPreserveFormActionAfterAJAX() {
'type' => 'text',
'cardinality' => FIELD_CARDINALITY_UNLIMITED,
);
- field_create_field($field);
+ entity_create('field_entity', $field)->save();
$instance = array(
'field_name' => $field_name,
'entity_type' => 'node',
'bundle' => 'page',
);
- field_create_instance($instance);
+ entity_create('field_instance', $instance)->save();
entity_get_form_display('node', 'page', 'default')
->setComponent($field_name, array('type' => 'text_test'))
->save();
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 f7b8726..50ee30b 100644
--- a/core/modules/system/tests/modules/entity_test/entity_test.install
+++ b/core/modules/system/tests/modules/entity_test/entity_test.install
@@ -16,7 +16,7 @@ function entity_test_install() {
'cardinality' => 1,
'translatable' => FALSE,
);
- field_create_field($field);
+ entity_create('field_entity', $field)->save();
$entity_types = array(
'entity_test',
@@ -31,7 +31,7 @@ function entity_test_install() {
'bundle' => $entity_type,
'label' => 'Test text-field',
);
- field_create_instance($instance);
+ entity_create('field_instance', $instance)->save();
entity_get_form_display($entity_type, $entity_type, 'default')
->setComponent('field_test_text', array('type' => 'text_text'))
diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/RssTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/RssTest.php
index d4be486..ef9aca8 100644
--- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/RssTest.php
+++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/RssTest.php
@@ -47,14 +47,14 @@ function setUp() {
),
),
);
- field_create_field($field);
+ entity_create('field_entity', $field)->save();
$this->instance = array(
'field_name' => 'taxonomy_' . $this->vocabulary->id(),
'bundle' => 'article',
'entity_type' => 'node',
);
- field_create_instance($this->instance);
+ entity_create('field_instance', $this->instance)->save();
entity_get_form_display('node', 'article', 'default')
->setComponent($field['field_name'], array(
'type' => 'options_select',
diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTermReferenceItemTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTermReferenceItemTest.php
index 77b9b1c..7c3822e 100644
--- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTermReferenceItemTest.php
+++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTermReferenceItemTest.php
@@ -55,13 +55,13 @@ public function setUp() {
),
),
);
- field_create_field($field);
+ entity_create('field_entity', $field)->save();
$instance = array(
'entity_type' => 'entity_test',
'field_name' => 'field_test_taxonomy',
'bundle' => 'entity_test',
);
- field_create_instance($instance);
+ entity_create('field_instance', $instance)->save();
$this->term = entity_create('taxonomy_term', array(
'name' => $this->randomName(),
'vid' => $vocabulary->id(),
diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldMultipleVocabularyTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldMultipleVocabularyTest.php
index 627f762..e845f2e 100644
--- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldMultipleVocabularyTest.php
+++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldMultipleVocabularyTest.php
@@ -58,13 +58,13 @@ function setUp() {
),
)
);
- field_create_field($this->field);
+ entity_create('field_entity', $this->field)->save();
$this->instance = array(
'field_name' => $this->field_name,
'entity_type' => 'test_entity',
'bundle' => 'test_bundle',
);
- field_create_instance($this->instance);
+ entity_create('field_instance', $this->instance)->save();
entity_get_form_display('test_entity', 'test_bundle', 'default')
->setComponent($this->field_name, array(
'type' => 'options_select',
diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldTest.php
index 27184d8..919982f 100644
--- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldTest.php
+++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldTest.php
@@ -41,7 +41,7 @@ function setUp() {
// Setup a field and instance.
$this->field_name = drupal_strtolower($this->randomName());
- $this->field = array(
+ $this->field = entity_create('field_entity', array(
'field_name' => $this->field_name,
'type' => 'taxonomy_term_reference',
'settings' => array(
@@ -52,14 +52,14 @@ function setUp() {
),
),
)
- );
- field_create_field($this->field);
+ ));
+ $this->field->save();
$this->instance = array(
'field_name' => $this->field_name,
'entity_type' => 'test_entity',
'bundle' => 'test_bundle',
);
- field_create_instance($this->instance);
+ entity_create('field_instance', $this->instance)->save();
entity_get_form_display('test_entity', 'test_bundle', 'default')
->setComponent($this->field_name, array(
'type' => 'options_select',
@@ -157,7 +157,7 @@ function testTaxonomyTermFieldChangeMachineName() {
'parent' => '0',
),
);
- field_update_field($this->field);
+ $this->field->save();
// Change the machine name.
$new_name = drupal_strtolower($this->randomName());
$this->vocabulary->vid = $new_name;
diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermIndexTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermIndexTest.php
index 4c2202c..0f59639 100644
--- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermIndexTest.php
+++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermIndexTest.php
@@ -44,13 +44,13 @@ function setUp() {
),
),
);
- field_create_field($this->field_1);
+ entity_create('field_entity', $this->field_1)->save();
$this->instance_1 = array(
'field_name' => $this->field_name_1,
'bundle' => 'article',
'entity_type' => 'node',
);
- field_create_instance($this->instance_1);
+ entity_create('field_instance', $this->instance_1)->save();
entity_get_form_display('node', 'article', 'default')
->setComponent($this->field_name_1, array(
'type' => 'options_select',
@@ -76,13 +76,13 @@ function setUp() {
),
),
);
- field_create_field($this->field_2);
+ entity_create('field_entity', $this->field_2)->save();
$this->instance_2 = array(
'field_name' => $this->field_name_2,
'bundle' => 'article',
'entity_type' => 'node',
);
- field_create_instance($this->instance_2);
+ entity_create('field_instance', $this->instance_2)->save();
entity_get_form_display('node', 'article', 'default')
->setComponent($this->field_name_2, array(
'type' => 'options_select',
diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php
index f9fb10b..4eadb55 100644
--- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php
+++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php
@@ -39,14 +39,14 @@ function setUp() {
),
),
);
- field_create_field($field);
+ entity_create('field_entity', $field)->save();
- $this->instance = array(
+ $this->instance = entity_create('field_instance', array(
'field_name' => 'taxonomy_' . $this->vocabulary->id(),
'bundle' => 'article',
'entity_type' => 'node',
- );
- field_create_instance($this->instance);
+ ));
+ $this->instance->save();
entity_get_form_display('node', 'article', 'default')
->setComponent('taxonomy_' . $this->vocabulary->id(), array(
'type' => 'options_select',
diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php
index 2d3657e..7de32f2 100644
--- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php
+++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php
@@ -40,14 +40,14 @@ function setUp() {
),
),
);
- field_create_field($field);
+ entity_create('field_entity', $field)->save();
$this->instance = array(
'field_name' => 'taxonomy_' . $this->vocabulary->id(),
'bundle' => 'article',
'entity_type' => 'node',
);
- field_create_instance($this->instance);
+ entity_create('field_instance', $this->instance)->save();
entity_get_form_display('node', 'article', 'default')
->setComponent('taxonomy_' . $this->vocabulary->id(), array(
'type' => 'options_select',
diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/Views/TaxonomyTestBase.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/Views/TaxonomyTestBase.php
index e71cf97..d2a9cf0 100644
--- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/Views/TaxonomyTestBase.php
+++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/Views/TaxonomyTestBase.php
@@ -94,14 +94,14 @@ protected function mockStandardInstall() {
),
),
);
- field_create_field($field);
+ entity_create('field_entity', $field)->save();
$instance = array(
'field_name' => 'field_' . $this->vocabulary->id(),
'entity_type' => 'node',
'label' => 'Tags',
'bundle' => 'article',
);
- field_create_instance($instance);
+ entity_create('field_instance', $instance)->save();
entity_get_form_display('node', 'article', 'default')
->setComponent($instance['field_name'], array(
diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyUnitTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyUnitTest.php
index 9a329f5..fbd0875 100644
--- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyUnitTest.php
+++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyUnitTest.php
@@ -145,13 +145,13 @@ function testTaxonomyVocabularyChangeMachineName() {
'field_name' => 'field_test',
'type' => 'test_field',
);
- field_create_field($field);
+ entity_create('field_entity', $field)->save();
$instance = array(
'field_name' => 'field_test',
'entity_type' => 'taxonomy_term',
'bundle' => $this->vocabulary->id(),
);
- field_create_instance($instance);
+ entity_create('field_instance', $instance)->save();
// Change the machine name.
$old_name = $this->vocabulary->id();
@@ -176,14 +176,14 @@ function testUninstallReinstall() {
// removed when the module is uninstalled.
$this->field_name = drupal_strtolower($this->randomName() . '_field_name');
$this->field_definition = array('field_name' => $this->field_name, 'type' => 'text', 'cardinality' => 4);
- field_create_field($this->field_definition);
+ entity_create('field_entity', $this->field_definition)->save();
$this->instance_definition = array(
'field_name' => $this->field_name,
'entity_type' => 'taxonomy_term',
'bundle' => $this->vocabulary->id(),
'label' => $this->randomName() . '_label',
);
- field_create_instance($this->instance_definition);
+ entity_create('field_instance', $this->instance_definition)->save();
module_disable(array('taxonomy'));
require_once DRUPAL_ROOT . '/core/includes/install.inc';
@@ -196,7 +196,7 @@ function testUninstallReinstall() {
// an instance of this field on the same bundle name should be successful.
$this->vocabulary->enforceIsNew();
$this->vocabulary->save();
- field_create_field($this->field_definition);
- field_create_instance($this->instance_definition);
+ entity_create('field_entity', $this->field_definition)->save();
+ entity_create('field_instance', $this->instance_definition)->save();
}
}
diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyStorageController.php b/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyStorageController.php
index c0e377b..d3d778b 100644
--- a/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyStorageController.php
+++ b/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyStorageController.php
@@ -36,7 +36,7 @@ protected function postSave(EntityInterface $entity, $update) {
}
}
if ($update_field) {
- field_update_field($field);
+ $field->save();
}
}
}
@@ -82,11 +82,11 @@ protected function postDelete($entities) {
}
if ($modified_field) {
if (empty($taxonomy_field['settings']['allowed_values'])) {
- field_delete_field($field_name);
+ $taxonomy_field->delete();
}
else {
// Update the field definition with the new allowed values.
- field_update_field($taxonomy_field);
+ $taxonomy_field->save();
}
}
}
diff --git a/core/modules/telephone/lib/Drupal/telephone/Tests/TelephoneFieldTest.php b/core/modules/telephone/lib/Drupal/telephone/Tests/TelephoneFieldTest.php
index 0d5aa47..bae4688 100644
--- a/core/modules/telephone/lib/Drupal/telephone/Tests/TelephoneFieldTest.php
+++ b/core/modules/telephone/lib/Drupal/telephone/Tests/TelephoneFieldTest.php
@@ -57,7 +57,7 @@ function testTelephoneField() {
'field_name' => 'field_telephone',
'type' => 'telephone',
);
- field_create_field($field);
+ entity_create('field_entity', $field)->save();
$instance = array(
'field_name' => 'field_telephone',
@@ -65,7 +65,7 @@ function testTelephoneField() {
'entity_type' => 'node',
'bundle' => 'article',
);
- field_create_instance($instance);
+ entity_create('field_instance', $instance)->save();
entity_get_form_display('node', 'article', 'default')
->setComponent('field_telephone', array(
diff --git a/core/modules/telephone/lib/Drupal/telephone/Tests/TelephoneItemTest.php b/core/modules/telephone/lib/Drupal/telephone/Tests/TelephoneItemTest.php
index d809161..3bce914 100644
--- a/core/modules/telephone/lib/Drupal/telephone/Tests/TelephoneItemTest.php
+++ b/core/modules/telephone/lib/Drupal/telephone/Tests/TelephoneItemTest.php
@@ -39,13 +39,13 @@ public function setUp() {
'field_name' => 'field_test',
'type' => 'telephone',
);
- field_create_field($this->field);
+ entity_create('field_entity', $this->field)->save();
$this->instance = array(
'entity_type' => 'entity_test',
'field_name' => 'field_test',
'bundle' => 'entity_test',
);
- field_create_instance($this->instance);
+ entity_create('field_instance', $this->instance)->save();
}
/**
diff --git a/core/modules/text/lib/Drupal/text/Tests/Formatter/TextPlainUnitTest.php b/core/modules/text/lib/Drupal/text/Tests/Formatter/TextPlainUnitTest.php
index 052cfe3..4c073e8 100644
--- a/core/modules/text/lib/Drupal/text/Tests/Formatter/TextPlainUnitTest.php
+++ b/core/modules/text/lib/Drupal/text/Tests/Formatter/TextPlainUnitTest.php
@@ -65,21 +65,21 @@ function setUp() {
$this->formatter_type = 'text_plain';
$this->formatter_settings = array();
- $this->field = array(
+ $this->field = entity_create('field_entity', array(
'field_name' => $this->field_name,
'type' => $this->field_type,
'settings' => $this->field_settings,
- );
- $this->field = field_create_field($this->field);
+ ));
+ $this->field->save();
- $this->instance = array(
+ $this->instance = entity_create('field_instance', array(
'entity_type' => $this->entity_type,
'bundle' => $this->bundle,
'field_name' => $this->field_name,
'label' => $this->randomName(),
'settings' => $this->instance_settings,
- );
- $this->instance = field_create_instance($this->instance);
+ ));
+ $this->instance->save();
$this->view_mode = 'default';
$this->display = entity_get_display($this->entity_type, $this->bundle, $this->view_mode)
diff --git a/core/modules/text/lib/Drupal/text/Tests/TextFieldTest.php b/core/modules/text/lib/Drupal/text/Tests/TextFieldTest.php
index e12553f..4ad8956 100644
--- a/core/modules/text/lib/Drupal/text/Tests/TextFieldTest.php
+++ b/core/modules/text/lib/Drupal/text/Tests/TextFieldTest.php
@@ -57,13 +57,13 @@ function testTextFieldValidation() {
'max_length' => $max_length,
)
);
- field_create_field($this->field);
+ entity_create('field_entity', $this->field)->save();
$this->instance = array(
'field_name' => $this->field['field_name'],
'entity_type' => 'test_entity',
'bundle' => 'test_bundle',
);
- field_create_instance($this->instance);
+ entity_create('field_instance', $this->instance)->save();
// Test valid and invalid values with field_attach_validate().
$entity = field_test_create_entity();
@@ -96,7 +96,7 @@ function _testTextfieldWidgets($field_type, $widget_type) {
$entity_type = 'test_entity';
$this->field_name = drupal_strtolower($this->randomName());
$this->field = array('field_name' => $this->field_name, 'type' => $field_type);
- field_create_field($this->field);
+ entity_create('field_entity', $this->field)->save();
$this->instance = array(
'field_name' => $this->field_name,
'entity_type' => 'test_entity',
@@ -106,7 +106,7 @@ function _testTextfieldWidgets($field_type, $widget_type) {
'text_processing' => TRUE,
),
);
- field_create_instance($this->instance);
+ entity_create('field_instance', $this->instance)->save();
entity_get_form_display('test_entity', 'test_bundle', 'default')
->setComponent($this->field_name, array(
'type' => $widget_type,
@@ -161,7 +161,7 @@ function _testTextfieldWidgetsFormatted($field_type, $widget_type) {
$entity_type = 'test_entity';
$this->field_name = drupal_strtolower($this->randomName());
$this->field = array('field_name' => $this->field_name, 'type' => $field_type);
- field_create_field($this->field);
+ entity_create('field_entity', $this->field)->save();
$this->instance = array(
'field_name' => $this->field_name,
'entity_type' => 'test_entity',
@@ -171,7 +171,7 @@ function _testTextfieldWidgetsFormatted($field_type, $widget_type) {
'text_processing' => TRUE,
),
);
- field_create_instance($this->instance);
+ entity_create('field_instance', $this->instance)->save();
entity_get_form_display('test_entity', 'test_bundle', 'default')
->setComponent($this->field_name, array(
'type' => $widget_type,
diff --git a/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationSyncImageTest.php b/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationSyncImageTest.php
index aa9c626..a58f30b 100644
--- a/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationSyncImageTest.php
+++ b/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationSyncImageTest.php
@@ -62,7 +62,7 @@ protected function setupTestFields() {
'cardinality' => $this->cardinality,
'translatable' => TRUE,
);
- field_create_field($field);
+ entity_create('field_entity', $field)->save();
$instance = array(
'entity_type' => $this->entityType,
@@ -77,7 +77,7 @@ protected function setupTestFields() {
),
),
);
- field_create_instance($instance);
+ entity_create('field_instance', $instance)->save();
}
/**
diff --git a/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationTestBase.php b/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationTestBase.php
index 870321f..7272eee 100644
--- a/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationTestBase.php
+++ b/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationTestBase.php
@@ -163,7 +163,7 @@ protected function setupTestFields() {
'cardinality' => 1,
'translatable' => TRUE,
);
- field_create_field($field);
+ entity_create('field_entity', $field)->save();
$instance = array(
'entity_type' => $this->entityType,
@@ -171,7 +171,7 @@ protected function setupTestFields() {
'bundle' => $this->bundle,
'label' => 'Test translatable text-field',
);
- field_create_instance($instance);
+ entity_create('field_instance', $instance)->save();
entity_get_form_display($this->entityType, $this->bundle, 'default')
->setComponent($this->fieldName, array(
'type' => 'text_textfield',
diff --git a/core/modules/translation_entity/translation_entity.admin.inc b/core/modules/translation_entity/translation_entity.admin.inc
index 8c184b5..3325ec0 100644
--- a/core/modules/translation_entity/translation_entity.admin.inc
+++ b/core/modules/translation_entity/translation_entity.admin.inc
@@ -459,7 +459,7 @@ function translation_entity_translatable_switch($translatable, $field_name) {
$field = field_info_field($field_name);
if ($field['translatable'] !== $translatable) {
$field['translatable'] = $translatable;
- field_update_field($field);
+ $field->save();
}
}
diff --git a/core/modules/translation_entity/translation_entity.module b/core/modules/translation_entity/translation_entity.module
index 82bd66d..697c9a4 100644
--- a/core/modules/translation_entity/translation_entity.module
+++ b/core/modules/translation_entity/translation_entity.module
@@ -1027,7 +1027,7 @@ function translation_entity_save_settings($settings) {
else {
unset($instance['settings']['translation_sync']);
}
- field_update_instance($instance);
+ $instance->save();
}
}
}
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php b/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php
index db649b0..dd58507 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php
@@ -194,21 +194,21 @@ function testRegistrationDefaultValues() {
*/
function testRegistrationWithUserFields() {
// Create a field, and an instance on 'user' entity type.
- $field = array(
+ $field = entity_create('field_entity', array(
'type' => 'test_field',
'field_name' => 'test_user_field',
'cardinality' => 1,
- );
- field_create_field($field);
- $instance = array(
+ ));
+ $field->save();
+ $instance = entity_create('field_instance', array(
'field_name' => 'test_user_field',
'entity_type' => 'user',
'label' => 'Some user field',
'bundle' => 'user',
'required' => TRUE,
'settings' => array('user_register_form' => FALSE),
- );
- field_create_instance($instance);
+ ));
+ $instance->save();
entity_get_form_display('user', 'user', 'default')
->setComponent('test_user_field', array('type' => 'test_field_widget'))
->save();
@@ -219,7 +219,7 @@ function testRegistrationWithUserFields() {
// Have the field appear on the registration form.
$instance['settings']['user_register_form'] = TRUE;
- field_update_instance($instance);
+ $instance->save();
$this->drupalGet('user/register');
$this->assertText($instance['label'], 'The field appears on user registration form');
@@ -247,7 +247,7 @@ function testRegistrationWithUserFields() {
// Check that the 'add more' button works.
$field['cardinality'] = FIELD_CARDINALITY_UNLIMITED;
- field_update_field($field);
+ $field->save();
foreach (array('js', 'nojs') as $js) {
$this->drupalGet('user/register');
// Add two inputs.
diff --git a/core/modules/user/user.install b/core/modules/user/user.install
index 4f22958..b65dd46 100644
--- a/core/modules/user/user.install
+++ b/core/modules/user/user.install
@@ -316,7 +316,7 @@ function user_install_picture_field() {
'default_image' => FALSE,
),
);
- $field = field_create_field($field);
+ entity_create('field_entity', $field)->save();
$instance = array(
'field_name' => 'user_picture',
@@ -336,7 +336,7 @@ function user_install_picture_field() {
'default_image' => 0,
),
);
- field_create_instance($instance);
+ entity_create('field_instance', $instance)->save();
// Assign form display settings for the 'default' view mode.
entity_get_form_display('user', 'user', 'default')
diff --git a/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php b/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php
index d6d7226..94c71f8 100644
--- a/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php
+++ b/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php
@@ -72,13 +72,13 @@ protected function setUp() {
),
)
);
- field_create_field($this->field);
+ entity_create('field_entity', $this->field)->save();
$this->instance = array(
'field_name' => $this->field_name,
'entity_type' => 'node',
'bundle' => 'page',
);
- field_create_instance($this->instance);
+ entity_create('field_instance', $this->instance)->save();
// Create a time in the past for the archive.
$time = time() - 3600;
diff --git a/core/modules/views/lib/Drupal/views/Tests/Wizard/TaggedWithTest.php b/core/modules/views/lib/Drupal/views/Tests/Wizard/TaggedWithTest.php
index f1a06a3..2cf4745 100644
--- a/core/modules/views/lib/Drupal/views/Tests/Wizard/TaggedWithTest.php
+++ b/core/modules/views/lib/Drupal/views/Tests/Wizard/TaggedWithTest.php
@@ -66,7 +66,7 @@ function setUp() {
),
),
);
- field_create_field($this->tag_field);
+ entity_create('field_entity', $this->tag_field)->save();
// Create an instance of the tag field on one of the content types, and
// configure it to display an autocomplete widget.
@@ -75,7 +75,7 @@ function setUp() {
'entity_type' => 'node',
'bundle' => $this->node_type_with_tags->type,
);
- field_create_instance($this->tag_instance);
+ entity_create('field_instance', $this->tag_instance)->save();
entity_get_form_display('node', $this->node_type_with_tags->type, 'default')
->setComponent('field_views_testing_tags', array(
@@ -187,7 +187,7 @@ function testTaggedWithByNodeType() {
// "tagged with" form element should not appear for it too.
$instance = $this->tag_instance;
$instance['bundle'] = $this->node_type_without_tags->type;
- field_create_instance($instance);
+ entity_create('field_instance', $instance)->save();
entity_get_form_display('node', $this->node_type_without_tags->type, 'default')
->setComponent('field_views_testing_tags', array(
'type' => 'taxonomy_autocomplete',
diff --git a/core/scripts/generate-d7-content.sh b/core/scripts/generate-d7-content.sh
index c171271..a64e22a 100644
--- a/core/scripts/generate-d7-content.sh
+++ b/core/scripts/generate-d7-content.sh
@@ -93,7 +93,7 @@
),
),
);
- field_create_field($field);
+ entity_create('field_entity', $field)->save();
$node_types = $i > 11 ? array('page') : array_keys(node_type_get_types());
foreach ($node_types as $bundle) {
$instance = array(
@@ -132,7 +132,7 @@
'settings' => array(),
);
}
- field_create_instance($instance);
+ entity_create('field_instance', $instance)->save();
}
$parents = array();
// Vocabularies without hierarchy get one term, single parent vocabularies get