Skip to content

Commit 51c995c

Browse files
author
olaru
committed
update handler names and routes
1 parent 5cc0b94 commit 51c995c

20 files changed

Lines changed: 96 additions & 64 deletions

‎src/App/src/ConfigProvider.php‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@
2626
use Light\App\Factory\MarkdownRuntimeLoaderFactory;
2727
use Light\App\Factory\PackageGeneratorFactory;
2828
use Light\App\Factory\SitemapGeneratorFactory;
29-
use Light\App\Handler\GetContactCreateFormHandler;
29+
use Light\App\Handler\GetCreateContactFormHandler;
3030
use Light\App\Handler\GetFeedViewHandler;
3131
use Light\App\Handler\GetIndexViewHandler;
3232
use Light\App\Handler\GetMarkdownArticleHandler;
3333
use Light\App\Handler\GetPackagesViewHandler;
3434
use Light\App\Handler\GetSitemapViewHandler;
35-
use Light\App\Handler\PostContactCreateHandler;
35+
use Light\App\Handler\PostCreateContactHandler;
3636
use Light\App\Resolver\EntityListenerResolver;
3737
use Light\App\Service\ContactService;
3838
use Light\App\Service\FeedGenerator;
@@ -146,8 +146,8 @@ public function getDependencies(): array
146146
GetMarkdownArticleHandler::class => GetMarkdownArticleHandlerFactory::class,
147147
GetSitemapViewHandler::class => GetSitemapViewHandlerFactory::class,
148148
GetPackagesViewHandler::class => GetPackagesViewHandlerFactory::class,
149-
GetContactCreateFormHandler::class => AttributedServiceFactory::class,
150-
PostContactCreateHandler::class => AttributedServiceFactory::class,
149+
GetCreateContactFormHandler::class => AttributedServiceFactory::class,
150+
PostCreateContactHandler::class => AttributedServiceFactory::class,
151151
ContactService::class => AttributedServiceFactory::class,
152152
FeedGenerator::class => FeedGeneratorFactory::class,
153153
SitemapGenerator::class => SitemapGeneratorFactory::class,

src/App/src/Handler/GetContactCreateFormHandler.php renamed to src/App/src/Handler/GetCreateContactFormHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use Psr\Http\Message\ServerRequestInterface;
1414
use Psr\Http\Server\RequestHandlerInterface;
1515

