modify
This commit is contained in:
+31
-10
@@ -179,7 +179,7 @@ class Loader extends BaseObject
|
|||||||
}
|
}
|
||||||
$this->appendFileToDirectory($path->getRealPath(), $replace->getName());
|
$this->appendFileToDirectory($path->getRealPath(), $replace->getName());
|
||||||
|
|
||||||
$_array = ['handler' => $replace->newInstance(), 'target' => [], 'methods' => [], 'property' => []];
|
$_array = ['handler' => $replace->getName(), 'target' => [], 'methods' => [], 'property' => []];
|
||||||
foreach ($replace->getAttributes() as $attribute) {
|
foreach ($replace->getAttributes() as $attribute) {
|
||||||
if ($attribute->getName() == Attribute::class) {
|
if ($attribute->getName() == Attribute::class) {
|
||||||
continue;
|
continue;
|
||||||
@@ -395,27 +395,31 @@ class Loader extends BaseObject
|
|||||||
if (empty($classes)) {
|
if (empty($classes)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$annotation = Snowflake::app()->getAnnotation();
|
$annotation = Snowflake::getAnnotation();
|
||||||
|
|
||||||
|
|
||||||
foreach ($classes as $className) {
|
foreach ($classes as $className) {
|
||||||
$annotations = $this->_classes[$className] ?? null;
|
$annotations = $this->_classes[$className] ?? null;
|
||||||
if ($annotations === null) {
|
if ($annotations === null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
foreach ($annotations['target'] ?? [] as $value) {
|
if (($reflect = $this->getRelect($annotations)) === null) {
|
||||||
$value->execute([$annotations['handler']]);
|
continue;
|
||||||
|
}
|
||||||
|
$reflect = $reflect->newInstance();
|
||||||
|
foreach ($annotations['target'] ?? [] as $value) {
|
||||||
|
$value->execute([$reflect]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$_className = $annotations['handler']::class;
|
|
||||||
foreach ($annotations['methods'] as $name => $attribute) {
|
foreach ($annotations['methods'] as $name => $attribute) {
|
||||||
foreach ($attribute as $value) {
|
foreach ($attribute as $value) {
|
||||||
if ($value instanceof Relation) {
|
if ($value instanceof Relation) {
|
||||||
$annotation->addRelate($_className, $value->name, $name);
|
$annotation->addRelate($reflect->getName(), $value->name, $name);
|
||||||
} else if ($value instanceof Get) {
|
} else if ($value instanceof Get) {
|
||||||
$annotation->addGets($_className, $value->name, $name);
|
$annotation->addGets($reflect->getName(), $value->name, $name);
|
||||||
} else if ($value instanceof Set) {
|
} else if ($value instanceof Set) {
|
||||||
$annotation->addSets($_className, $value->name, $name);
|
$annotation->addSets($reflect->getName(), $value->name, $name);
|
||||||
} else {
|
} else {
|
||||||
$value->execute([$annotations['handler'], $name]);
|
$value->execute([$reflect, $name]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -423,4 +427,21 @@ class Loader extends BaseObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $annotations
|
||||||
|
* @return \ReflectionClass|null
|
||||||
|
* @throws \ReflectionException
|
||||||
|
* @throws \Snowflake\Exception\NotFindClassException
|
||||||
|
*/
|
||||||
|
private function getRelect($annotations)
|
||||||
|
{
|
||||||
|
$reflect = Snowflake::getDi()->getReflect($annotations['handler']);
|
||||||
|
if ($reflect === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return $reflect;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user