1 field.test protected FieldBulkDeleteTestCase::convertToPartialEntities($entities, $field_name)

Converts the passed entities to partially created ones.

This replicates the partial entities created in field_purge_data_batch(), which only have the ids and the to be deleted field defined. *

Parameters

$entities: An array of entities of type test_entity.

$field_name: A field name whose data should be copied from $entities into the returned partial entities. * @return array An array of partial entities corresponding to $entities.

File

core/modules/field/tests/field.test, line 3232
Tests for field.module.

Class

FieldBulkDeleteTestCase
Unit test class for field bulk delete and batch purge functionality.

Code

protected function convertToPartialEntities($entities, $field_name) {
  $partial_entities = array();
  foreach ($entities as $id => $entity) {
    // Re-create the entity with only the required keys, remove label as that
    // is not present when using _field_create_entity_from_ids().
    $partial_entities[$id] = field_test_create_entity($entity->ftid, $entity->ftvid, $entity->fttype, $entity->ftlabel);
    unset($partial_entities[$id]->ftlabel);
    $partial_entities[$id]->$field_name = $entity->$field_name;
  }
  return $partial_entities;
}