function entity_create_stub_entity
Helper function to assemble an object structure with initial ids.
This function can be seen as reciprocal to entity_extract_ids().
Parameters
$entity_type: The entity type; e.g. 'node' or 'user'.
$ids: A numerically indexed array, as returned by entity_extract_ids().
Return value
An entity structure, initialized with the ids provided.
See also
4 calls to entity_create_stub_entity()
- EntityFieldQuery::finishQuery in includes/
entity.inc - Finishes the query.
- FieldBulkDeleteTestCase::_generateStubEntities in modules/
field/ tests/ field.test - Convenience function for Field API tests.
- field_test_dummy_field_storage_query in modules/
field/ tests/ field_test.module - Pseudo-implements hook_field_storage_query().
- file_field_update in modules/
file/ file.field.inc - Implements hook_field_update().
File
-
includes/
common.inc, line 8125
Code
function entity_create_stub_entity($entity_type, $ids) {
$entity = new stdClass();
$info = entity_get_info($entity_type);
$entity->{$info['entity keys']['id']} = $ids[0];
if (!empty($info['entity keys']['revision']) && isset($ids[1])) {
$entity->{$info['entity keys']['revision']} = $ids[1];
}
if (!empty($info['entity keys']['bundle']) && isset($ids[2])) {
$entity->{$info['entity keys']['bundle']} = $ids[2];
}
return $entity;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.