-
Notifications
You must be signed in to change notification settings - Fork 2
Removed dotkernel/dot-controller and replaced with handlers #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6f1ca1e
00f1846
ef2593b
d34d42f
c75d678
975b5dc
ceb6062
bc0446c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Light\App\Factory; | ||
|
|
||
| use Light\App\Handler\IndexHandler; | ||
| use Mezzio\Template\TemplateRendererInterface; | ||
| use Psr\Container\ContainerExceptionInterface; | ||
| use Psr\Container\ContainerInterface; | ||
| use Psr\Container\NotFoundExceptionInterface; | ||
|
|
||
| use function assert; | ||
|
|
||
| class IndexHandlerFactory | ||
| { | ||
| /** | ||
| * @param class-string $requestedName | ||
| * @throws ContainerExceptionInterface | ||
| * @throws NotFoundExceptionInterface | ||
| */ | ||
| public function __invoke(ContainerInterface $container, string $requestedName): IndexHandler | ||
MarioRadu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| $template = $container->get(TemplateRendererInterface::class); | ||
| assert($template instanceof TemplateRendererInterface); | ||
|
|
||
| return new IndexHandler($template); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Light\App\Handler; | ||
|
|
||
| use Laminas\Diactoros\Response\HtmlResponse; | ||
| use Mezzio\Template\TemplateRendererInterface; | ||
| use Psr\Http\Message\ResponseInterface; | ||
| use Psr\Http\Message\ServerRequestInterface; | ||
| use Psr\Http\Server\RequestHandlerInterface; | ||
|
|
||
| class IndexHandler implements RequestHandlerInterface | ||
| { | ||
| public function __construct( | ||
| protected TemplateRendererInterface $template | ||
| ) { | ||
| } | ||
|
|
||
| public function handle(ServerRequestInterface $request): ResponseInterface | ||
| { | ||
| return new HtmlResponse( | ||
| $this->template->render('app::index') | ||
| ); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Light\App; | ||
|
|
||
| use Light\App\Handler\IndexHandler; | ||
| use Mezzio\Application; | ||
| use Psr\Container\ContainerInterface; | ||
|
|
||
| use function assert; | ||
|
|
||
| class RoutesDelegator | ||
| { | ||
| public function __invoke(ContainerInterface $container, string $serviceName, callable $callback): Application | ||
| { | ||
| $app = $callback(); | ||
| assert($app instanceof Application); | ||
|
|
||
| $app->get('/', [IndexHandler::class], 'app::index'); | ||
|
|
||
| return $app; | ||
| } | ||
| } | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| {% extends '@layout/default.html.twig' %} | ||
|
|
||
| {% block title %}{{ status }} {{ reason }}{% endblock %} | ||
| {% block canonical %}{% endblock %} | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @arhimede
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should not bother to have a canonical in 404 pages
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As I said:
My question was if we should have a canonical URL on a 500 (or any other non-404) page.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nope, useless |
||
|
|
||
| {% block content %} | ||
| <div class="page-intro home-intro error-messages"> | ||
|
|
@@ -9,12 +10,6 @@ | |
| <h2>This is awkward.</h2> | ||
| <h1>{{ status }}</h1> | ||
| <h2 class="message">{{ reason }}</h2> | ||
| {% if status == 404 %} | ||
| <p> | ||
| You are looking for something that doesn't exist or may have moved. Check out one of the links on this page | ||
| or head back to <a href="{{ path('home') }}">Home</a>. | ||
| </p> | ||
| {% endif %} | ||
| </div> | ||
| </div> | ||
| {% endblock %} | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Light\Page\Handler; | ||
|
|
||
| use Laminas\Diactoros\Response\HtmlResponse; | ||
| use Mezzio\Router\RouteResult; | ||
| use Mezzio\Template\TemplateRendererInterface; | ||
| use Psr\Http\Message\ResponseInterface; | ||
| use Psr\Http\Message\ServerRequestInterface; | ||
| use Psr\Http\Server\RequestHandlerInterface; | ||
|
|
||
| class PageHandler implements RequestHandlerInterface | ||
| { | ||
| public function __construct( | ||
| protected TemplateRendererInterface $template, | ||
| ) { | ||
| } | ||
|
|
||
| public function handle(ServerRequestInterface $request): ResponseInterface | ||
| { | ||
| $template = $request->getAttribute(RouteResult::class)->getMatchedRouteName(); | ||
|
|
||
| return new HtmlResponse( | ||
| $this->template->render($template) | ||
| ); | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.