From ac68e071a5375e030dc85ac7e489d38472147320 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Tue, 23 Mar 2021 17:11:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Annotation/Loader.php | 7 ++++++- Annotation/Rpc/RpcService.php | 3 --- Database/Base/BaseActiveRecord.php | 2 -- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Annotation/Loader.php b/Annotation/Loader.php index 4dca8ea3..e80c75f5 100644 --- a/Annotation/Loader.php +++ b/Annotation/Loader.php @@ -185,7 +185,12 @@ class Loader extends BaseObject if (!class_exists($attribute->getName())) { continue; } - $_property[] = $attribute->newInstance(); + $property = $attribute->newInstance(); + if ($property instanceof Inject) { + $property->execute([$_array['handler'], $method->getName()]); + } else { + $_property[] = $attribute->newInstance(); + } } $_array['property'][$method->getName()] = $_property; } diff --git a/Annotation/Rpc/RpcService.php b/Annotation/Rpc/RpcService.php index e49e9c2c..778e393c 100644 --- a/Annotation/Rpc/RpcService.php +++ b/Annotation/Rpc/RpcService.php @@ -56,9 +56,6 @@ use Snowflake\Snowflake; $rpc = Snowflake::app()->getRpc(); $rpc->addProducer($this->cmd, $handler, $this->config); - $attributes = Snowflake::app()->getAttributes(); - $attributes->injectProperty($handler[0]); - return parent::execute($handler); } diff --git a/Database/Base/BaseActiveRecord.php b/Database/Base/BaseActiveRecord.php index 7910cfc7..d26cfa8d 100644 --- a/Database/Base/BaseActiveRecord.php +++ b/Database/Base/BaseActiveRecord.php @@ -149,8 +149,6 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess private function createAnnotation() { $annotation = Snowflake::app()->getAttributes(); - $annotation->injectProperty($this); - $methods = $annotation->getMethods(get_called_class()); foreach ($methods as $method => $attributes) { foreach ($attributes as $attribute) {