This commit is contained in:
2023-04-16 17:15:34 +08:00
parent 9cbe8ee062
commit 740e8c5c94
+26
View File
@@ -0,0 +1,26 @@
<?php
declare(strict_types=1);
namespace Kiri\Router\Inject;
#[\Attribute(\Attribute::TARGET_CLASS)]
class AutoController
{
/**
* @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());
}
}
}
}