PluginProbe
MailPoet – Newsletters, Email Marketing, and Automation / 5.33.1
MailPoet – Newsletters, Email Marketing, and Automation v5.33.1
5.38.0 5.37.0 5.36.1 5.36.0 5.35.1 5.35.0 5.34.3 5.34.2 5.34.1 5.34.0 5.33.1 5.33.0 5.32.0 5.31.0 5.30.0 5.29.0 5.28.1 5.28.0 5.27.0 5.26.0 5.26.1 5.25.0 5.24.0 4.43.0 4.43.1 All 542 releases
mailpoet / lib / Doctrine / Annotations / AnnotationReaderProvider.php
AnnotationReaderProvider.php
33 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php // phpcs:ignore SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing
2
3 namespace MailPoet\Doctrine\Annotations;
4
5 if (!defined('ABSPATH')) exit;
6
7
8 use MailPoet\Doctrine\PSRArrayCache;
9 use MailPoetVendor\Doctrine\Common\Annotations\AnnotationReader;
10 use MailPoetVendor\Doctrine\Common\Annotations\AnnotationRegistry;
11 use MailPoetVendor\Doctrine\Common\Annotations\PsrCachedReader;
12
13 class AnnotationReaderProvider {
14 /** @var PsrCachedReader */
15 private $annotationReader;
16
17 public function __construct() {
18 // register annotation reader if doctrine/annotations package is installed
19 // (i.e. in dev environment, on production metadata is dumped in the build)
20 $readAnnotations = class_exists(PsrCachedReader::class) && class_exists(AnnotationReader::class);
21 if ($readAnnotations) {
22 // autoload all annotation classes using registered loaders (Composer)
23 // (needed for Symfony\Validator constraint annotations to be loaded)
24 AnnotationRegistry::registerLoader('class_exists');
25 $this->annotationReader = new PsrCachedReader(new AnnotationReader(), new PSRArrayCache());
26 }
27 }
28
29 public function getAnnotationReader(): ?PsrCachedReader {
30 return $this->annotationReader;
31 }
32 }
33