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-16 20:36:47 +08:00
|
|
|
namespace Kiri\Router\Annotate;
|
2023-04-15 23:29:27 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
#[\Attribute(\Attribute::TARGET_CLASS)]
|
2023-04-16 17:15:34 +08:00
|
|
|
class AutoController
|
2023-04-15 23:29:27 +08:00
|
|
|
{
|
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
|
|
|
}
|