Validates a YAML file.
mixed $content: The parsed YAML file.
string $filename: The name of the file, only used for error messages.
array The $content unchanged returned to allow for chaining this method.
\InvalidArgumentException When service file is not valid
protected function validate($content, $filename) {
if (NULL === $content) {
return $content;
}
if (!is_array($content)) {
throw new \InvalidArgumentException(sprintf('The service file "%s" is not valid: it is not an array.', $filename));
}
if ($keys = array_diff_key($content, array(
'parameters' => TRUE,
'services' => TRUE,
))) {
$invalid_keys = htmlspecialchars(implode(', ', $keys), ENT_QUOTES, 'UTF-8');
throw new \InvalidArgumentException(sprintf('The service file "%s" is not valid: it contains invalid keys %s.', $filename, $invalid_keys));
}
return $content;
}