16-
class GetContactCreateFormHandler implements RequestHandlerInterface
16+
class GetCreateContactFormHandler implements RequestHandlerInterface
1717
{
1818
public const string TEMPLATE = 'page::contact';
1919

src/App/src/Handler/PostContactCreateHandler.php renamed to src/App/src/Handler/PostCreateContactHandler.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace Light\App\Handler;
66

77
use Dot\DependencyInjection\Attribute\Inject;
8-
use Fig\Http\Message\StatusCodeInterface;
98
use Laminas\Diactoros\Response\HtmlResponse;
109
use Laminas\Diactoros\Response\RedirectResponse;
1110
use Light\App\Enum\ContactTopicEnum;
@@ -18,7 +17,7 @@
1817

1918
use function is_array;
2019

21-
class PostContactCreateHandler implements RequestHandlerInterface
20+
class PostCreateContactHandler implements RequestHandlerInterface
2221
{
2322
#[Inject(
2423
TemplateRendererInterface::class,
@@ -45,7 +44,7 @@ public function handle(ServerRequestInterface $request): ResponseInterface
4544
if ($errors !== [] || $mailFailed) {
4645
$rawBody = $request->getParsedBody();
4746

48-
return new HtmlResponse($this->template->render(GetContactCreateFormHandler::TEMPLATE, [
47+
return new HtmlResponse($this->template->render(GetCreateContactFormHandler::TEMPLATE, [
4948
'topics' => ContactTopicEnum::cases(),
5049
'contact_errors' => $errors,
5150
'contact_values' => $data,
@@ -55,13 +54,7 @@ public function handle(ServerRequestInterface $request): ResponseInterface
5554
}
5655

5756
return new RedirectResponse(
58-
$this->urlHelper->generate(
59-
GetContactCreateFormHandler::TEMPLATE,
60-
[],
61-
['contact' => 'sent'],
62-
'contact-form'
63-
),
64-
StatusCodeInterface::STATUS_SEE_OTHER
57+
$this->urlHelper->generate('app::create-contact-form', [], ['contact' => 'sent'], 'contact-form')
6558
);
6659
}
6760
}

‎src/App/src/RoutesDelegator.php‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44

55
namespace Light\App;
66

7-
use Light\App\Handler\GetContactCreateFormHandler;
7+
use Light\App\Handler\GetCreateContactFormHandler;
88
use Light\App\Handler\GetFeedViewHandler;
99
use Light\App\Handler\GetIndexViewHandler;
1010
use Light\App\Handler\GetMarkdownArticleHandler;
1111
use Light\App\Handler\GetPackagesViewHandler;
1212
use Light\App\Handler\GetSitemapViewHandler;
13-
use Light\App\Handler\PostContactCreateHandler;
13+
use Light\App\Handler\PostCreateContactHandler;
1414
use Mezzio\Application;
1515
use Psr\Container\ContainerInterface;
1616

@@ -27,8 +27,8 @@ public function __invoke(ContainerInterface $container, string $serviceName, cal
2727
$app->get('/sitemap/', [GetSitemapViewHandler::class], 'app::sitemap');
2828
$app->get('/{categorySlug}/{slug}.md', [GetMarkdownArticleHandler::class], 'app::markdown-article');
2929

30-
$app->get('/contact/', [GetContactCreateFormHandler::class], GetContactCreateFormHandler::TEMPLATE);
31-
$app->post('/contact/', [PostContactCreateHandler::class], 'app::create-contact');
30+
$app->get('/contact/', [GetCreateContactFormHandler::class], 'app::create-contact-form');
31+
$app->post('/contact/', [PostCreateContactHandler::class], 'app::create-contact');
3232

3333
// Route name kept as `page::…` because `@layout/default.html.twig` links it by name.
3434
// The matching entry must stay out of `routes.page` in local.php to avoid a duplicate.

‎src/App/src/Service/ContactService.php‎

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Laminas\Validator\EmailAddress;
1010
use Laminas\Validator\NotEmpty;
1111
use Light\App\Enum\ContactTopicEnum;
12+
use Psr\Log\LoggerInterface;
1213
use Throwable;
1314

1415
use function htmlspecialchars;
@@ -44,9 +45,14 @@ final class ContactService
4445

4546
private const array RESERVED_FIELDS = ['topic', 'name', 'email', 'company', 'stack', 'message', 'contact'];
4647

47-
#[Inject('dot-mail.service.contact')]
48-
public function __construct(private readonly MailServiceInterface $mailService)
49-
{
48+
#[Inject(
49+
'dot-mail.service.contact',
50+
'dot-log.default_logger',
51+
)]
52+
public function __construct(
53+
private readonly MailServiceInterface $mailService,
54+
private readonly LoggerInterface $logger,
55+
) {
5056
}
5157

5258
/**
@@ -115,10 +121,25 @@ public function send(array $data): bool
115121
$this->mailService->setBody($this->buildBody($data));
116122

117123
try {
118-
return $this->mailService->send()->isValid();
119-
} catch (Throwable) {
124+
$result = $this->mailService->send();
125+
} catch (Throwable $exception) {
126+
$this->logger->error('Contact form email could not be sent: {message}', [
127+
'message' => $exception->getMessage(),
128+
'exception' => $exception,
129+
]);
130+
120131
return false;
121132
}
133+
134+
if (! $result->isValid()) {
135+
$this->logger->error('Contact form email could not be sent: {message}', [
136+
'message' => $result->getMessage(),
137+
]);
138+
139+
return false;
140+
}
141+
142+
return true;
122143
}
123144

124145
/**

‎src/App/templates/app/index.html.twig‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@
393393
<div>
394394
<p class="about-text">Dotkernel is an open-source project created and led by the dev team at Apidemia - built first as an internal tool for handling complex architectures, now freely shared as our way of giving back to the community.</p>
395395
<div class="about-cta">
396-
<a class="btn btn-ghost" href="{{ url('page::contact') }}">See more about us -></a>
396+
<a class="btn btn-ghost" href="{{ url('app::create-contact-form') }}">See more about us -></a>
397397
</div>
398398
</div>
399399
</div>

‎src/App/templates/layout/default.html.twig‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
<li class="nav-item"><a class="nav-link" href="https://docs.dotkernel.org/" target="_blank" rel="noopener">Documentation</a></li>
6060
<li class="nav-item"><a class="nav-link" href="https://github.com/orgs/dotkernel/discussions" target="_blank" rel="noopener">Discussion</a></li>
6161
<li class="nav-item"><a class="nav-link" href="{{ url('page::blog') }}">Blog</a></li>
62-
<li class="nav-item"><a class="nav-link nav-cta mx-2 " href="{{ url('page::contact') }}">Contact us</a></li>
62+
<li class="nav-item"><a class="nav-link nav-cta mx-2 " href="{{ url('app::create-contact-form') }}">Contact us</a></li>
6363
</ul>
6464
</div>
6565
</div>
@@ -109,7 +109,7 @@
109109
<li><a href="{{ url('page::blog') }}">Blog</a></li>
110110
<li><a href="https://github.com/orgs/dotkernel/discussions" target="_blank" rel="noopener">Discussion</a></li>
111111
<li><a href="{{ url('page::about') }}">About</a></li>
112-
<li><a href="{{ url('page::contact') }}">Contact us</a></li>
112+
<li><a href="{{ url('app::create-contact-form') }}">Contact us</a></li>
113113
</ul>
114114
</div>
115115
</nav>

‎src/Blog/templates/page/JSON-LD/contact.jsonld.twig‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
{
33
"@context": "https://schema.org",
44
"@type": "ContactPage",
5-
"@id": "{{ app.url ~ path('page::contact') }}#webpage",
6-
"url": "{{ app.url ~ path('page::contact') }}",
5+
"@id": "{{ app.url ~ path('app::create-contact-form') }}#webpage",
6+
"url": "{{ app.url ~ path('app::create-contact-form') }}",
77
"name": "Contact",
88
"isPartOf": { "@id": "{{ app.url }}#website" }
99
}

‎src/Page/templates/page/about.html.twig‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
on. Everything here is made by a team that has to live with its own decisions.
4040
</p>
4141
<div class="hero-ctas">
42-
<a class="btn btn-primary" href="{{ url('page::contact') }}">Talk to us</a>
42+
<a class="btn btn-primary" href="{{ url('app::create-contact-form') }}">Talk to us</a>
4343
<a class="btn btn-ghost" href="https://github.com/dotkernel" target="_blank" rel="noopener">
4444
<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 .5a12 12 0 0 0-3.79 23.4c.6.1.83-.27.83-.58v-2.17c-3.34.73-4.04-1.42-4.04-1.42-.55-1.4-1.34-1.77-1.34-1.77-1.08-.75.09-.73.09-.73 1.2.08 1.84 1.24 1.84 1.24 1.07 1.84 2.8 1.3 3.49 1 .1-.78.42-1.3.76-1.6-2.67-.3-5.47-1.33-5.47-5.93 0-1.31.47-2.38 1.24-3.22-.13-.3-.54-1.53.12-3.18 0 0 1-.32 3.3 1.23a11.5 11.5 0 0 1 6 0c2.3-1.55 3.3-1.23 3.3-1.23.66 1.65.25 2.88.12 3.18.77.84 1.24 1.91 1.24 3.22 0 4.61-2.8 5.63-5.48 5.92.43.37.81 1.1.81 2.22v3.29c0 .31.22.69.83.57A12 12 0 0 0 12 .5z"/></svg>
4545
View on GitHub
@@ -293,7 +293,7 @@
293293
<a href="https://jb.gg/OpenSourceSupport" target="_blank" rel="noopener">JetBrains open source programme</a> -
294294
one of the ways this work stays sustainable.</p>
295295
<div class="get-started">
296-
<a href="{{ url('page::contact') }}">Work with us →</a>
296+
<a href="{{ url('app::create-contact-form') }}">Work with us →</a>
297297
</div>
298298
</div>
299299
</div>
@@ -311,7 +311,7 @@
311311
a platform, hiring a team, or just want to argue about middleware, we would rather have the
312312
conversation than the brochure.</p>
313313
<div class="about-cta">
314-
<a class="btn btn-ghost" href="{{ url('page::contact') }}">Talk to us →</a>
314+
<a class="btn btn-ghost" href="{{ url('app::create-contact-form') }}">Talk to us →</a>
315315
</div>
316316
</div>
317317
</div>

‎src/Page/templates/page/admin.html.twig‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@
655655
the interface before you install anything. Dotkernel Admin is developed and led by the dev team at
656656
Apidemia, and released as open source for the community.</p>
657657
<div class="about-cta">
658-
<a class="btn btn-ghost" href="{{ url('page::contact') }}">Talk to us →</a>
658+
<a class="btn btn-ghost" href="{{ url('app::create-contact-form') }}">Talk to us →</a>
659659
</div>
660660
</div>
661661
</div>

0 commit comments

Comments
 (0)