protected function JsonBlueprintDenormalizer::fillDefaults in Subrequests 3.x
Same name and namespace in other branches
- 8.2 src/Normalizer/JsonBlueprintDenormalizer.php \Drupal\subrequests\Normalizer\JsonBlueprintDenormalizer::fillDefaults()
Fill the defaults.
Parameters
array $raw_item: The object to turn into a Subrequest input.
Return value
array The complete Subrequest.
File
- src/
Normalizer/ JsonBlueprintDenormalizer.php, line 130
Class
- JsonBlueprintDenormalizer
- Denormalizer that builds the blueprint based on the incoming blueprint.
Namespace
Drupal\subrequests\NormalizerCode
protected function fillDefaults($raw_item) {
if (empty($raw_item['requestId'])) {
$uuid = new Php();
$raw_item['requestId'] = $uuid
->generate();
}
if (!isset($raw_item['body'])) {
$raw_item['body'] = NULL;
}
elseif (!empty($raw_item['body'])) {
$raw_item['body'] = Json::decode($raw_item['body']);
}
$raw_item['headers'] = !empty($raw_item['headers']) ? $raw_item['headers'] : [];
$raw_item['waitFor'] = !empty($raw_item['waitFor']) ? $raw_item['waitFor'] : [
'<ROOT>',
];
$raw_item['_resolved'] = FALSE;
// Detect if there is an encoded token. If so, then decode the URI.
if (!empty($raw_item['uri']) && strpos($raw_item['uri'], '%7B%7B') !== FALSE && strpos($raw_item['uri'], '%7D%7D') !== FALSE) {
$raw_item['uri'] = urldecode($raw_item['uri']);
}
return $raw_item;
}