From 9cbe8ee062d26b87f0bf85ef51c57fd711fc88c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Sun, 16 Apr 2023 16:51:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Inject/Controller.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Inject/Controller.php b/src/Inject/Controller.php index add2c4b..dd80381 100644 --- a/src/Inject/Controller.php +++ b/src/Inject/Controller.php @@ -7,4 +7,20 @@ namespace Kiri\Router\Inject; #[\Attribute(\Attribute::TARGET_CLASS)] class Controller { + + /** + * @throws \ReflectionException + */ + public function dispatch(object $object): void + { + $reflection = \Kiri::getDi()->getReflectionClass($object::class); + foreach ($reflection->getMethods() as $method) { + $attributes = $method->getAttributes(); + foreach ($attributes as $attribute) { + $attribute->newInstance()->dispatch($object, $method->getName()); + } + } + + } + }