Files
kiri-router/src/Inject/Controller.php
T

27 lines
507 B
PHP
Raw Normal View History

2023-04-15 23:29:27 +08:00
<?php
2023-04-16 01:24:30 +08:00
declare(strict_types=1);
2023-04-15 23:29:27 +08:00
2023-04-15 23:31:16 +08:00
namespace Kiri\Router\Inject;
2023-04-15 23:29:27 +08:00
#[\Attribute(\Attribute::TARGET_CLASS)]
class Controller
{
2023-04-16 16:51:24 +08:00
/**
* @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());
}
}
}
2023-04-15 23:29:27 +08:00
}