Integrate symfony/validator with Doctrine entitites

[MAILPOET-2437]
This commit is contained in:
Jan Jakeš
2019-10-22 10:19:25 +02:00
committed by Jack Kitterhing
parent bed49f97ef
commit 730f640cc3
7 changed files with 117 additions and 5 deletions

View File

@@ -2,6 +2,7 @@
namespace MailPoet\Doctrine;
use MailPoetVendor\Doctrine\Common\Annotations\AnnotationRegistry;
use MailPoetVendor\Doctrine\Common\Annotations\SimpleAnnotationReader;
use MailPoetVendor\Doctrine\Common\Cache\ArrayCache;
use MailPoetVendor\Doctrine\Common\Proxy\AbstractProxyFactory;
@@ -39,6 +40,10 @@ class ConfigurationFactory {
$metadata_storage = new MetadataCache(self::METADATA_DIR);
$configuration->setMetadataCacheImpl($metadata_storage);
// autoload all annotation classes using registered loaders (Composer)
// (needed for Symfony\Validator constraint annotations to be loaded)
AnnotationRegistry::registerLoader('class_exists');
// register annotation reader if doctrine/annotations package is installed
// (i.e. in dev environment, on production metadata is dumped in the build)
if (class_exists(SimpleAnnotationReader::class)) {