X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=vendor%2Fsymfony%2Fvalidator%2FValidatorBuilder.php;h=3562b945922af3ac34bea7bca8efaf16cfff99e5;hb=4e1bfbf98b844da83b18aca92ef00f11a4735806;hp=4a69976ed2b11227cca39acf9ffdc9031052ddfe;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/vendor/symfony/validator/ValidatorBuilder.php b/vendor/symfony/validator/ValidatorBuilder.php index 4a69976ed..3562b9459 100644 --- a/vendor/symfony/validator/ValidatorBuilder.php +++ b/vendor/symfony/validator/ValidatorBuilder.php @@ -15,21 +15,19 @@ use Doctrine\Common\Annotations\AnnotationReader; use Doctrine\Common\Annotations\CachedReader; use Doctrine\Common\Annotations\Reader; use Doctrine\Common\Cache\ArrayCache; -use Symfony\Component\PropertyAccess\PropertyAccessorInterface; use Symfony\Component\Translation\IdentityTranslator; use Symfony\Component\Translation\TranslatorInterface; use Symfony\Component\Validator\Context\ExecutionContextFactory; -use Symfony\Component\Validator\Exception\InvalidArgumentException; use Symfony\Component\Validator\Exception\ValidatorException; use Symfony\Component\Validator\Mapping\Cache\CacheInterface; use Symfony\Component\Validator\Mapping\Factory\LazyLoadingMetadataFactory; +use Symfony\Component\Validator\Mapping\Factory\MetadataFactoryInterface; use Symfony\Component\Validator\Mapping\Loader\AnnotationLoader; use Symfony\Component\Validator\Mapping\Loader\LoaderChain; +use Symfony\Component\Validator\Mapping\Loader\LoaderInterface; use Symfony\Component\Validator\Mapping\Loader\StaticMethodLoader; use Symfony\Component\Validator\Mapping\Loader\XmlFileLoader; -use Symfony\Component\Validator\Mapping\Loader\XmlFilesLoader; use Symfony\Component\Validator\Mapping\Loader\YamlFileLoader; -use Symfony\Component\Validator\Mapping\Loader\YamlFilesLoader; use Symfony\Component\Validator\Validator\RecursiveValidator; /** @@ -39,24 +37,9 @@ use Symfony\Component\Validator\Validator\RecursiveValidator; */ class ValidatorBuilder implements ValidatorBuilderInterface { - /** - * @var array - */ private $initializers = array(); - - /** - * @var array - */ private $xmlMappings = array(); - - /** - * @var array - */ private $yamlMappings = array(); - - /** - * @var array - */ private $methodMappings = array(); /** @@ -85,15 +68,10 @@ class ValidatorBuilder implements ValidatorBuilderInterface private $translator; /** - * @var null|string + * @var string|null */ private $translationDomain; - /** - * @var PropertyAccessorInterface|null - */ - private $propertyAccessor; - /** * {@inheritdoc} */ @@ -235,7 +213,7 @@ class ValidatorBuilder implements ValidatorBuilderInterface */ public function setMetadataFactory(MetadataFactoryInterface $metadataFactory) { - if (count($this->xmlMappings) > 0 || count($this->yamlMappings) > 0 || count($this->methodMappings) > 0 || null !== $this->annotationReader) { + if (\count($this->xmlMappings) > 0 || \count($this->yamlMappings) > 0 || \count($this->methodMappings) > 0 || null !== $this->annotationReader) { throw new ValidatorException('You cannot set a custom metadata factory after adding custom mappings. You should do either of both.'); } @@ -263,10 +241,6 @@ class ValidatorBuilder implements ValidatorBuilderInterface */ public function setConstraintValidatorFactory(ConstraintValidatorFactoryInterface $validatorFactory) { - if (null !== $this->propertyAccessor) { - throw new ValidatorException('You cannot set a validator factory after setting a custom property accessor. Remove the call to setPropertyAccessor() if you want to call setConstraintValidatorFactory().'); - } - $this->validatorFactory = $validatorFactory; return $this; @@ -293,38 +267,29 @@ class ValidatorBuilder implements ValidatorBuilderInterface } /** - * {@inheritdoc} - * - * @deprecated since version 2.5, to be removed in 3.0. - * The validator will function without a property accessor. + * @return LoaderInterface[] */ - public function setPropertyAccessor(PropertyAccessorInterface $propertyAccessor) + public function getLoaders() { - @trigger_error('The '.__METHOD__.' method is deprecated since version 2.5 and will be removed in 3.0. The validator will function without a property accessor.', E_USER_DEPRECATED); + $loaders = array(); - if (null !== $this->validatorFactory) { - throw new ValidatorException('You cannot set a property accessor after setting a custom validator factory. Configure your validator factory instead.'); + foreach ($this->xmlMappings as $xmlMapping) { + $loaders[] = new XmlFileLoader($xmlMapping); } - $this->propertyAccessor = $propertyAccessor; - - return $this; - } + foreach ($this->yamlMappings as $yamlMappings) { + $loaders[] = new YamlFileLoader($yamlMappings); + } - /** - * {@inheritdoc} - * - * @deprecated since version 2.7, to be removed in 3.0. - */ - public function setApiVersion($apiVersion) - { - @trigger_error('The '.__METHOD__.' method is deprecated in version 2.7 and will be removed in version 3.0.', E_USER_DEPRECATED); + foreach ($this->methodMappings as $methodName) { + $loaders[] = new StaticMethodLoader($methodName); + } - if (!in_array($apiVersion, array(Validation::API_VERSION_2_4, Validation::API_VERSION_2_5, Validation::API_VERSION_2_5_BC))) { - throw new InvalidArgumentException(sprintf('The requested API version is invalid: "%s"', $apiVersion)); + if ($this->annotationReader) { + $loaders[] = new AnnotationLoader($this->annotationReader); } - return $this; + return $loaders; } /** @@ -335,40 +300,19 @@ class ValidatorBuilder implements ValidatorBuilderInterface $metadataFactory = $this->metadataFactory; if (!$metadataFactory) { - $loaders = array(); - - if (count($this->xmlMappings) > 1) { - $loaders[] = new XmlFilesLoader($this->xmlMappings); - } elseif (1 === count($this->xmlMappings)) { - $loaders[] = new XmlFileLoader($this->xmlMappings[0]); - } - - if (count($this->yamlMappings) > 1) { - $loaders[] = new YamlFilesLoader($this->yamlMappings); - } elseif (1 === count($this->yamlMappings)) { - $loaders[] = new YamlFileLoader($this->yamlMappings[0]); - } - - foreach ($this->methodMappings as $methodName) { - $loaders[] = new StaticMethodLoader($methodName); - } - - if ($this->annotationReader) { - $loaders[] = new AnnotationLoader($this->annotationReader); - } - + $loaders = $this->getLoaders(); $loader = null; - if (count($loaders) > 1) { + if (\count($loaders) > 1) { $loader = new LoaderChain($loaders); - } elseif (1 === count($loaders)) { + } elseif (1 === \count($loaders)) { $loader = $loaders[0]; } $metadataFactory = new LazyLoadingMetadataFactory($loader, $this->metadataCache); } - $validatorFactory = $this->validatorFactory ?: new ConstraintValidatorFactory($this->propertyAccessor); + $validatorFactory = $this->validatorFactory ?: new ConstraintValidatorFactory(); $translator = $this->translator; if (null === $translator) {