From 079bcb0f066301d642e649a22922309e13d6ed6d Mon Sep 17 00:00:00 2001 From: Dave Smith-Hayes Date: Sun, 16 Jun 2024 21:25:22 -0400 Subject: [PATCH] Move from 'respond' to 'handle' for the controller method. --- app/src/Controller/Channel/CreateChannelPage.php | 2 +- app/src/Controller/Controller.php | 4 ++-- app/src/Controller/HomePage.php | 2 +- app/src/Controller/User/LoginUserPage.php | 2 +- app/src/Controller/User/RegisterUserAction.php | 2 +- app/src/Controller/User/RegisterUserPage.php | 2 +- app/src/Infrastructure/User/BasicUserAuthorization.php | 4 ++-- app/tests/Controller/ControllerTest.php | 10 +++++----- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/app/src/Controller/Channel/CreateChannelPage.php b/app/src/Controller/Channel/CreateChannelPage.php index 595f573..037124e 100644 --- a/app/src/Controller/Channel/CreateChannelPage.php +++ b/app/src/Controller/Channel/CreateChannelPage.php @@ -7,7 +7,7 @@ use Slovocast\Controller\Controller; class CreateChannelPage extends Controller { - public function respond(): Response + public function handle(): Response { // set up the form key return $this->render('channel/create.twig'); diff --git a/app/src/Controller/Controller.php b/app/src/Controller/Controller.php index 00c0933..8b2ac0a 100644 --- a/app/src/Controller/Controller.php +++ b/app/src/Controller/Controller.php @@ -34,7 +34,7 @@ abstract class Controller $this->routeContext = RouteContext::fromRequest($this->request); $this->view = Twig::fromRequest($request); - return $this->respond($request, $response); + return $this->handle($request, $response); } /** @@ -42,7 +42,7 @@ abstract class Controller * * @return Response */ - abstract public function respond(): Response; + abstract public function handle(): Response; /** * Render the given Template. diff --git a/app/src/Controller/HomePage.php b/app/src/Controller/HomePage.php index cab9b84..738e5ea 100644 --- a/app/src/Controller/HomePage.php +++ b/app/src/Controller/HomePage.php @@ -6,7 +6,7 @@ use Psr\Http\Message\ResponseInterface as Response; class HomePage extends Controller { - public function respond(): Response + public function handle(): Response { return $this->render('home.twig'); } diff --git a/app/src/Controller/User/LoginUserPage.php b/app/src/Controller/User/LoginUserPage.php index fc87cb9..3ae37ca 100644 --- a/app/src/Controller/User/LoginUserPage.php +++ b/app/src/Controller/User/LoginUserPage.php @@ -7,7 +7,7 @@ use Slovocast\Controller\Controller; class LoginUserPage extends Controller { - public function respond(): Response + public function handle(): Response { return $this->render('user/login'); } diff --git a/app/src/Controller/User/RegisterUserAction.php b/app/src/Controller/User/RegisterUserAction.php index 947bbe6..d92795a 100644 --- a/app/src/Controller/User/RegisterUserAction.php +++ b/app/src/Controller/User/RegisterUserAction.php @@ -15,7 +15,7 @@ class RegisterUserAction extends Controller protected SessionInterface $session ) { } - public function respond(): Response + public function handle(): Response { $requestData = $this->request->getParsedBody(); $user = User::fromArray([ diff --git a/app/src/Controller/User/RegisterUserPage.php b/app/src/Controller/User/RegisterUserPage.php index d4c1ff4..a98d4a7 100644 --- a/app/src/Controller/User/RegisterUserPage.php +++ b/app/src/Controller/User/RegisterUserPage.php @@ -7,7 +7,7 @@ use Slovocast\Controller\Controller; class RegisterUserPage extends Controller { - public function respond(): Response + public function handle(): Response { return $this->render('user/register.twig'); } diff --git a/app/src/Infrastructure/User/BasicUserAuthorization.php b/app/src/Infrastructure/User/BasicUserAuthorization.php index 2146b3f..7ece89e 100644 --- a/app/src/Infrastructure/User/BasicUserAuthorization.php +++ b/app/src/Infrastructure/User/BasicUserAuthorization.php @@ -5,8 +5,8 @@ namespace Slovocast\Infrastructure\User; use Slovocast\Infrastructure\User\UserAuthorizationInterface; /** - * This empty class will essentially just check hashed passwords passed - * into it using the default `password_` functions from PHP. + * This empty class will essentially just check hashed passwords passed into it + * using the default `password_` functions from PHP. */ class BasicUserAuthorization implements UserAuthorizationInterface { diff --git a/app/tests/Controller/ControllerTest.php b/app/tests/Controller/ControllerTest.php index 1309e1e..747f767 100644 --- a/app/tests/Controller/ControllerTest.php +++ b/app/tests/Controller/ControllerTest.php @@ -12,7 +12,7 @@ class ControllerTest extends TestCase public function testHtmlInlineResponse(): void { $testController = new class extends Controller { - public function respond(): Response + public function handle(): Response { return $this->renderInline( '

{{ name }}

', @@ -33,7 +33,7 @@ class ControllerTest extends TestCase public function testHtmlInlineResponseCodes(): void { $testController = new class extends Controller { - public function respond(): Response + public function handle(): Response { $response = $this->renderInline( '

{{ name }}

', @@ -58,7 +58,7 @@ class ControllerTest extends TestCase public function testJsonResponse(): void { $testController = new class extends Controller { - public function respond(): Response + public function handle(): Response { return $this->json([ 'data' => 'hello' ]); } @@ -84,7 +84,7 @@ class ControllerTest extends TestCase public function testRenderSiteName(): void { $testController = new class extends Controller { - public function respond(): Response + public function handle(): Response { return $this->renderInline("

{{ site_name }}

"); } @@ -112,7 +112,7 @@ class ControllerTest extends TestCase $this->session = $session; } - public function respond(): Response + public function handle(): Response { $this->session->getFlash()->add("error", "Error message"); return $this->response;