function _jsonapi_defaults_convert_value in JSON:API Extras 8.3
Convert default parameters value to raw value (textarea).
Parameters
array|null $value: Value from config.
Return value
string Value to be shown in textarea.
1 call to _jsonapi_defaults_convert_value()
- _jsonapi_defaults_form_alter in modules/
jsonapi_defaults/ jsonapi_defaults.module - Build JSON API Defaults part of the form.
File
- modules/
jsonapi_defaults/ jsonapi_defaults.module, line 184 - Contains module related hooks.
Code
function _jsonapi_defaults_convert_value($value) {
$raw_value = '';
if (is_array($value)) {
foreach ($value as $key => $val) {
if ($key == 'include') {
$raw_value .= "{$key}={$val}\n";
}
elseif (preg_match('/^filter.+/', $key)) {
$key = implode('][', explode('#', preg_replace('/^filter:/', '', $key)));
$raw_value .= "filter[{$key}]={$val}\n";
}
elseif (preg_match('/^sort.+/', $key)) {
$key = implode('][', explode('#', preg_replace('/^sort:/', '', $key)));
$raw_value .= "sort[{$key}]={$val}\n";
}
}
}
return $raw_value;
}