diff --git a/core/modules/node/lib/Drupal/node/Tests/MultiStepNodeFormBasicOptionsTest.php b/core/modules/node/lib/Drupal/node/Tests/MultiStepNodeFormBasicOptionsTest.php
index 7697423..2bd01b3 100644
--- a/core/modules/node/lib/Drupal/node/Tests/MultiStepNodeFormBasicOptionsTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/MultiStepNodeFormBasicOptionsTest.php
@@ -44,7 +44,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(
@@ -56,7 +56,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 4b3dc88..3ffd608 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessFieldTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessFieldTest.php
@@ -40,13 +40,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 18c879f..f4ec2dd 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 d46c24e..38dab06 100644
--- a/core/modules/node/lib/Drupal/node/Tests/PagePreviewTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/PagePreviewTest.php
@@ -74,13 +74,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 9206798..de5d0e0 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 7cb310a..28b6d49 100644
--- a/core/modules/number/lib/Drupal/number/Tests/NumberFieldTest.php
+++ b/core/modules/number/lib/Drupal/number/Tests/NumberFieldTest.php
@@ -53,13 +53,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 984a205..d4f1a0e 100644
--- a/core/modules/options/lib/Drupal/options/Tests/OptionsFieldTest.php
+++ b/core/modules/options/lib/Drupal/options/Tests/OptionsFieldTest.php
@@ -50,7 +50,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) {
@@ -62,7 +62,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');
@@ -71,7 +71,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');
@@ -80,15 +80,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 f28fb7c..a3aa444 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 91f7498..66990e2 100644
--- a/core/modules/options/lib/Drupal/options/Tests/OptionsWidgetsTest.php
+++ b/core/modules/options/lib/Drupal/options/Tests/OptionsWidgetsTest.php
@@ -34,7 +34,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,
@@ -42,11 +42,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,
@@ -54,19 +54,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'));
@@ -78,12 +78,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',
@@ -123,9 +123,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");
}
@@ -135,12 +135,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',
@@ -213,9 +213,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");
}
@@ -225,13 +225,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',
@@ -278,7 +278,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');
@@ -293,7 +293,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');
@@ -325,12 +325,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',
@@ -399,7 +399,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.');
@@ -411,9 +411,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');
@@ -445,12 +445,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',
@@ -498,13 +497,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 bf47b46..1b89160 100644
--- a/core/modules/rdf/lib/Drupal/rdf/Tests/RdfaMarkupTest.php
+++ b/core/modules/rdf/lib/Drupal/rdf/Tests/RdfaMarkupTest.php
@@ -111,13 +111,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(