Assembles a partial entity structure with initial IDs.
stdClass $ids: An object with the properties entity_type (required), entity_id (required), revision_id (optional) and bundle (optional).
\Drupal\Core\Entity\EntityInterface An entity, initialized with the provided IDs.
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);
}