private function RecursiveContextualValidator::validateGenericNode in Plug 7
Validates a node that is not a class node.
Currently, two such node types exist:
- property nodes, which consist of the value of an object's property together with a {@link PropertyMetadataInterface} instance
- generic nodes, which consist of a value and some arbitrary constraints defined in a {@link MetadataInterface} container
In both cases, the value is validated against all constraints defined in the passed metadata object. Then, if the value is an instance of {@link \Traversable} and the selected traversal strategy permits it, the value is traversed and each nested object validated against its own constraints. Arrays are always traversed.
Parameters
mixed $value The validated value:
object|null $object The current object:
string $cacheKey The key for caching: the validated value
MetadataInterface $metadata The metadata of the: value
string $propertyPath The property path leading: to the value
string[] $groups The groups in which the: value should be validated
string[]|null $cascadedGroups The groups in which: cascaded objects should be validated
int $traversalStrategy The strategy used for: traversing the value
ExecutionContextInterface $context The current execution context:
See also
5 calls to RecursiveContextualValidator::validateGenericNode()
- RecursiveContextualValidator::stepThroughGroupSequence in lib/Symfony/ validator/ Symfony/ Component/ Validator/ Validator/ RecursiveContextualValidator.php 
- Sequentially validates a node's value in each group of a group sequence.
- RecursiveContextualValidator::validate in lib/Symfony/ validator/ Symfony/ Component/ Validator/ Validator/ RecursiveContextualValidator.php 
- Validates a value against a constraint or a list of constraints.
- RecursiveContextualValidator::validateClassNode in lib/Symfony/ validator/ Symfony/ Component/ Validator/ Validator/ RecursiveContextualValidator.php 
- Validates a class node.
- RecursiveContextualValidator::validateProperty in lib/Symfony/ validator/ Symfony/ Component/ Validator/ Validator/ RecursiveContextualValidator.php 
- Validates a property of an object against the constraints specified for this property.
- RecursiveContextualValidator::validatePropertyValue in lib/Symfony/ validator/ Symfony/ Component/ Validator/ Validator/ RecursiveContextualValidator.php 
- Validates a value against the constraints specified for an object's property.
File
- lib/Symfony/ validator/ Symfony/ Component/ Validator/ Validator/ RecursiveContextualValidator.php, line 676 
Class
- RecursiveContextualValidator
- Recursive implementation of {@link ContextualValidatorInterface}.
Namespace
Symfony\Component\Validator\ValidatorCode
private function validateGenericNode($value, $object, $cacheKey, MetadataInterface $metadata = null, $propertyPath, array $groups, $cascadedGroups, $traversalStrategy, ExecutionContextInterface $context) {
  $context
    ->setNode($value, $object, $metadata, $propertyPath);
  foreach ($groups as $key => $group) {
    if ($group instanceof GroupSequence) {
      $this
        ->stepThroughGroupSequence($value, $object, $cacheKey, $metadata, $propertyPath, $traversalStrategy, $group, null, $context);
      // Skip the group sequence when cascading, as the cascading
      // logic is already done in stepThroughGroupSequence()
      unset($groups[$key]);
      continue;
    }
    $this
      ->validateInGroup($value, $cacheKey, $metadata, $group, $context);
  }
  if (0 === count($groups)) {
    return;
  }
  if (null === $value) {
    return;
  }
  $cascadingStrategy = $metadata
    ->getCascadingStrategy();
  // Quit unless we have an array or a cascaded object
  if (!is_array($value) && !($cascadingStrategy & CascadingStrategy::CASCADE)) {
    return;
  }
  // If no specific traversal strategy was requested when this method
  // was called, use the traversal strategy of the node's metadata
  if ($traversalStrategy & TraversalStrategy::IMPLICIT) {
    // Keep the STOP_RECURSION flag, if it was set
    $traversalStrategy = $metadata
      ->getTraversalStrategy() | $traversalStrategy & TraversalStrategy::STOP_RECURSION;
  }
  // The $cascadedGroups property is set, if the "Default" group is
  // overridden by a group sequence
  // See validateClassNode()
  $cascadedGroups = count($cascadedGroups) > 0 ? $cascadedGroups : $groups;
  if (is_array($value)) {
    // Arrays are always traversed, independent of the specified
    // traversal strategy
    // (BC with Symfony < 2.5)
    $this
      ->validateEachObjectIn($value, $propertyPath, $cascadedGroups, $traversalStrategy & TraversalStrategy::STOP_RECURSION, $context);
    return;
  }
  // If the value is a scalar, pass it anyway, because we want
  // a NoSuchMetadataException to be thrown in that case
  // (BC with Symfony < 2.5)
  $this
    ->validateObject($value, $propertyPath, $cascadedGroups, $traversalStrategy, $context);
  // Currently, the traversal strategy can only be TRAVERSE for a
  // generic node if the cascading strategy is CASCADE. Thus, traversable
  // objects will always be handled within validateObject() and there's
  // nothing more to do here.
  // see GenericMetadata::addConstraint()
}