public function ClassMetadata::accept

Implementation of the Visitor design pattern.

Calls {@link ValidationVisitorInterface::visit} and then forwards the <tt>accept()</tt>-call to all property metadata instances.

Parameters

ValidationVisitorInterface $visitor The visitor implementing the validation logic.:

mixed $value The value to validate.:

string|string[] $group The validation group to validate in.:

string $propertyPath The current property path in the validation graph.:

Overrides MetadataInterface::accept

File

drupal/core/vendor/symfony/validator/Symfony/Component/Validator/Mapping/ClassMetadata.php, line 86

Class

ClassMetadata
Represents all the configured constraints on a given class.

Namespace

Symfony\Component\Validator\Mapping

Code

public function accept(ValidationVisitorInterface $visitor, $value, $group, $propertyPath, $propagatedGroup = null) {
  if (null === $propagatedGroup && Constraint::DEFAULT_GROUP === $group && ($this
    ->hasGroupSequence() || $this
    ->isGroupSequenceProvider())) {
    if ($this
      ->hasGroupSequence()) {
      $groups = $this
        ->getGroupSequence();
    }
    else {
      $groups = $value
        ->getGroupSequence();
    }
    foreach ($groups as $group) {
      $this
        ->accept($visitor, $value, $group, $propertyPath, Constraint::DEFAULT_GROUP);
      if (count($visitor
        ->getViolations()) > 0) {
        break;
      }
    }
    return;
  }
  $visitor
    ->visit($this, $value, $group, $propertyPath);
  if (null !== $value) {
    $pathPrefix = empty($propertyPath) ? '' : $propertyPath . '.';
    foreach ($this
      ->getConstrainedProperties() as $property) {
      foreach ($this
        ->getMemberMetadatas($property) as $member) {
        $member
          ->accept($visitor, $member
          ->getPropertyValue($value), $group, $pathPrefix . $property, $propagatedGroup);
      }
    }
  }
}