You are here

public function ValidatorBuilder::enableAnnotationMapping in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/validator/ValidatorBuilder.php \Symfony\Component\Validator\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

vendor/symfony/validator/ValidatorBuilder.php, line 204

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') || !class_exists('Doctrine\\Common\\Cache\\ArrayCache')) {
      throw new \RuntimeException('Enabling annotation based constraint mapping requires the packages doctrine/annotations and doctrine/cache to be installed.');
    }
    $annotationReader = new CachedReader(new AnnotationReader(), new ArrayCache());
  }
  $this->annotationReader = $annotationReader;
  return $this;
}