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..fb5714b 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,13 @@ 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(); + AnnotationRegistry::registerLoader([SilentAutoload::class, 'autoload']); + } }