This commit is contained in:
2021-08-13 17:00:48 +08:00
parent ee46ba2474
commit fe67cad896
2 changed files with 4 additions and 8 deletions
+2 -6
View File
@@ -5,12 +5,10 @@ namespace Annotation;
use Exception; use Exception;
use HttpServer\Http\Context;
use Kiri\Core\Str; use Kiri\Core\Str;
use Kiri\Kiri; use Kiri\Kiri;
use ReflectionException; use ReflectionException;
use ReflectionProperty; use ReflectionProperty;
use Server\ResponseInterface;
/** /**
* Class Inject * Class Inject
@@ -94,12 +92,10 @@ use Server\ResponseInterface;
*/ */
private function parseInjectValue(): mixed private function parseInjectValue(): mixed
{ {
if (class_exists($this->value)) { if (!Kiri::app()->has($this->value)) {
return Kiri::getDi()->get($this->value, $this->args); return Kiri::getDi()->get($this->value, $this->args);
} else if (Kiri::app()->has($this->value)) {
return Kiri::app()->get($this->value);
} else { } else {
return $this->value; return Kiri::app()->get($this->value);
} }
} }
+2 -2
View File
@@ -84,7 +84,7 @@ class Container extends BaseObject
*/ */
public function get($class, array $constrict = [], array $config = []): mixed public function get($class, array $constrict = [], array $config = []): mixed
{ {
if ($this->_isInterface($class)) { if ($this->isInterface($class)) {
$class = $this->_interfaces[$class]; $class = $this->_interfaces[$class];
} }
if (!isset($this->_singletons[$class])) { if (!isset($this->_singletons[$class])) {
@@ -99,7 +99,7 @@ class Container extends BaseObject
* @return bool * @return bool
* @throws ReflectionException * @throws ReflectionException
*/ */
private function _isInterface($class): bool public function isInterface($class): bool
{ {
$reflect = $this->getReflect($class); $reflect = $this->getReflect($class);
if ($reflect->isInterface()) { if ($reflect->isInterface()) {