protected function JsonPathReplacer::validateJsonPathReplacements in Subrequests 3.x
Same name and namespace in other branches
- 8.2 src/JsonPathReplacer.php \Drupal\subrequests\JsonPathReplacer::validateJsonPathReplacements()
Validates tha the JSONPath query yields a string or an array of strings.
Parameters
array $to_replace: The replacement candidates.
Throws
\Symfony\Component\HttpKernel\Exception\BadRequestHttpException When the replacements are not valid.
1 call to JsonPathReplacer::validateJsonPathReplacements()
- JsonPathReplacer::addReplacementsForSubject in src/
JsonPathReplacer.php - Fill replacement values for a subrequest a subject and an structured token.
File
- src/
JsonPathReplacer.php, line 384
Class
Namespace
Drupal\subrequestsCode
protected function validateJsonPathReplacements($to_replace) {
$is_valid = is_array($to_replace) && array_reduce($to_replace, function ($valid, $replacement) {
return $valid && (is_string($replacement) || is_int($replacement) || is_bool($replacement) || is_float($replacement));
}, TRUE);
if (!$is_valid) {
throw new BadRequestHttpException(sprintf('The replacement token did find not a list of strings. Instead it found %s.', Json::encode($to_replace)));
}
}