First working version with non working routes
This commit is contained in:
28
src/Kernel/BaseKernel.php
Normal file
28
src/Kernel/BaseKernel.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Ardent\Undercurrent\Kernel;
|
||||
|
||||
use App\Controller\BaseController;
|
||||
use Ardent\Undercurrent\Container\GenericContainer;
|
||||
use Ardent\Undercurrent\Controller\GenericRouter;
|
||||
|
||||
class BaseKernel
|
||||
{
|
||||
public function __invoke()
|
||||
{
|
||||
$container = new GenericContainer();
|
||||
$container->add(GenericRouter::class);
|
||||
$container->add(BaseController::class);
|
||||
|
||||
$this->render($container);
|
||||
}
|
||||
|
||||
private function render(GenericContainer $container): void
|
||||
{
|
||||
$router = $container->get(GenericRouter::class);
|
||||
$route = $router->getRoute($_SERVER['REQUEST_URI']);
|
||||
$controller = $container->get($route['controller']);
|
||||
$method = $route['method'];
|
||||
echo $controller->$method();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user