protected function Request::fixQueryFields in RESTful 7.2
Helps fixing the fields to ensure that dot-notation makes sense.
Make sure to add all of the parents for the dot-notation sparse fieldsets. fields=active,image.category.name,image.description becomes fields=active,image,image.category,image.category.name,image.description
Parameters
array $input: The parsed input to fix.
Return value
array The parsed input array.
1 call to Request::fixQueryFields()
- Request::__construct in src/
Http/ Request.php - Constructor.
File
- src/
Http/ Request.php, line 360 - Contains \Drupal\restful\Http\Request
Class
- Request
- Deals with everything coming from the consumer.
Namespace
Drupal\restful\HttpCode
protected function fixQueryFields(array $input) {
// Make sure that we include all the parents for full linkage.
foreach (array(
'fields',
'include',
) as $key_name) {
if (empty($input[$key_name])) {
continue;
}
$added_keys = array();
foreach (explode(',', $input[$key_name]) as $key) {
$parts = explode('.', $key);
for ($index = 0; $index < count($parts); $index++) {
$path = implode('.', array_slice($parts, 0, $index + 1));
$added_keys[$path] = TRUE;
}
}
$input[$key_name] = implode(',', array_keys(array_filter($added_keys))) ?: NULL;
}
return $input;
}