Commit ba6591cd authored by catch's avatar catch

Issue #2018319 by yched, swentel, pcambra: Remove field_read_field(s)() and...

Issue #2018319 by yched, swentel, pcambra: Remove field_read_field(s)() and field_read_instance(s) in favor of entity_load() and entity_load_multiple_by_properties().
parent 255d7304
......@@ -1185,7 +1185,7 @@ public function onBundleRename($bundle, $bundle_new) {
// We need to account for deleted fields and instances. The method runs
// before the instance definitions are updated, so we need to fetch them
// using the old bundle name.
$instances = field_read_instances(array('entity_type' => $this->entityType, 'bundle' => $bundle), array('include_deleted' => TRUE));
$instances = entity_load_multiple_by_properties('field_instance', array('entity_type' => $this->entityType, 'bundle' => $bundle, 'include_deleted' => TRUE));
foreach ($instances as $instance) {
$field = $instance->getField();
$table_name = static::_fieldTableName($field);
......
......@@ -198,10 +198,8 @@ function field_info_field_map() {
* non-deleted field. For deleted fields, use field_info_field_by_id().
*
* @return
* The field array, as returned by field_read_fields(), with an
* additional element 'bundles', whose value is an array of all the bundles
* this field belongs to keyed by entity type. NULL if the field was not
* found.
* The \Drupal\field\FieldInterface field definition, as returned by
* entity_load_multiple_by_properties(), NULL if the field was not found.
*
* @see field_info_field_by_id()
......@@ -219,9 +217,8 @@ function field_info_field($entity_type, $field_name) {
* The ID of the field to retrieve. $field_id can refer to a deleted field.
*
* @return
* The field array, as returned by field_read_fields(), with an additional
* element 'bundles', whose value is an array of all the bundles this field
* belongs to.
* The \Drupal\field\FieldInterface field definition, as returned by
* entity_load_multiple_by_properties(), NULL if the field was not found.
*
* @see field_info_field()
*
......@@ -239,13 +236,11 @@ function field_info_field_by_id($field_id) {
* statically caches a potentially large array of information.
*
* When iterating over the fields present in a given bundle after a call to
* field_info_instances($entity_type, $bundle), it is recommended to use
* field_info_field() on each individual field instead.
* field_info_instances($entity_type, $bundle), it is recommended to use the
* getField() method on each $instance instead.
*
* @return
* An array, each key is a field ID and the values are field arrays as
* returned by field_read_fields(), with an additional element 'bundles',
* whose value is an array of all the bundle this field belongs to.
* @return \Drupal\field\FieldInterface[]
* An array of FieldInterface configuration entities, keyed by UUID.
*
* @see field_info_field()
* @see field_info_field_by_id()
......
......@@ -153,9 +153,10 @@ function field_cron() {
* required if there are any active fields of that type.
*/
function field_system_info_alter(&$info, $file, $type) {
// It is not safe to call field_read_fields() during maintenance mode.
// It is not safe to call entity_load_multiple_by_properties() during
// maintenance mode.
if ($type == 'module' && !defined('MAINTENANCE_MODE')) {
$fields = field_read_fields(array('module' => $file->name), array('include_deleted' => TRUE));
$fields = entity_load_multiple_by_properties('field_entity', array('module' => $file->name, 'include_deleted' => TRUE));
if ($fields) {
$info['required'] = TRUE;
......@@ -222,10 +223,10 @@ function field_entity_bundle_create($entity_type, $bundle) {
* Implements hook_entity_bundle_rename().
*/
function field_entity_bundle_rename($entity_type, $bundle_old, $bundle_new) {
$instances = field_read_instances();
$instances = entity_load_multiple_by_properties('field_instance', array('entity_type' => $entity_type, 'bundle' => $bundle_old));
foreach ($instances as $instance) {
if ($instance->entity_type == $entity_type && $instance->bundle == $bundle_old) {
$id_new = $instance->entity_type . '.' . $bundle_new . '.' . $instance->getName();
$id_new = $instance->entity_type . '.' . $bundle_new . '.' . $instance->field_name;
$instance->id = $id_new;
$instance->bundle = $bundle_new;
$instance->allowBundleRename();
......@@ -248,10 +249,10 @@ function field_entity_bundle_rename($entity_type, $bundle_old, $bundle_new) {
* simple DELETE query).
*/
function field_entity_bundle_delete($entity_type, $bundle) {
// Get the instances on the bundle. field_read_instances() must be used
// here since field_info_instances() does not return instances for disabled
// entity types or bundles.
$instances = field_read_instances(array('entity_type' => $entity_type, 'bundle' => $bundle));
// Get the instances on the bundle. entity_load_multiple_by_properties() must
// be used here since field_info_instances() does not return instances for
// disabled entity types or bundles.
$instances = entity_load_multiple_by_properties('field_instance', array('entity_type' => $entity_type, 'bundle' => $bundle));
foreach ($instances as $instance) {
$instance->delete();
}
......
......@@ -72,7 +72,7 @@
function field_purge_batch($batch_size) {
// Retrieve all deleted field instances. We cannot use field_info_instances()
// because that function does not return deleted instances.
$instances = field_read_instances(array('deleted' => TRUE), array('include_deleted' => TRUE));
$instances = entity_load_multiple_by_properties('field_instance', array('deleted' => TRUE, 'include_deleted' => TRUE));
$factory = \Drupal::service('entity.query');
$info = entity_get_info();
foreach ($instances as $instance) {
......@@ -130,7 +130,7 @@ function field_purge_batch($batch_size) {
continue;
}
$instances = field_read_instances(array('field_id' => $field->uuid()), array('include_deleted' => 1));
$instances = entity_load_multiple_by_properties('field_instance', array('field_id' => $field->uuid(), 'include_deleted' => TRUE));
if (empty($instances)) {
field_purge_field($field);
}
......@@ -169,7 +169,7 @@ function field_purge_instance($instance) {
* The field record to purge.
*/
function field_purge_field($field) {
$instances = field_read_instances(array('field_id' => $field->uuid()), array('include_deleted' => 1));
$instances = entity_load_multiple_by_properties('field_instance', array('field_id' => $field->uuid(), 'include_deleted' => TRUE));
if (count($instances) > 0) {
throw new FieldException(t('Attempt to purge a field @field_name that still has instances.', array('@field_name' => $field->getName())));
}
......
......@@ -231,7 +231,7 @@ public function getFields() {
}
else {
// Collect and prepare fields.
foreach (field_read_fields(array(), array('include_deleted' => TRUE)) as $field) {
foreach (entity_load_multiple_by_properties('field_entity', array('include_deleted' => TRUE)) as $field) {
$this->fieldsById[$field->uuid()] = $this->prepareField($field);
}
......@@ -277,7 +277,7 @@ public function getInstances($entity_type = NULL) {
// be set by subsequent getBundleInstances() calls.
$this->getFields();
foreach (field_read_instances() as $instance) {
foreach (entity_load_multiple('field_instance') as $instance) {
$instance = $this->prepareInstance($instance);
$this->bundleInstances[$instance->entity_type][$instance->bundle][$instance->getName()] = $instance;
}
......@@ -359,7 +359,7 @@ public function getFieldById($field_id) {
// bundle.
// Cache miss: read from definition.
if ($fields = field_read_fields(array('uuid' => $field_id), array('include_deleted' => TRUE))) {
if ($fields = entity_load_multiple_by_properties('field_entity', array('uuid' => $field_id, 'include_deleted' => TRUE))) {
$field = current($fields);
$field = $this->prepareField($field);
......
......@@ -164,8 +164,6 @@ public function loadByProperties(array $conditions = array()) {
}
}
$this->moduleHandler->invokeAll('field_read_instance', $instance);
$matching_instances[] = $instance;
}
......
......@@ -138,8 +138,6 @@ public function loadByProperties(array $conditions = array()) {
}
}
$this->moduleHandler->invokeAll('field_read_field', $field);
// When returning deleted fields, key the results by UUID since they can
// include several fields with the same ID.
$key = $include_deleted ? $field->uuid : $field->id;
......
......@@ -180,7 +180,7 @@ function testDeleteFieldInstance() {
$instance->delete();
// The instance still exists, deleted.
$instances = field_read_instances(array('field_id' => $field->uuid, 'deleted' => TRUE), array('include_deleted' => TRUE));
$instances = entity_load_multiple_by_properties('field_instance', array('field_id' => $field->uuid, 'deleted' => TRUE, 'include_deleted' => TRUE));
$this->assertEqual(count($instances), 1, 'There is one deleted instance');
$instance = $instances[0];
$this->assertEqual($instance->bundle, $bundle, 'The deleted instance is for the correct bundle');
......@@ -258,18 +258,18 @@ function testPurgeInstance() {
$this->checkHooksInvocations($hooks, $actual_hooks);
// The instance still exists, deleted.
$instances = field_read_instances(array('field_id' => $field->uuid, 'deleted' => TRUE), array('include_deleted' => TRUE));
$instances = entity_load_multiple_by_properties('field_instance', array('field_id' => $field->uuid, 'deleted' => TRUE, 'include_deleted' => TRUE));
$this->assertEqual(count($instances), 1, 'There is one deleted instance');
// Purge the instance.
field_purge_batch($batch_size);
// The instance is gone.
$instances = field_read_instances(array('field_id' => $field->uuid, 'deleted' => TRUE), array('include_deleted' => TRUE));
$instances = entity_load_multiple_by_properties('field_instance', array('field_id' => $field->uuid, 'deleted' => TRUE, 'include_deleted' => TRUE));
$this->assertEqual(count($instances), 0, 'The instance is gone');
// The field still exists, not deleted, because it has a second instance.
$fields = field_read_fields(array('uuid' => $field->uuid), array('include_deleted' => TRUE));
$fields = entity_load_multiple_by_properties('field_entity', array('uuid' => $field->uuid, 'include_deleted' => TRUE));
$this->assertTrue(isset($fields[$field->uuid]), 'The field exists and is not deleted');
}
......@@ -310,7 +310,7 @@ function testPurgeField() {
field_purge_batch(0);
// The field still exists, not deleted.
$fields = field_read_fields(array('uuid' => $field->uuid), array('include_deleted' => TRUE));
$fields = entity_load_multiple_by_properties('field_entity', array('uuid' => $field->uuid, 'include_deleted' => TRUE));
$this->assertTrue(isset($fields[$field->uuid]) && !$fields[$field->uuid]->deleted, 'The field exists and is not deleted');
// Delete the second instance.
......@@ -335,14 +335,14 @@ function testPurgeField() {
$this->checkHooksInvocations($hooks, $actual_hooks);
// The field still exists, deleted.
$fields = field_read_fields(array('uuid' => $field->uuid), array('include_deleted' => TRUE));
$fields = entity_load_multiple_by_properties('field_entity', array('uuid' => $field->uuid, 'include_deleted' => TRUE));
$this->assertTrue(isset($fields[$field->uuid]) && $fields[$field->uuid]->deleted, 'The field exists and is deleted');
// Purge again to purge the instance and the field.
field_purge_batch(0);
// The field is gone.
$fields = field_read_fields(array('uuid' => $field->uuid), array('include_deleted' => TRUE));
$fields = entity_load_multiple_by_properties('field_entity', array('uuid' => $field->uuid, 'include_deleted' => TRUE));
$this->assertEqual(count($fields), 0, 'The field is purged.');
}
......
......@@ -203,13 +203,13 @@ function testReadFields() {
$id = $field->id();
// Check that 'single column' criteria works.
$fields = field_read_fields(array('id' => $id));
$fields = entity_load_multiple_by_properties('field_entity', array('field_name' => $field_definition['name']));
$this->assertTrue(count($fields) == 1 && isset($fields[$id]), 'The field was properly read.');
// Check that 'multi column' criteria works.
$fields = field_read_fields(array('id' => $id, 'type' => $field_definition['type']));
$fields = entity_load_multiple_by_properties('field_entity', array('field_name' => $field_definition['name'], 'type' => $field_definition['type']));
$this->assertTrue(count($fields) == 1 && isset($fields[$id]), 'The field was properly read.');
$fields = field_read_fields(array('name' => $field_definition['name'], 'type' => 'foo'));
$fields = entity_load_multiple_by_properties('field_entity', array('field_name' => $field_definition['name'], 'type' => 'foo'));
$this->assertTrue(empty($fields), 'No field was found.');
// Create an instance of the field.
......@@ -309,41 +309,41 @@ function testDeleteField() {
entity_create('field_instance', $another_instance_definition)->save();
// Test that the first field is not deleted, and then delete it.
$field = field_read_field('entity_test', $this->field['name'], array('include_deleted' => TRUE));
$field = current(entity_load_multiple_by_properties('field_entity', array('field_name' => $this->field['name'], 'include_deleted' => TRUE)));
$this->assertTrue(!empty($field) && empty($field->deleted), 'A new field is not marked for deletion.');
field_info_field('entity_test', $this->field['name'])->delete();
// Make sure that the field is marked as deleted when it is specifically
// loaded.
$field = field_read_field('entity_test', $this->field['name'], array('include_deleted' => TRUE));
$field = current(entity_load_multiple_by_properties('field_entity', array('field_name' => $this->field['name'], 'include_deleted' => TRUE)));
$this->assertTrue(!empty($field->deleted), 'A deleted field is marked for deletion.');
// Make sure that this field's instance is marked as deleted when it is
// specifically loaded.
$instance = field_read_instance('entity_test', $this->instance_definition['field_name'], $this->instance_definition['bundle'], array('include_deleted' => TRUE));
$instance = current(entity_load_multiple_by_properties('field_instance', array('entity_type' => 'entity_test', 'field_name' => $this->instance_definition['field_name'], 'bundle' => $this->instance_definition['bundle'], 'include_deleted' => TRUE)));
$this->assertTrue(!empty($instance->deleted), 'An instance for a deleted field is marked for deletion.');
// Try to load the field normally and make sure it does not show up.
$field = field_read_field('entity_test', $this->field['name']);
$field = entity_load('field_entity', 'entity_test.' . $this->field['name']);
$this->assertTrue(empty($field), 'A deleted field is not loaded by default.');
// Try to load the instance normally and make sure it does not show up.
$instance = field_read_instance('entity_test', $this->instance_definition['field_name'], $this->instance_definition['bundle']);
$instance = entity_load('field_instance', 'entity_test.' . '.' . $this->instance_definition['bundle'] . '.' . $this->instance_definition['field_name']);
$this->assertTrue(empty($instance), 'An instance for a deleted field is not loaded by default.');
// Make sure the other field (and its field instance) are not deleted.
$another_field = field_read_field('entity_test', $this->another_field['name']);
$another_field = entity_load('field_entity', 'entity_test.' . $this->another_field['name']);
$this->assertTrue(!empty($another_field) && empty($another_field->deleted), 'A non-deleted field is not marked for deletion.');
$another_instance = field_read_instance('entity_test', $another_instance_definition['field_name'], $another_instance_definition['bundle']);
$another_instance = entity_load('field_instance', 'entity_test.' . $another_instance_definition['bundle'] . '.' . $another_instance_definition['field_name']);
$this->assertTrue(!empty($another_instance) && empty($another_instance->deleted), 'An instance of a non-deleted field is not marked for deletion.');
// Try to create a new field the same name as a deleted field and
// write data into it.
entity_create('field_entity', $this->field)->save();
entity_create('field_instance', $this->instance_definition)->save();
$field = field_read_field('entity_test', $this->field['name']);
$field = entity_load('field_entity', 'entity_test.' . $this->field['name']);
$this->assertTrue(!empty($field) && empty($field->deleted), 'A new field with a previously used name is created.');
$instance = field_read_instance('entity_test', $this->instance_definition['field_name'], $this->instance_definition['bundle']);
$instance = entity_load('field_instance', 'entity_test.' . $this->instance_definition['bundle'] . '.' . $this->instance_definition['field_name'] );
$this->assertTrue(!empty($instance) && empty($instance->deleted), 'A new instance for a previously used field name is created.');
// Save an entity with data for the field
......
......@@ -396,9 +396,9 @@ function testEntityDeleteBundle() {
$this->assertTrue(empty($entity->{$this->field_name}), 'No data for first field');
$this->assertTrue(empty($entity->{$field_name}), 'No data for second field');
// Verify that the instances are gone
$this->assertFalse(field_read_instance('entity_test', $this->field_name, $new_bundle), "First field is deleted");
$this->assertFalse(field_read_instance('entity_test', $field_name, $new_bundle), "Second field is deleted");
// Verify that the instances are gone.
$this->assertFalse(entity_load('field_instance', 'entity_test.' . $this->instance->bundle . '.' . $this->field_name), "First field is deleted");
$this->assertFalse(entity_load('field_instance', 'entity_test.' . $instance['bundle']. '.' . $field_name), "Second field is deleted");
}
}
......@@ -114,7 +114,7 @@ function testReadFieldInstance() {
entity_create('field_instance', $this->instance_definition)->save();
// Read the instance back.
$instance = field_read_instance('entity_test', $this->instance_definition['field_name'], $this->instance_definition['bundle']);
$instance = entity_load('field_instance', 'entity_test.' . $this->instance_definition['bundle'] . '.' . $this->instance_definition['field_name']);
$this->assertTrue($this->instance_definition['field_name'] == $instance->getName(), 'The field was properly read.');
$this->assertTrue($this->instance_definition['entity_type'] == $instance->entity_type, 'The field was properly read.');
$this->assertTrue($this->instance_definition['bundle'] == $instance->bundle, 'The field was properly read.');
......@@ -127,14 +127,14 @@ function testUpdateFieldInstance() {
entity_create('field_instance', $this->instance_definition)->save();
// Check that basic changes are saved.
$instance = field_read_instance('entity_test', $this->instance_definition['field_name'], $this->instance_definition['bundle']);
$instance = entity_load('field_instance', 'entity_test.' . $this->instance_definition['bundle'] . '.' . $this->instance_definition['field_name']);
$instance->required = !$instance->isRequired();
$instance->label = $this->randomName();
$instance->description = $this->randomName();
$instance->settings['test_instance_setting'] = $this->randomName();
$instance->save();
$instance_new = field_read_instance('entity_test', $this->instance_definition['field_name'], $this->instance_definition['bundle']);
$instance_new = entity_load('field_instance', 'entity_test.' . $this->instance_definition['bundle'] . '.' . $this->instance_definition['field_name']);
$this->assertEqual($instance->isRequired(), $instance_new->isRequired(), '"required" change is saved');
$this->assertEqual($instance->getLabel(), $instance_new->getLabel(), '"label" change is saved');
$this->assertEqual($instance->getDescription(), $instance_new->getDescription(), '"description" change is saved');
......@@ -158,21 +158,21 @@ function testDeleteFieldInstance() {
entity_create('field_instance', $another_instance_definition)->save();
// Test that the first instance is not deleted, and then delete it.
$instance = field_read_instance('entity_test', $this->instance_definition['field_name'], $this->instance_definition['bundle'], array('include_deleted' => TRUE));
$instance = current(entity_load_multiple_by_properties('field_instance', array('entity_type' => 'entity_test', 'field_name' => $this->instance_definition['field_name'], 'bundle' => $this->instance_definition['bundle'], 'include_deleted' => TRUE)));
$this->assertTrue(!empty($instance) && empty($instance->deleted), 'A new field instance is not marked for deletion.');
$instance->delete();
// Make sure the instance is marked as deleted when the instance is
// specifically loaded.
$instance = field_read_instance('entity_test', $this->instance_definition['field_name'], $this->instance_definition['bundle'], array('include_deleted' => TRUE));
$instance = current(entity_load_multiple_by_properties('field_instance', array('entity_type' => 'entity_test', 'field_name' => $this->instance_definition['field_name'], 'bundle' => $this->instance_definition['bundle'], 'include_deleted' => TRUE)));
$this->assertTrue(!empty($instance->deleted), 'A deleted field instance is marked for deletion.');
// Try to load the instance normally and make sure it does not show up.
$instance = field_read_instance('entity_test', $this->instance_definition['field_name'], $this->instance_definition['bundle']);
$instance = entity_load('field_instance', 'entity_test.' . '.' . $this->instance_definition['bundle'] . '.' . $this->instance_definition['field_name']);
$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('entity_test', $another_instance_definition['field_name'], $another_instance_definition['bundle']);
$another_instance = entity_load('field_instance', 'entity_test.' . $another_instance_definition['bundle'] . '.' . $another_instance_definition['field_name']);
$this->assertTrue(!empty($another_instance) && empty($another_instance->deleted), 'A non-deleted field instance is not marked for deletion.');
}
......
......@@ -94,7 +94,7 @@ function setUp() {
'translatable' => TRUE,
);
entity_create('field_entity', $this->field_definition)->save();
$this->field = field_read_field($this->entity_type, $this->field_name);
$this->field = entity_load('field_entity', $this->entity_type . '.' . $this->field_name);
$this->instance_definition = array(
'field_name' => $this->field_name,
......@@ -102,7 +102,7 @@ function setUp() {
'bundle' => 'entity_test',
);
entity_create('field_instance', $this->instance_definition)->save();
$this->instance = field_read_instance($this->entity_type, $this->field_name, $this->entity_type);
$this->instance = entity_load('field_instance', 'entity_test.' . $this->instance_definition['bundle'] . '.' . $this->field_name);
for ($i = 0; $i < 3; ++$i) {
$language = new Language(array(
......
......@@ -70,7 +70,7 @@ function setUp() {
'translatable' => TRUE,
);
entity_create('field_entity', $field)->save();
$this->field = field_read_field($this->entity_type, $this->field_name);
$this->field = entity_load('field_entity', $this->entity_type . '.' . $this->field_name);
$instance = array(
'field_name' => $this->field_name,
......@@ -78,7 +78,7 @@ function setUp() {
'bundle' => $this->entity_type,
);
entity_create('field_instance', $instance)->save();
$this->instance = field_read_instance($this->entity_type, $this->field_name, $this->entity_type);
$this->instance = entity_load('field_instance', 'entity_test.' . $instance['bundle'] . '.' . $this->field_name);
entity_get_form_display($this->entity_type, $this->entity_type, 'default')
->setComponent($this->field_name)
......
......@@ -444,7 +444,7 @@ function testHiddenFields() {
entity_get_form_display('node', $this->type, 'default')
->setComponent($field_name)
->save();
$this->assertTrue(field_read_instance('node', $field_name, $this->type), format_string('An instance of the field %field was created programmatically.', array('%field' => $field_name)));
$this->assertTrue(entity_load('field_instance', 'node.' . $this->type . '.' . $field_name), format_string('An instance of the field %field was created programmatically.', array('%field' => $field_name)));
// Check that the newly added instance appears on the 'Manage Fields'
// screen.
......
......@@ -145,29 +145,22 @@ public static function postDelete(EntityStorageControllerInterface $storage_cont
*/
protected static function replaceImageStyle(ImageStyleInterface $style) {
if ($style->id() != $style->getOriginalId()) {
// Loop through all fields searching for image fields.
foreach (field_read_instances() as $instance) {
if ($instance->getType() == 'image') {
$field_name = $instance->getName();
$view_modes = array('default') + array_keys(entity_get_view_modes($instance->entity_type));
foreach ($view_modes as $view_mode) {
$display = entity_get_display($instance->entity_type, $instance->bundle, $view_mode);
$display_options = $display->getComponent($field_name);
// Check if the formatter involves an image style.
if ($display_options && $display_options['type'] == 'image' && $display_options['settings']['image_style'] == $style->getOriginalId()) {
// Update display information for any instance using the image
// style that was just deleted.
$display_options['settings']['image_style'] = $style->id();
$display->setComponent($field_name, $display_options)
->save();
}
// Loop through all entity displays looking for formatters / widgets using
// the image style.
foreach (entity_load_multiple('entity_display') as $display) {
foreach ($display->getComponents() as $name => $options) {
if (isset($options['type']) && $options['type'] == 'image' && $options['settings']['image_style'] == $style->getOriginalId()) {
$options['settings']['image_style'] = $style->id();
$display->setComponent($name, $options)
->save();
}
$entity_form_display = entity_get_form_display($instance->entity_type, $instance->bundle, 'default');
$widget_configuration = $entity_form_display->getComponent($field_name);
if ($widget_configuration['settings']['preview_image_style'] == $style->getOriginalId()) {
$widget_options['settings']['preview_image_style'] = $style->id();
$entity_form_display->setComponent($field_name, $widget_options)
}
}
foreach (entity_load_multiple('entity_form_display') as $display) {
foreach ($display->getComponents() as $name => $options) {
if (isset($options['type']) && $options['type'] == 'image_image' && $options['settings']['preview_image_style'] == $style->getOriginalId()) {
$options['settings']['preview_image_style'] = $style->id();
$display->setComponent($name, $options)
->save();
}
}
......
......@@ -39,5 +39,5 @@ function node_access_test_language_install() {
* Implements hook_uninstall().
*/
function node_access_test_language_uninstall() {
field_read_instance('node', 'field_private', 'page')->delete();
entity_load('field_instance', 'node.page.field_private')->delete();
}
......@@ -75,7 +75,7 @@ function setUp() {
'entity_type' => $entity_type,
'bundle' => $entity_type,
))->save();
$this->instance[$entity_type] = field_read_instance($entity_type, $this->field_name, $entity_type);
$this->instance[$entity_type] = entity_load('field_instance', $entity_type . '.' . $entity_type . '.' . $this->field_name);;
entity_create('field_entity', array(
'name' => $this->untranslatable_field_name,
......
......@@ -110,7 +110,7 @@ public function postSave(EntityStorageControllerInterface $storage_controller, $
elseif ($this->getOriginalId() != $this->id()) {
// Reflect machine name changes in the definitions of existing 'taxonomy'
// fields.
$fields = field_read_fields();
$fields = entity_load_multiple('field_entity');
foreach ($fields as $field) {
$update_field = FALSE;
if ($field->getType() == 'taxonomy_term_reference') {
......@@ -153,7 +153,7 @@ public static function postDelete(EntityStorageControllerInterface $storage_cont
}
// Load all Taxonomy module fields and delete those which use only this
// vocabulary.
$taxonomy_fields = field_read_fields(array('module' => 'taxonomy'));
$taxonomy_fields = entity_load_multiple_by_properties('field_entity', array('module' => 'taxonomy'));
foreach ($taxonomy_fields as $taxonomy_field) {
$modified_field = FALSE;
// Term reference fields may reference terms from more than one
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment