/** * Validate configuration * @param ConfigurationArray $configuration * @param string $key * @param ValidatorInterface $validator * @param Constraint|Constraint[] $constraints * @throws ConfigurationNotFoundException */ public static function assertMatchesSchema(ConfigurationArray $configuration, string $key, ValidatorInterface $validator, $constraints) { $violations = $validator->validate($configuration->getAll()->getArrayCopy(), $constraints); if (!$violations->count()) { return; } $error = "Validation errors:"; /** @var ConstraintViolation $violation */ foreach ($violations as $violation) { $error .= "\n"; if (!empty($violation->getPropertyPath())) { $error .= "[" . $violation->getPropertyPath() . "]"; } $error .= $violation->getMessage(); } throw new ConfigurationNotValidException(sprintf('Configuration %s has bad structure: %s', $key, $error)); }
/** * @inheritdoc */ public function get($key) { return parent::get($key); }