function _jsonapi_defaults_convert_rawvalue in JSON:API Extras 8.3
Convert default parameters value to array (used in config).
Parameters
string|null $raw_value: Raw value from textarea.
Return value
array Value to be saved into config.
1 call to _jsonapi_defaults_convert_rawvalue()
- jsonapi_defaults_form_jsonapi_resource_config_form_builder in modules/
jsonapi_defaults/ jsonapi_defaults.module - Entity builder for json api resource configuration entity.
File
- modules/
jsonapi_defaults/ jsonapi_defaults.module, line 148 - Contains module related hooks.
Code
function _jsonapi_defaults_convert_rawvalue($raw_value) {
$value = [];
$raw_value = !is_string($raw_value) ? '' : $raw_value;
foreach (preg_split('/\\r\\n|[\\r\\n]/', $raw_value) as $param) {
if (strpos($param, '=') !== FALSE) {
$a = explode('=', $param);
$key = $a[0];
$val = $a[1];
if ($key == 'include') {
$value[$key] = trim($val);
}
elseif (preg_match('/^filter.+/', $key)) {
$key = str_replace('filter[', '', $key);
$key = explode('][', $key);
$value['filter:' . trim(implode('#', $key), '[]')] = $val;
}
elseif (preg_match('/^sort.+/', $key)) {
$key = str_replace('sort[', '', $key);
$key = explode('][', $key);
$value['sort:' . trim(implode('#', $key), '[]')] = $val;
}
}
}
return $value;
}