This commit is contained in:
as2252258@163.com
2021-05-02 04:18:06 +08:00
parent 52f637ea25
commit 291ad9870d
+7 -8
View File
@@ -179,7 +179,7 @@ class Loader extends BaseObject
} }
$this->appendFileToDirectory($path->getRealPath(), $replace->getName()); $this->appendFileToDirectory($path->getRealPath(), $replace->getName());
$_array = ['handler' => $replace->getName(), 'target' => [], 'methods' => [], 'property' => []]; $_array = ['handler' => $replace->newInstance(), '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;
@@ -401,22 +401,21 @@ class Loader extends BaseObject
if ($annotations === null) { if ($annotations === null) {
continue; continue;
} }
$target = new $annotations['handler']();
foreach ($annotations['target'] ?? [] as $value) { foreach ($annotations['target'] ?? [] as $value) {
$value->execute([$target]); $value->execute([$annotations['handler']]);
} }
$_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($target::class, $value->name, $name); $annotation->addRelate($_className, $value->name, $name);
} else if ($value instanceof Get) { } else if ($value instanceof Get) {
$annotation->addGets($target::class, $value->name, $name); $annotation->addGets($_className, $value->name, $name);
} else if ($value instanceof Set) { } else if ($value instanceof Set) {
$annotation->addSets($target::class, $value->name, $name); $annotation->addSets($_className, $value->name, $name);
} else { } else {
$value->execute([$target, $name]); $value->execute([$annotations['handler'], $name]);
} }
} }
} }