Mercurial > hg > isophonics-drupal-site
view vendor/symfony/validator/Validator/RecursiveValidator.php @ 13:5fb285c0d0e3
Update Drupal core to 8.4.7 via Composer. Security update; I *think* we've
been lucky to get away with this so far, as we don't support self-registration
which seems to be used by the so-called "drupalgeddon 2" attack that 8.4.5
was vulnerable to.
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:33:26 +0100 |
parents | 4c8ae668cc8c |
children | 1fec387a4317 |
line wrap: on
line source
<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Validator\Validator; use Symfony\Component\Validator\ConstraintValidatorFactoryInterface; use Symfony\Component\Validator\Context\ExecutionContextFactoryInterface; use Symfony\Component\Validator\Context\ExecutionContextInterface; use Symfony\Component\Validator\Mapping\Factory\MetadataFactoryInterface; use Symfony\Component\Validator\ObjectInitializerInterface; /** * Recursive implementation of {@link ValidatorInterface}. * * @author Bernhard Schussek <bschussek@gmail.com> */ class RecursiveValidator implements ValidatorInterface { /** * @var ExecutionContextFactoryInterface */ protected $contextFactory; /** * @var MetadataFactoryInterface */ protected $metadataFactory; /** * @var ConstraintValidatorFactoryInterface */ protected $validatorFactory; /** * @var ObjectInitializerInterface[] */ protected $objectInitializers; /** * Creates a new validator. * * @param ExecutionContextFactoryInterface $contextFactory The factory for * creating new contexts * @param MetadataFactoryInterface $metadataFactory The factory for * fetching the metadata * of validated objects * @param ConstraintValidatorFactoryInterface $validatorFactory The factory for creating * constraint validators * @param ObjectInitializerInterface[] $objectInitializers The object initializers */ public function __construct(ExecutionContextFactoryInterface $contextFactory, MetadataFactoryInterface $metadataFactory, ConstraintValidatorFactoryInterface $validatorFactory, array $objectInitializers = array()) { $this->contextFactory = $contextFactory; $this->metadataFactory = $metadataFactory; $this->validatorFactory = $validatorFactory; $this->objectInitializers = $objectInitializers; } /** * {@inheritdoc} */ public function startContext($root = null) { return new RecursiveContextualValidator( $this->contextFactory->createContext($this, $root), $this->metadataFactory, $this->validatorFactory, $this->objectInitializers ); } /** * {@inheritdoc} */ public function inContext(ExecutionContextInterface $context) { return new RecursiveContextualValidator( $context, $this->metadataFactory, $this->validatorFactory, $this->objectInitializers ); } /** * {@inheritdoc} */ public function getMetadataFor($object) { return $this->metadataFactory->getMetadataFor($object); } /** * {@inheritdoc} */ public function hasMetadataFor($object) { return $this->metadataFactory->hasMetadataFor($object); } /** * {@inheritdoc} */ public function validate($value, $constraints = null, $groups = null) { return $this->startContext($value) ->validate($value, $constraints, $groups) ->getViolations(); } /** * {@inheritdoc} */ public function validateProperty($object, $propertyName, $groups = null) { return $this->startContext($object) ->validateProperty($object, $propertyName, $groups) ->getViolations(); } /** * {@inheritdoc} */ public function validatePropertyValue($objectOrClass, $propertyName, $value, $groups = null) { // If a class name is passed, take $value as root return $this->startContext(is_object($objectOrClass) ? $objectOrClass : $value) ->validatePropertyValue($objectOrClass, $propertyName, $value, $groups) ->getViolations(); } }