protected function ServicesEntityResourceControllerClean::transform_values in Services Entity API 7.2
Checks for field_ prefix for each field and adds it if necessary.
Parameters
type $values:
Return value
type
3 calls to ServicesEntityResourceControllerClean::transform_values()
- ServicesEntityResourceControllerClean::createWrapperFromValues in plugins/
services_entity_resource_clean.inc - Helper function to create a wrapped entity from provided data values.
- ServicesEntityResourceControllerClean::index in plugins/
services_entity_resource_clean.inc - Implements ServicesResourceControllerInterface::index().
- ServicesEntityResourceControllerClean::update in plugins/
services_entity_resource_clean.inc - Implements ServicesResourceControllerInterface::update().
File
- plugins/
services_entity_resource_clean.inc, line 247
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 transform_values($entity_type, $property_info, $values) {
foreach ($values as $key => $value) {
// Handle Resource references so we can pass pack the object.
if (is_array($value) && isset($value['id'])) {
$values[$key] = $value['id'];
}
// Check if this is actually a field_ value
if (isset($property_info['field_' . $key])) {
$values['field_' . $key] = $values[$key];
unset($values[$key]);
}
}
return $values;
}