Move from 'respond' to 'handle' for the controller method.

This commit is contained in:
Dave Smith-Hayes 2024-06-16 21:25:22 -04:00
parent 98c34efea5
commit 079bcb0f06
8 changed files with 14 additions and 14 deletions

View File

@ -7,7 +7,7 @@ use Slovocast\Controller\Controller;
class CreateChannelPage extends Controller class CreateChannelPage extends Controller
{ {
public function respond(): Response public function handle(): Response
{ {
// set up the form key // set up the form key
return $this->render('channel/create.twig'); return $this->render('channel/create.twig');

View File

@ -34,7 +34,7 @@ abstract class Controller
$this->routeContext = RouteContext::fromRequest($this->request); $this->routeContext = RouteContext::fromRequest($this->request);
$this->view = Twig::fromRequest($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 * @return Response
*/ */
abstract public function respond(): Response; abstract public function handle(): Response;
/** /**
* Render the given Template. * Render the given Template.

View File

@ -6,7 +6,7 @@ use Psr\Http\Message\ResponseInterface as Response;
class HomePage extends Controller class HomePage extends Controller
{ {
public function respond(): Response public function handle(): Response
{ {
return $this->render('home.twig'); return $this->render('home.twig');
} }

View File

@ -7,7 +7,7 @@ use Slovocast\Controller\Controller;
class LoginUserPage extends Controller class LoginUserPage extends Controller
{ {
public function respond(): Response public function handle(): Response
{ {
return $this->render('user/login'); return $this->render('user/login');
} }

View File

@ -15,7 +15,7 @@ class RegisterUserAction extends Controller
protected SessionInterface $session protected SessionInterface $session
) { } ) { }
public function respond(): Response public function handle(): Response
{ {
$requestData = $this->request->getParsedBody(); $requestData = $this->request->getParsedBody();
$user = User::fromArray([ $user = User::fromArray([

View File

@ -7,7 +7,7 @@ use Slovocast\Controller\Controller;
class RegisterUserPage extends Controller class RegisterUserPage extends Controller
{ {
public function respond(): Response public function handle(): Response
{ {
return $this->render('user/register.twig'); return $this->render('user/register.twig');
} }

View File

@ -5,8 +5,8 @@ namespace Slovocast\Infrastructure\User;
use Slovocast\Infrastructure\User\UserAuthorizationInterface; use Slovocast\Infrastructure\User\UserAuthorizationInterface;
/** /**
* This empty class will essentially just check hashed passwords passed * This empty class will essentially just check hashed passwords passed into it
* into it using the default `password_` functions from PHP. * using the default `password_` functions from PHP.
*/ */
class BasicUserAuthorization implements UserAuthorizationInterface class BasicUserAuthorization implements UserAuthorizationInterface
{ {

View File

@ -12,7 +12,7 @@ class ControllerTest extends TestCase
public function testHtmlInlineResponse(): void public function testHtmlInlineResponse(): void
{ {
$testController = new class extends Controller { $testController = new class extends Controller {
public function respond(): Response public function handle(): Response
{ {
return $this->renderInline( return $this->renderInline(
'<p>{{ name }}</p>', '<p>{{ name }}</p>',
@ -33,7 +33,7 @@ class ControllerTest extends TestCase
public function testHtmlInlineResponseCodes(): void public function testHtmlInlineResponseCodes(): void
{ {
$testController = new class extends Controller { $testController = new class extends Controller {
public function respond(): Response public function handle(): Response
{ {
$response = $this->renderInline( $response = $this->renderInline(
'<p>{{ name }}</p>', '<p>{{ name }}</p>',
@ -58,7 +58,7 @@ class ControllerTest extends TestCase
public function testJsonResponse(): void public function testJsonResponse(): void
{ {
$testController = new class extends Controller { $testController = new class extends Controller {
public function respond(): Response public function handle(): Response
{ {
return $this->json([ 'data' => 'hello' ]); return $this->json([ 'data' => 'hello' ]);
} }
@ -84,7 +84,7 @@ class ControllerTest extends TestCase
public function testRenderSiteName(): void public function testRenderSiteName(): void
{ {
$testController = new class extends Controller { $testController = new class extends Controller {
public function respond(): Response public function handle(): Response
{ {
return $this->renderInline("<h1>{{ site_name }}</h1>"); return $this->renderInline("<h1>{{ site_name }}</h1>");
} }
@ -112,7 +112,7 @@ class ControllerTest extends TestCase
$this->session = $session; $this->session = $session;
} }
public function respond(): Response public function handle(): Response
{ {
$this->session->getFlash()->add("error", "Error message"); $this->session->getFlash()->add("error", "Error message");
return $this->response; return $this->response;