function _field_create_entity_from_ids

Assembles a partial entity structure with initial IDs.

Parameters

stdClass $ids: An object with the properties entity_type (required), entity_id (required), revision_id (optional) and bundle (optional).

Return value

\Drupal\Core\Entity\EntityInterface An entity, initialized with the provided IDs.

5 calls to _field_create_entity_from_ids()
BulkDeleteTest::convertToPartialEntities in drupal/core/modules/field/lib/Drupal/field/Tests/BulkDeleteTest.php
Converts the passed entities to partially created ones.
BulkDeleteTest::testDeleteFieldInstance in drupal/core/modules/field/lib/Drupal/field/Tests/BulkDeleteTest.php
Verify that deleting an instance leaves the field data items in the database and that the appropriate Field API functions can operate on the deleted data and instance.
EfqTest::testTaxonomyEfq in drupal/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/EfqTest.php
Tests that a basic taxonomy entity query works.
field_purge_batch in drupal/core/modules/field/field.crud.inc
Purges a batch of deleted Field API data, instances, or fields.
field_ui_field_edit_form in drupal/core/modules/field_ui/field_ui.admin.inc
Form constructor for the field instance settings form.

File

drupal/core/modules/field/field.module, line 1278
Attach custom data fields to Drupal entities.

Code

function _field_create_entity_from_ids($ids) {
  $id_properties = array();
  $info = entity_get_info($ids->entity_type);
  $id_properties[$info['entity_keys']['id']] = $ids->entity_id;
  if (!empty($info['entity_keys']['revision']) && isset($ids->revision_id)) {
    $id_properties[$info['entity_keys']['revision']] = $ids->revision_id;
  }
  if (!empty($info['entity_keys']['bundle']) && isset($ids->bundle)) {
    $id_properties[$info['entity_keys']['bundle']] = $ids->bundle;
  }
  return entity_create($ids->entity_type, $id_properties);
}