mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 12:42:48 +08:00
改进自动注入机制 需要依赖注入的类如果定义了invoke方法则自动调用
This commit is contained in:
@@ -280,7 +280,14 @@ class App
|
||||
if ($bind instanceof $className) {
|
||||
$args[] = $bind;
|
||||
} else {
|
||||
$args[] = method_exists($className, 'instance') ? $className::instance() : new $className();
|
||||
if (method_exists($className, 'invoke')) {
|
||||
$method = new \ReflectionMethod($className, 'invoke');
|
||||
if ($method->isStatic()) {
|
||||
$args[] = $className::invoke();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$args[] = method_exists($className, 'instance') ? $className::instance() : new $className;
|
||||
}
|
||||
} elseif (1 == $type && !empty($vars)) {
|
||||
$args[] = array_shift($vars);
|
||||
|
||||
Reference in New Issue
Block a user