don't change state in case of exception

This commit is contained in:
Christian Flothmann 2019-09-13 12:19:20 +02:00
parent 6e7182f9e3
commit dcd47335a8

View File

@ -255,12 +255,12 @@ class ValidatorBuilder implements ValidatorBuilderInterface
*/
public function setMappingCache(CacheItemPoolInterface $cache)
{
$this->mappingCache = $cache;
if (null !== $this->metadataFactory) {
throw new ValidatorException('You cannot set a custom mapping cache after setting a custom metadata factory. Configure your metadata factory instead.');
}
$this->mappingCache = $cache;
return $this;
}