From 1adfdfa7107b533d7a446ecaf1998facd38fd4b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Tue, 23 Feb 2021 15:26:43 +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/Annotation.php | 7 +++++++ Database/DatabasesProviders.php | 7 ++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Annotation/Annotation.php b/Annotation/Annotation.php index 3f091156..17af6002 100644 --- a/Annotation/Annotation.php +++ b/Annotation/Annotation.php @@ -34,6 +34,9 @@ class Annotation extends Component private array $_methods = []; + private array $_prepertyes = []; + + /** * @param array $handler * @param $name @@ -147,6 +150,9 @@ class Annotation extends Component private function resolveProperty(ReflectionClass $reflectionClass, $object) { $property = $reflectionClass->getProperties(); + if (!isset($this->_prepertyes[get_class($object)])) { + $this->_prepertyes[get_class($object)] = []; + } foreach ($property as $value) { if ($value->isStatic()) continue; $attributes = $value->getAttributes(); @@ -160,6 +166,7 @@ class Annotation extends Component continue; } $annotation = $annotation->execute([$object, $value->getName()]); + $this->_prepertyes[get_class($object)][$value->getName()] = $annotation; if ($value->isPublic()) { $object->{$value->getName()} = $annotation; } else { diff --git a/Database/DatabasesProviders.php b/Database/DatabasesProviders.php index 01d0756d..be414686 100644 --- a/Database/DatabasesProviders.php +++ b/Database/DatabasesProviders.php @@ -12,6 +12,8 @@ use Snowflake\Application; use Snowflake\Event; use Snowflake\Exception\ComponentException; use Snowflake\Exception\ConfigException; +use Snowflake\Exception\NotFindClassException; +use Snowflake\Exception\NotFindPropertyException; use Snowflake\Snowflake; use Snowflake\Abstracts\Config; @@ -36,12 +38,15 @@ class DatabasesProviders extends Providers $event->on(Event::SERVER_TASK_START, [$this, 'createPool']); $event->on(Event::SERVER_WORKER_START, [$this, 'scanModel']); + $event->on(Event::SERVER_TASK_START, [$this, 'scanModel']); } /** - * @throws ReflectionException * @throws ComponentException + * @throws ReflectionException + * @throws NotFindClassException + * @throws NotFindPropertyException */ public function scanModel() {