This commit is contained in:
2023-04-15 23:31:16 +08:00
parent 2d9ac93a7a
commit 41a53200b3
69 changed files with 1678 additions and 749 deletions
+1 -41
View File
@@ -1,49 +1,9 @@
<?php
namespace Kiri\Inject\Route;
namespace Kiri\Router\Inject;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use ReflectionException;
#[\Attribute(\Attribute::TARGET_CLASS)]
class Controller
{
readonly public ?RequestInterface $request;
readonly public ResponseInterface $response;
/**
*
*/
public function __construct()
{
$this->request = \Kiri::getDi()->get(RequestInterface::class);
}
/**
* @param object $class
* @return void
* @throws ReflectionException
*/
public function dispatch(object $class): void
{
// TODO: Implement dispatch() method.
$reflectionClass = \Kiri::getDi()->getReflect($class::class);
$scheduler = \Kiri::getDi()->get(ControllerInterpreter::class);
foreach ($reflectionClass->getMethods() as $reflectionMethod) {
$scheduler->addRouteByObject($class, $reflectionMethod, $reflectionClass);
}
}
}