You are here

public function ValidatorBuilder::setMetadataFactory in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/validator/ValidatorBuilder.php \Symfony\Component\Validator\ValidatorBuilder::setMetadataFactory()

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

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

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