You are here

public function ValidatorBuilder::setMetadataFactory in Plug 7

Sets the class metadata factory used by the validator.

Parameters

MetadataFactoryInterface $metadataFactory The metadata factory:

Return value

ValidatorBuilderInterface The builder object

Overrides ValidatorBuilderInterface::setMetadataFactory

File

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

Class

ValidatorBuilder
The default implementation of {@link ValidatorBuilderInterface}.

Namespace

Symfony\Component\Validator

Code

public function setMetadataFactory(MetadataFactoryInterface $metadataFactory) {
  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.');
  }
  $this->metadataFactory = $metadataFactory;
  return $this;
}