Skip to content

Commit

Permalink
Merge pull request #28 from koriym/annotation_loader
Browse files Browse the repository at this point in the history
Add Dii::registerAnnotationLoader()
  • Loading branch information
koriym authored Jan 29, 2021
2 parents a0202cf + b3e58ee commit 6656d94
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion demo/public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
10 changes: 10 additions & 0 deletions src/Dii.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Koriym\Dii;

use CException;
use Doctrine\Common\Annotations\AnnotationRegistry;
use Koriym\Dii\Module\AppModule;
use LengthException;
use LogicException;
Expand Down Expand Up @@ -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']);
}
}

0 comments on commit 6656d94

Please # to comment.