protected function ServicesEntityResourceControllerClean::property_access_filter in Services Entity API 7.2
Filters out properties where view access is not allowed for the current user.
Parameters
EntityMetadataWrapper $wrapper: EntityMetadataWrapper that should be checked.
Return value
An array of properties where access is allowed, keyed by their property name.
1 call to ServicesEntityResourceControllerClean::property_access_filter()
- ServicesEntityResourceControllerClean::get_data in plugins/
services_entity_resource_clean.inc - Return the data structure for an entity stripped of all "drupalisms" such as field_ and complex data arrays.
File
- plugins/
services_entity_resource_clean.inc, line 222
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 property_access_filter($wrapper) {
$filtered = array();
foreach ($wrapper as $name => $property) {
try {
if ($property
->access('view')) {
$filtered[$name] = $property;
}
} catch (EntityMetaDataWrapperException $e) {
// Log the exception and ignore the property. This is known to happen
// when attempting to access the 'book' property of a non-book node.
// In such cases Entity API erroneously throws an exception.
// @see https://drupal.org/node/2051087 and linked issues.
watchdog('services_entity', 'Exception testing access to property @p: @e', array(
'@p' => $name,
'@e' => $e
->getMessage(),
), WATCHDOG_WARNING);
}
}
return $filtered;
}