Skip to content

Commit

Permalink
Simple support of Instance::of in configuration
Browse files Browse the repository at this point in the history
see vendor/yiisoft/yii2/di/Container.php::get
$class is string|Instance
  • Loading branch information
antonovsky committed Nov 13, 2020
1 parent 2993af8 commit b89741c
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions StubsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use yii\console\Controller;
use yii\console\Exception;
use yii\di\Instance;

class StubsController extends Controller
{
Expand Down Expand Up @@ -88,9 +89,18 @@ public function actionIndex()
}

if (isset($component['class'])) {
$components[$name][] = $component['class'];
$class = $component['class'];
} elseif (isset($component['__class'])) {
$components[$name][] = $component['__class'];
$class = $component['class'];
}

if (isset($class)) {
if ($class instanceof Instance)
{
$components[$name][] = get_class($class->get());
} else {
$components[$name][] = $class;
}
}
}
}
Expand Down

0 comments on commit b89741c

Please sign in to comment.