Skip to content

Commit

Permalink
修正app对象
Browse files Browse the repository at this point in the history
  • Loading branch information
yunwuxin committed Nov 27, 2020
1 parent 589c562 commit fe70b5f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/InteractsWithInject.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/**
* Trait InteractsWithInject
* @package think\annotation\traits
* @property App $app
* @property App $app
* @property Reader $reader
*/
trait InteractsWithInject
Expand All @@ -29,7 +29,7 @@ protected function getDocReader()
protected function autoInject()
{
if ($this->app->config->get('annotation.inject.enable', true)) {
$this->app->resolving(function ($object) {
$this->app->resolving(function ($object, $app) {

if ($this->isInjectClass(get_class($object))) {

Expand All @@ -42,12 +42,12 @@ protected function autoInject()
$annotation = $this->reader->getPropertyAnnotation($refProperty, Inject::class);
if ($annotation) {
if ($annotation->value) {
$value = $this->app->make($annotation->value);
$value = $app->make($annotation->value);
} else {
//获取@var类名
$propertyClass = $reader->getPropertyClass($refProperty);
if ($propertyClass) {
$value = $this->app->make($propertyClass);
$value = $app->make($propertyClass);
}
}

Expand All @@ -62,7 +62,7 @@ protected function autoInject()
}

if ($refObject->hasMethod('__injected')) {
$this->app->invokeMethod([$object, '__injected']);
$app->invokeMethod([$object, '__injected']);
}
}
});
Expand Down

0 comments on commit fe70b5f

Please sign in to comment.