改名
This commit is contained in:
+16
-9
@@ -5,6 +5,7 @@ namespace Annotation;
|
|||||||
|
|
||||||
|
|
||||||
use ReflectionException;
|
use ReflectionException;
|
||||||
|
use ReflectionProperty;
|
||||||
use Snowflake\Exception\ComponentException;
|
use Snowflake\Exception\ComponentException;
|
||||||
use Snowflake\Exception\NotFindClassException;
|
use Snowflake\Exception\NotFindClassException;
|
||||||
use Snowflake\Snowflake;
|
use Snowflake\Snowflake;
|
||||||
@@ -37,17 +38,23 @@ use Snowflake\Snowflake;
|
|||||||
{
|
{
|
||||||
[$object, $property] = $handler;
|
[$object, $property] = $handler;
|
||||||
if (class_exists($this->className)) {
|
if (class_exists($this->className)) {
|
||||||
return $object->$property = Snowflake::createObject($this->className, $this->args);
|
$injectValue = Snowflake::createObject($this->className, $this->args);
|
||||||
|
} else if (Snowflake::app()->has($this->className)) {
|
||||||
|
$injectValue = Snowflake::app()->get($this->className);
|
||||||
|
} else {
|
||||||
|
$injectValue = $this->className;
|
||||||
}
|
}
|
||||||
|
if (!empty($this->args) && is_object($injectValue)) {
|
||||||
$application = Snowflake::app();
|
Snowflake::configure($injectValue, $this->args);
|
||||||
if (!$application->has($this->className)) {
|
|
||||||
return $object;
|
|
||||||
}
|
}
|
||||||
|
/** @var ReflectionProperty $property */
|
||||||
$object->$property = $application->get($this->className);
|
if ($property->isPrivate() || $property->isProtected()) {
|
||||||
if (!empty($this->args) && is_object($object->$property)) {
|
if (!method_exists($handler[0], 'set' . ucfirst($property->getName()))) {
|
||||||
Snowflake::configure($object->$property, $this->args);
|
return false;
|
||||||
|
}
|
||||||
|
$object->{'set' . ucfirst($property->getName())}($injectValue);
|
||||||
|
} else {
|
||||||
|
$object->$property = $injectValue;
|
||||||
}
|
}
|
||||||
return $object;
|
return $object;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ class Loader extends BaseObject
|
|||||||
}
|
}
|
||||||
$property = $attribute->newInstance();
|
$property = $attribute->newInstance();
|
||||||
if ($property instanceof Inject) {
|
if ($property instanceof Inject) {
|
||||||
$property->execute([$_array['handler'], $method->getName()]);
|
$property->execute([$_array['handler'], $method]);
|
||||||
} else {
|
} else {
|
||||||
$_property[] = $attribute->newInstance();
|
$_property[] = $attribute->newInstance();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user