public function ValidatorBuilder::enableAnnotationMapping

Enables annotation based constraint mapping.

Parameters

Reader $annotationReader The annotation reader to be used.:

Return value

ValidatorBuilderInterface The builder object.

Overrides ValidatorBuilderInterface::enableAnnotationMapping

File

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

Class

ValidatorBuilder
The default implementation of {@link ValidatorBuilderInterface}.

Namespace

Symfony\Component\Validator

Code

public function enableAnnotationMapping(Reader $annotationReader = null) {
  if (null !== $this->metadataFactory) {
    throw new ValidatorException('You cannot enable annotation mapping after setting a custom metadata factory. Configure your metadata factory instead.');
  }
  if (null === $annotationReader) {
    if (!class_exists('Doctrine\\Common\\Annotations\\AnnotationReader')) {
      throw new \RuntimeException('Requested a ValidatorFactory with an AnnotationLoader, but the AnnotationReader was not found. You should add Doctrine Common to your project.');
    }
    $annotationReader = new CachedReader(new AnnotationReader(), new ArrayCache());
  }
  $this->annotationReader = $annotationReader;
  return $this;
}