Create a PSR cache for validator

[MAILPOET-3241]
This commit is contained in:
Pavel Dohnal
2020-10-27 11:34:15 +01:00
committed by Veljko V
parent e2d6fb77ce
commit 95cf33b176
6 changed files with 235 additions and 7 deletions

View File

@@ -3,8 +3,7 @@
namespace MailPoet\Doctrine\Validator;
use MailPoet\Doctrine\Annotations\AnnotationReaderProvider;
use MailPoet\Doctrine\MetadataCache;
use MailPoetVendor\Symfony\Component\Validator\Mapping\Cache\DoctrineCache;
use MailPoet\Doctrine\PSRMetadataCache;
use MailPoetVendor\Symfony\Component\Validator\Validation;
class ValidatorFactory {
@@ -34,8 +33,7 @@ class ValidatorFactory {
// metadata cache (for production cache is pre-generated at build time)
$isReadOnly = !$annotationReader;
$metadataCache = new MetadataCache(self::METADATA_DIR, $isReadOnly);
$builder->setMetadataCache(new DoctrineCache($metadataCache));
$builder->setMappingCache(new PSRMetadataCache(self::METADATA_DIR, $isReadOnly));
return $builder->getValidator();
}