public function Validator::validatePropertyValue

Throws

ValidatorException If the metadata for the value does not support properties.

Overrides ValidatorInterface::validatePropertyValue

File

drupal/core/vendor/symfony/validator/Symfony/Component/Validator/Validator.php, line 132

Class

Validator
Default implementation of {@link ValidatorInterface}.

Namespace

Symfony\Component\Validator

Code

public function validatePropertyValue($containingValue, $property, $value, $groups = null) {
  $visitor = $this
    ->createVisitor($containingValue);
  $metadata = $this->metadataFactory
    ->getMetadataFor($containingValue);
  if (!$metadata instanceof PropertyMetadataContainerInterface) {
    $valueAsString = is_scalar($containingValue) ? '"' . $containingValue . '"' : 'the value of type ' . gettype($containingValue);
    throw new ValidatorException(sprintf('The metadata for ' . $valueAsString . ' does not support properties.'));
  }
  foreach ($this
    ->resolveGroups($groups) as $group) {
    if (!$metadata
      ->hasPropertyMetadata($property)) {
      continue;
    }
    foreach ($metadata
      ->getPropertyMetadata($property) as $propMeta) {
      $propMeta
        ->accept($visitor, $value, $group, $property);
    }
  }
  return $visitor
    ->getViolations();
}