From 3068864e57f70cde4ade64be90ade33f8c81faa7 Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Fri, 29 Jan 2021 09:41:03 +0900 Subject: [PATCH 1/2] Add Dii::registerAnnotationLoader() --- demo/public/index.php | 2 +- src/Dii.php | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/demo/public/index.php b/demo/public/index.php index 2152db0..37cd5f7 100644 --- a/demo/public/index.php +++ b/demo/public/index.php @@ -10,7 +10,7 @@ use Koriym\Dii\Test; $loader = require dirname(__DIR__) . '/vendor/autoload.php'; -AnnotationRegistry::registerLoader([SilentAutoload::class, 'autoload']); +Dii::registerAnnotationLoader(); $config = __DIR__ . '/protected/config/main.php'; diff --git a/src/Dii.php b/src/Dii.php index 37078c6..991de6f 100644 --- a/src/Dii.php +++ b/src/Dii.php @@ -5,6 +5,7 @@ namespace Koriym\Dii; use CException; +use Doctrine\Common\Annotations\AnnotationRegistry; use Koriym\Dii\Module\AppModule; use LengthException; use LogicException; @@ -150,4 +151,10 @@ private static function extract($config): array throw new CException(self::t('yii', 'Object configuration must be an array containing a "class" element.')); } + + public static function registerAnnotationLoader() + { + AnnotationRegistry::reset(); + AnnotationRegistry::registerLoader([SilentAutoload::class, 'autoload']); + } } From b3e58ee6d5037bc73ccc8a0504df2399bdf21edf Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Fri, 29 Jan 2021 10:39:18 +0900 Subject: [PATCH 2/2] Add comment --- src/Dii.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Dii.php b/src/Dii.php index 991de6f..fb5714b 100644 --- a/src/Dii.php +++ b/src/Dii.php @@ -152,6 +152,9 @@ private static function extract($config): array throw new CException(self::t('yii', 'Object configuration must be an array containing a "class" element.')); } + /** + * Register silent annotation loader + */ public static function registerAnnotationLoader() { AnnotationRegistry::reset();