You are here

public function ValidatorBuilder::enableAnnotationMapping in Plug 7

Enables annotation based constraint mapping.

Parameters

Reader $annotationReader The annotation reader to be used:

Return value

ValidatorBuilderInterface The builder object

Overrides ValidatorBuilderInterface::enableAnnotationMapping

File

lib/Symfony/validator/Symfony/Component/Validator/ValidatorBuilder.php, line 212

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;
}