diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/RssTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/RssTest.php index 118e813..1b8bb3b 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/RssTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/RssTest.php @@ -35,9 +35,10 @@ function setUp() { $this->admin_user = $this->drupalCreateUser(array('administer taxonomy', 'bypass node access', 'administer content types', 'administer node display')); $this->drupalLogin($this->admin_user); $this->vocabulary = $this->createVocabulary(); + $this->field_name = 'taxonomy_' . $this->vocabulary->id(); - $field = array( - 'field_name' => 'taxonomy_' . $this->vocabulary->id(), + $this->field = entity_create('field_entity', array( + 'field_name' => $this->field_name, 'type' => 'taxonomy_term_reference', 'cardinality' => FIELD_CARDINALITY_UNLIMITED, 'settings' => array( @@ -48,22 +49,20 @@ function setUp() { ), ), ), - ); - field_create_field($field); - - $this->instance = array( - 'field_name' => 'taxonomy_' . $this->vocabulary->id(), + )); + $this->field->save(); + entity_create('field_instance', array( + 'field_name' => $this->field_name, 'bundle' => 'article', 'entity_type' => 'node', - ); - field_create_instance($this->instance); + ))->save(); entity_get_form_display('node', 'article', 'default') - ->setComponent($field['field_name'], array( + ->setComponent($this->field_name, array( 'type' => 'options_select', )) ->save(); entity_get_display('node', 'article', 'default') - ->setComponent('taxonomy_' . $this->vocabulary->id(), array( + ->setComponent($this->field_name, array( 'type' => 'taxonomy_term_reference_link', )) ->save(); @@ -96,7 +95,7 @@ function testTaxonomyRss() { $edit = array(); $langcode = Language::LANGCODE_NOT_SPECIFIED; $edit["title"] = $this->randomName(); - $edit[$this->instance['field_name'] . '[' . $langcode . '][]'] = $term1->id(); + $edit[$this->field_name . '[' . $langcode . '][]'] = $term1->id(); $this->drupalPost('node/add/article', $edit, t('Save')); // Check that the term is displayed when the RSS feed is viewed. diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTermReferenceItemTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTermReferenceItemTest.php index a8aefcb..fa39d83 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTermReferenceItemTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTermReferenceItemTest.php @@ -43,7 +43,8 @@ public function setUp() { 'langcode' => Language::LANGCODE_NOT_SPECIFIED, )); $vocabulary->save(); - $field = array( + + entity_create('field_entity', array( 'field_name' => 'field_test_taxonomy', 'type' => 'taxonomy_term_reference', 'cardinality' => FIELD_CARDINALITY_UNLIMITED, @@ -55,14 +56,12 @@ public function setUp() { ), ), ), - ); - field_create_field($field); - $instance = array( + ))->save(); + entity_create('field_instance', array( 'entity_type' => 'entity_test', 'field_name' => 'field_test_taxonomy', 'bundle' => 'entity_test', - ); - field_create_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 f82bce2..2449694 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldMultipleVocabularyTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldMultipleVocabularyTest.php @@ -21,7 +21,6 @@ class TermFieldMultipleVocabularyTest extends TaxonomyTestBase { */ public static $modules = array('entity_test'); - protected $instance; protected $vocabulary1; protected $vocabulary2; @@ -43,7 +42,7 @@ function setUp() { // Set up a field and instance. $this->field_name = drupal_strtolower($this->randomName()); - $this->field = array( + entity_create('field_entity', array( 'field_name' => $this->field_name, 'type' => 'taxonomy_term_reference', 'cardinality' => FIELD_CARDINALITY_UNLIMITED, @@ -59,14 +58,12 @@ function setUp() { ), ), ) - ); - field_create_field($this->field); - $this->instance = array( + ))->save(); + entity_create('field_entity', array( 'field_name' => $this->field_name, 'entity_type' => 'entity_test', 'bundle' => 'entity_test', - ); - field_create_instance($this->instance); + ))->save(); entity_get_form_display('entity_test', 'entity_test', '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 53a53b1..1db9e15 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldTest.php @@ -46,7 +46,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( @@ -57,14 +57,13 @@ function setUp() { ), ), ) - ); - field_create_field($this->field); - $this->instance = array( + )); + $this->field->save(); + entity_create('field_instance', array( 'field_name' => $this->field_name, 'entity_type' => 'entity_test', 'bundle' => 'entity_test', - ); - field_create_instance($this->instance); + ))->save(); entity_get_form_display('entity_test', 'entity_test', 'default') ->setComponent($this->field_name, array( 'type' => 'options_select', @@ -150,7 +149,7 @@ function testTaxonomyTermFieldWidgets() { function testTaxonomyTermFieldChangeMachineName() { // Add several entries in the 'allowed_values' setting, to make sure that // they all get updated. - $this->field['settings']['allowed_values'] = array( + $this->field->settings['allowed_values'] = array( array( 'vocabulary' => $this->vocabulary->id(), 'parent' => '0', @@ -164,7 +163,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 d6280c8..937511f 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermIndexTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermIndexTest.php @@ -33,7 +33,7 @@ function setUp() { $this->vocabulary = $this->createVocabulary(); $this->field_name_1 = drupal_strtolower($this->randomName()); - $this->field_1 = array( + entity_create('field_entity', array( 'field_name' => $this->field_name_1, 'type' => 'taxonomy_term_reference', 'cardinality' => FIELD_CARDINALITY_UNLIMITED, @@ -45,14 +45,12 @@ function setUp() { ), ), ), - ); - field_create_field($this->field_1); - $this->instance_1 = array( + ))->save(); + entity_create('field_instance', array( 'field_name' => $this->field_name_1, 'bundle' => 'article', 'entity_type' => 'node', - ); - field_create_instance($this->instance_1); + ))->save(); entity_get_form_display('node', 'article', 'default') ->setComponent($this->field_name_1, array( 'type' => 'options_select', @@ -65,7 +63,7 @@ function setUp() { ->save(); $this->field_name_2 = drupal_strtolower($this->randomName()); - $this->field_2 = array( + entity_create('field_entity', array( 'field_name' => $this->field_name_2, 'type' => 'taxonomy_term_reference', 'cardinality' => FIELD_CARDINALITY_UNLIMITED, @@ -77,14 +75,12 @@ function setUp() { ), ), ), - ); - field_create_field($this->field_2); - $this->instance_2 = array( + ))->save(); + entity_create('field_instance', array( 'field_name' => $this->field_name_2, 'bundle' => 'article', 'entity_type' => 'node', - ); - field_create_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 2a0907d..caf5397 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php @@ -41,14 +41,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 9bd8b2f..eec5921 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TokenReplaceTest.php @@ -28,9 +28,9 @@ function setUp() { $this->drupalLogin($this->admin_user); $this->vocabulary = $this->createVocabulary(); $this->langcode = Language::LANGCODE_NOT_SPECIFIED; - - $field = array( - 'field_name' => 'taxonomy_' . $this->vocabulary->id(), + $this->field_name = 'taxonomy_' . $this->vocabulary->id(); + entity_create('field_entity', array( + 'field_name' => $this->field_name, 'type' => 'taxonomy_term_reference', 'cardinality' => FIELD_CARDINALITY_UNLIMITED, 'settings' => array( @@ -41,22 +41,20 @@ function setUp() { ), ), ), - ); - field_create_field($field); + ))->save(); - $this->instance = array( - 'field_name' => 'taxonomy_' . $this->vocabulary->id(), + entity_create('field_instance', array( + 'field_name' => $this->field_name, 'bundle' => 'article', 'entity_type' => 'node', - ); - field_create_instance($this->instance); + ))->save(); entity_get_form_display('node', 'article', 'default') - ->setComponent('taxonomy_' . $this->vocabulary->id(), array( + ->setComponent($this->field_name, array( 'type' => 'options_select', )) ->save(); entity_get_display('node', 'article', 'default') - ->setComponent('taxonomy_' . $this->vocabulary->id(), array( + ->setComponent($this->field_name, array( 'type' => 'taxonomy_term_reference_link', )) ->save(); @@ -82,7 +80,7 @@ function testTaxonomyTokenReplacement() { // Create node with term2. $edit = array(); $node = $this->drupalCreateNode(array('type' => 'article')); - $edit[$this->instance['field_name'] . '[' . $this->langcode . '][]'] = $term2->id(); + $edit[$this->field_name . '[' . $this->langcode . '][]'] = $term2->id(); $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save')); // Generate and test sanitized tokens for term1. 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 74c546b..9d9eaee 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/Views/TaxonomyTestBase.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/Views/TaxonomyTestBase.php @@ -81,8 +81,9 @@ protected function mockStandardInstall() { 'vid' => 'views_testing_tags', )); $this->vocabulary->save(); - $field = array( - 'field_name' => 'field_' . $this->vocabulary->id(), + $this->field_name = 'field_' . $this->vocabulary->id(); + entity_create('field_entity', array( + 'field_name' => $this->field_name, 'type' => 'taxonomy_term_reference', // Set cardinality to unlimited for tagging. 'cardinality' => FIELD_CARDINALITY_UNLIMITED, @@ -94,31 +95,29 @@ protected function mockStandardInstall() { ), ), ), - ); - field_create_field($field); - $instance = array( - 'field_name' => 'field_' . $this->vocabulary->id(), + ))->save(); + $instance = entity_create('field_instance', array( + 'field_name' => $this->field_name, 'entity_type' => 'node', 'label' => 'Tags', 'bundle' => 'article', - ); - field_create_instance($instance); + ))->save(); entity_get_form_display('node', 'article', 'default') - ->setComponent($instance['field_name'], array( + ->setComponent($this->field_name, array( 'type' => 'taxonomy_autocomplete', 'weight' => -4, )) ->save(); entity_get_display('node', 'article', 'default') - ->setComponent($instance['field_name'], array( + ->setComponent($this->field_name, array( 'type' => 'taxonomy_term_reference_link', 'weight' => 10, )) ->save(); entity_get_display('node', 'article', 'teaser') - ->setComponent($instance['field_name'], array( + ->setComponent($this->field_name, array( 'type' => 'taxonomy_term_reference_link', 'weight' => 10, )) diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyUnitTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyUnitTest.php index 909cbcb..fec21c3 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyUnitTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyUnitTest.php @@ -154,17 +154,15 @@ function testTaxonomyVocabularyLoadMultiple() { */ function testTaxonomyVocabularyChangeMachineName() { // Add a field instance to the vocabulary. - $field = array( + entity_create('field_entity', array( 'field_name' => 'field_test', 'type' => 'test_field', - ); - field_create_field($field); - $instance = array( + ))->save(); + entity_create('field_instance', array( 'field_name' => 'field_test', 'entity_type' => 'taxonomy_term', 'bundle' => $this->vocabulary->id(), - ); - field_create_instance($instance); + ))->save(); // Change the machine name. $old_name = $this->vocabulary->id(); @@ -188,15 +186,19 @@ function testUninstallReinstall() { // Fields and field instances attached to taxonomy term bundles should be // removed when the module is uninstalled. $this->field_name = drupal_strtolower($this->randomName() . '_field_name'); - $this->field_definition = array('field_name' => $this->field_name, 'type' => 'text', 'cardinality' => 4); - field_create_field($this->field_definition); + $this->field_definition = array( + 'field_name' => $this->field_name, + 'type' => 'text', + 'cardinality' => 4 + ); + 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'; @@ -209,7 +211,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..6158f07 100644 --- a/core/modules/telephone/lib/Drupal/telephone/Tests/TelephoneFieldTest.php +++ b/core/modules/telephone/lib/Drupal/telephone/Tests/TelephoneFieldTest.php @@ -53,19 +53,16 @@ function setUp() { function testTelephoneField() { // Add the telepone field to the article content type. - $field = array( + entity_create('field_entity', array( 'field_name' => 'field_telephone', 'type' => 'telephone', - ); - field_create_field($field); - - $instance = array( + ))->save(); + entity_create('field_instance', array( 'field_name' => 'field_telephone', 'label' => 'Telephone Number', 'entity_type' => 'node', 'bundle' => 'article', - ); - field_create_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..bd3633b 100644 --- a/core/modules/telephone/lib/Drupal/telephone/Tests/TelephoneItemTest.php +++ b/core/modules/telephone/lib/Drupal/telephone/Tests/TelephoneItemTest.php @@ -35,17 +35,15 @@ public function setUp() { parent::setUp(); // Create a telephone field and instance for validation. - $this->field = array( + entity_create('field_entity', array( 'field_name' => 'field_test', 'type' => 'telephone', - ); - field_create_field($this->field); - $this->instance = array( + ))->save(); + entity_create('field_instance', array( 'entity_type' => 'entity_test', 'field_name' => 'field_test', 'bundle' => 'entity_test', - ); - field_create_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 0ecec7b..0a2b900 100644 --- a/core/modules/text/lib/Drupal/text/Tests/Formatter/TextPlainUnitTest.php +++ b/core/modules/text/lib/Drupal/text/Tests/Formatter/TextPlainUnitTest.php @@ -67,21 +67,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 86368d0..59e01e9 100644 --- a/core/modules/text/lib/Drupal/text/Tests/TextFieldTest.php +++ b/core/modules/text/lib/Drupal/text/Tests/TextFieldTest.php @@ -23,7 +23,6 @@ class TextFieldTest extends WebTestBase { */ public static $modules = array('entity_test'); - protected $instance; protected $admin_user; protected $web_user; @@ -51,26 +50,25 @@ function setUp() { function testTextFieldValidation() { // Create a field with settings to validate. $max_length = 3; - $this->field = array( + $this->field = entity_create('field_entity', array( 'field_name' => drupal_strtolower($this->randomName()), 'type' => 'text', 'settings' => array( 'max_length' => $max_length, ) - ); - field_create_field($this->field); - $this->instance = array( - 'field_name' => $this->field['field_name'], + )); + $this->field->save(); + entity_create('field_instance', array( + 'field_name' => $this->field->id(), 'entity_type' => 'entity_test', 'bundle' => 'entity_test', - ); - field_create_instance($this->instance); + ))->save(); // Test valid and invalid values with field_attach_validate(). $entity = entity_create('entity_test', array()); $langcode = Language::LANGCODE_NOT_SPECIFIED; for ($i = 0; $i <= $max_length + 2; $i++) { - $entity->{$this->field['field_name']}->value = str_repeat('x', $i); + $entity->{$this->field->id()}->value = str_repeat('x', $i); try { field_attach_validate($entity); $this->assertTrue($i <= $max_length, "Length $i does not cause validation error when max_length is $max_length"); @@ -96,9 +94,12 @@ function _testTextfieldWidgets($field_type, $widget_type) { // Setup a field and instance $entity_type = 'entity_test'; $this->field_name = drupal_strtolower($this->randomName()); - $this->field = array('field_name' => $this->field_name, 'type' => $field_type); - field_create_field($this->field); - $this->instance = array( + $this->field = entity_create('field_entity', array( + 'field_name' => $this->field_name, + 'type' => $field_type + )); + $this->field->save(); + entity_create('field_instance', array( 'field_name' => $this->field_name, 'entity_type' => 'entity_test', 'bundle' => 'entity_test', @@ -106,8 +107,7 @@ function _testTextfieldWidgets($field_type, $widget_type) { 'settings' => array( 'text_processing' => TRUE, ), - ); - field_create_instance($this->instance); + ))->save(); entity_get_form_display('entity_test', 'entity_test', 'default') ->setComponent($this->field_name, array( 'type' => $widget_type, @@ -162,9 +162,12 @@ function testTextfieldWidgetsFormatted() { function _testTextfieldWidgetsFormatted($field_type, $widget_type) { // Setup a field and instance $this->field_name = drupal_strtolower($this->randomName()); - $this->field = array('field_name' => $this->field_name, 'type' => $field_type); - field_create_field($this->field); - $this->instance = array( + $this->field = entity_create('field_entity', array( + 'field_name' => $this->field_name, + 'type' => $field_type + )); + $this->field->save(); + entity_create('field_instance', array( 'field_name' => $this->field_name, 'entity_type' => 'entity_test', 'bundle' => 'entity_test', @@ -172,8 +175,7 @@ function _testTextfieldWidgetsFormatted($field_type, $widget_type) { 'settings' => array( 'text_processing' => TRUE, ), - ); - field_create_instance($this->instance); + ))->save(); entity_get_form_display('entity_test', 'entity_test', '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..2bedb35 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 @@ -56,15 +56,14 @@ protected function setupTestFields() { $this->fieldName = 'field_test_et_ui_image'; $this->cardinality = 3; - $field = array( + entity_create('field_entity', array( 'field_name' => $this->fieldName, 'type' => 'image', 'cardinality' => $this->cardinality, 'translatable' => TRUE, - ); - field_create_field($field); + ))->save(); - $instance = array( + entity_create('field_instance', array( 'entity_type' => $this->entityType, 'field_name' => $this->fieldName, 'bundle' => $this->entityType, @@ -76,8 +75,7 @@ protected function setupTestFields() { 'title' => 'title', ), ), - ); - field_create_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 31592c7..4ceb6c4 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 @@ -161,21 +161,18 @@ protected function enableTranslation() { protected function setupTestFields() { $this->fieldName = 'field_test_et_ui_test'; - $field = array( + entity_create('field_entity', array( 'field_name' => $this->fieldName, 'type' => 'text', 'cardinality' => 1, 'translatable' => TRUE, - ); - field_create_field($field); - - $instance = array( + ))->save(); + entity_create('field_instance', array( 'entity_type' => $this->entityType, 'field_name' => $this->fieldName, 'bundle' => $this->bundle, 'label' => 'Test translatable text-field', - ); - field_create_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 dd7874c..57bb727 100644 --- a/core/modules/translation_entity/translation_entity.admin.inc +++ b/core/modules/translation_entity/translation_entity.admin.inc @@ -462,7 +462,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 bbe6605..5800198 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(); } } }