Tim
96e833fb4b
diff --git a/app/Kernel.php b/app/Kernel.php index 0e8e047..4425355 100644 --- a/app/Kernel.php +++ b/app/Kernel.php @@ -2,8 +2,16 @@ namespace App; +use App\Controller\BaseController; +use Ardent\Undercurrent\Container\ContainerInterface; use Ardent\Undercurrent\Kernel\BaseKernel; class Kernel extends BaseKernel { + protected function dependencies(ContainerInterface $container): void + { + $this->addRoutes($container, [ + BaseController::class, + ]); + } } \ No newline at end of file diff --git a/src/Http/RouterConfig.php b/src/Http/RouterConfig.php index ad856d6..60e5af7 100644 --- a/src/Http/RouterConfig.php +++ b/src/Http/RouterConfig.php @@ -4,7 +4,6 @@ namespace Ardent\Undercurrent\Http; class RouterConfig { - public function __construct( private readonly array $controllers = [], ) diff --git a/src/Kernel/BaseKernel.php b/src/Kernel/BaseKernel.php index a6732f4..149aa8b 100644 --- a/src/Kernel/BaseKernel.php +++ b/src/Kernel/BaseKernel.php @@ -2,7 +2,6 @@ namespace Ardent\Undercurrent\Kernel; -use App\Controller\BaseController; use Ardent\Undercurrent\Container\ContainerInterface; use Ardent\Undercurrent\Container\GenericContainer; use Ardent\Undercurrent\Http\GenericRequest; @@ -20,12 +19,9 @@ class BaseKernel ->alias(RouterInterface::class, GenericRouter::class) ->alias(ContainerInterface::class, GenericContainer::class) ->add(GenericContainer::class, fn($container) => $container) - ->add(GenericRouter::class) - ->add(BaseController::class); + ->add(GenericRouter::class); - $container->add(RouterConfig::class, fn() => new RouterConfig([ - BaseController::class, - ])); + $this->dependencies($container); $this->render($container); } @@ -41,4 +37,17 @@ class BaseKernel $router = $container->get(RouterInterface::class); echo $router->dispatch($request)->getBody(); } + + protected function addRoutes(ContainerInterface $container, array $routes): void + { + foreach ($routes as $route) { + $container->add($route); + } + + $container->add(RouterConfig::class, fn() => new RouterConfig($routes)); + } + + protected function dependencies(ContainerInterface $container): void + { + } } \ No newline at end of file |
||
---|---|---|
.. | ||
Controller | ||
Kernel.php |