This commit is contained in:
2023-04-16 16:51:24 +08:00
parent 89bc2a9ab1
commit 9cbe8ee062
+16
View File
@@ -7,4 +7,20 @@ namespace Kiri\Router\Inject;
#[\Attribute(\Attribute::TARGET_CLASS)] #[\Attribute(\Attribute::TARGET_CLASS)]
class Controller 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());
}
}
}
} }