diff --git a/code/src/Bootstrap.php b/code/src/Bootstrap.php index ce0490a..2f366d8 100644 --- a/code/src/Bootstrap.php +++ b/code/src/Bootstrap.php @@ -7,6 +7,9 @@ use Slim\Factory\AppFactory; use League\Config\Configuration; use DI\Container; use DI\ContainerBuilder; +use Slim\Views\Twig; +use Slim\Views\TwigMiddleware; +use Slovocast\Routes; class Bootstrap { @@ -52,10 +55,7 @@ class Bootstrap */ protected static function establishRoutes(App $app): void { - $app->get('/', function ($req, $res) { - $res->getBody()->write(json_encode([ 'message' => "hello!" ])); - return $res->withHeader("Content-Type", "application/json"); - }); + Routes::init($app); } /** @@ -67,6 +67,10 @@ class Bootstrap protected static function establishMiddleware(App $app): void { $app->addErrorMiddleware(true, true, true); + + // Twig + $twig = Twig::create(__DIR__ . "../templates", [ 'cache' => false ]); + $app->add(TwigMiddleware::create($app, $twig)); } /** diff --git a/code/src/Controller/HomePage.php b/code/src/Controller/HomePage.php new file mode 100644 index 0000000..3081b73 --- /dev/null +++ b/code/src/Controller/HomePage.php @@ -0,0 +1,14 @@ +render('home'); + } +} diff --git a/code/src/Controller/User/RegisterUserAction.php b/code/src/Controller/User/RegisterUserAction.php index 5f3d3a6..1427209 100644 --- a/code/src/Controller/User/RegisterUserAction.php +++ b/code/src/Controller/User/RegisterUserAction.php @@ -9,6 +9,6 @@ class RegisterUserAction extends Controller { public function respond(): Response { - return $this->respond('user/register/success'); + return $this->respond('users/register/success'); } } diff --git a/code/src/Controller/User/RegisterUserPage.php b/code/src/Controller/User/RegisterUserPage.php index 02f60ce..d2943fe 100644 --- a/code/src/Controller/User/RegisterUserPage.php +++ b/code/src/Controller/User/RegisterUserPage.php @@ -9,6 +9,6 @@ class RegisterUserPage extends Controller { public function respond(): Response { - return $this->render('user/register'); + return $this->render('users/register'); } } diff --git a/code/templates/home.twig b/code/templates/home.twig new file mode 100644 index 0000000..9629149 --- /dev/null +++ b/code/templates/home.twig @@ -0,0 +1,7 @@ +{% extends 'layouts/skeleton' %} + +{% block "content" %} +