protected function ServicesEntityResourceControllerClean::createWrapperFromValues in Services Entity API 7.2
Helper function to create a wrapped entity from provided data values.
@todo the created wrapper should probably be statically cached, so we don't have to build it twice (first on access() and again on create()).
Parameters
$entity_type: The type of entity to be created.
$values: Array of data property values.
Return value
EntityDrupalWrapper The wrapped entity.
2 calls to ServicesEntityResourceControllerClean::createWrapperFromValues()
File
- plugins/
services_entity_resource_clean.inc, line 291
Class
- ServicesEntityResourceControllerClean
- This class is designed to create a very clean API that integrates with the services and entity modules. We want to strip all "drupalisms" out of the API. For example, there should be no [LANGUAGE_NONE][0][value] or field_ in the API.
Code
protected function createWrapperFromValues($entity_type, array &$values) {
$property_info = entity_get_all_property_info($entity_type);
$values = $this
->transform_values($entity_type, $property_info, $values);
try {
$wrapper = entity_property_values_create_entity($entity_type, $values);
} catch (EntityMetadataWrapperException $e) {
services_error($e
->getMessage(), 406);
}
return $wrapper;
}