diff --git a/code/src/Controller/Controller.php b/code/src/Controller/Controller.php new file mode 100644 index 0000000..4fefc92 --- /dev/null +++ b/code/src/Controller/Controller.php @@ -0,0 +1,57 @@ +request = $request; + $this->response = $response; + $this->args = $args; + $this->routeContext = RouteContext::fromRequest($this->request); + + return $this->respond($request, $response); + } + + /** + * Implement this method for handling the request. + * + * @return Response + */ + abstract public function respond(): Response; + + /** + * Render the given Template. + * + * @param string $templateName The name of the template + * @param array $data The data for the template + * @return Response + */ + public function render(string $templateName, array $data = []): Response + { + $view = Twig::fromRequest($this->request); + return $view->render($this->response, $templateName, $data); + } +} diff --git a/code/src/Controller/User/RegisterUserAction.php b/code/src/Controller/User/RegisterUserAction.php new file mode 100644 index 0000000..5f3d3a6 --- /dev/null +++ b/code/src/Controller/User/RegisterUserAction.php @@ -0,0 +1,14 @@ +respond('user/register/success'); + } +} diff --git a/code/src/Controller/User/RegisterUserPage.php b/code/src/Controller/User/RegisterUserPage.php new file mode 100644 index 0000000..02f60ce --- /dev/null +++ b/code/src/Controller/User/RegisterUserPage.php @@ -0,0 +1,14 @@ +render('user/register'); + } +} diff --git a/code/src/Routes.php b/code/src/Routes.php new file mode 100644 index 0000000..fcd6c42 --- /dev/null +++ b/code/src/Routes.php @@ -0,0 +1,24 @@ +get('/users/register', RegisterUserPage::class); + $app->post('/users/register', RegisterUserAction::class); + } +}