You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/book/v6/core-features/rendering-and-sending-emails.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,24 +1,24 @@
1
1
# Rendering and sending emails
2
2
3
-
In the previous versions of Dotkernel API we have been composing email bodies using **Twig** from the `mezzio/mezzio-twigrenderer` package.\
3
+
In the previous versions of Dotkernel API we have been composing email bodies using **Twig** from the `mezzio/mezzio-twigrenderer` package.
4
4
In the current version of Dotkernel API, we introduced the core mail service `Core/src/App/src/Service/MailService` which is responsible for sending all emails.
5
5
6
-
Being a core service, `MailService` is used across all projects implementing the Core architecture.\
6
+
Being a core service, `MailService` is used across all projects implementing the Core architecture.
7
7
To compose and send an email, a solid implementation of `TemplateRendererInterface` was required to be injected into `MailService`, because each method rendered and parsed their respective templates in place before sending an email.
8
8
This is acceptable with other Dotkernel applications which in most cases return a rendered template, but being that Dotkernel API mostly returns JSON objects, rendered with a different renderer, **Twig** had to be replaced with a lighter solution.
9
9
10
-
The solution is a custom [`Api\App\Template\Renderer`](https://github.com/dotkernel/api/blob/6.0/src/App/src/Template/Renderer.php) implementing [`Api\App\Template\RendererInterface`](https://github.com/dotkernel/api/blob/6.0/src/App/src/Template/RendererInterface.php).\
10
+
The solution is a custom [`Api\App\Template\Renderer`](https://github.com/dotkernel/api/blob/6.0/src/App/src/Template/Renderer.php) implementing [`Api\App\Template\RendererInterface`](https://github.com/dotkernel/api/blob/6.0/src/App/src/Template/RendererInterface.php).
11
11
This is a lightweight renderer, aimed at rendering a combination of **PHP** and **HTML** files with `phtml` extension.
12
12
13
-
With the new solution, `MailService` requires no implementation of any renderer because it no longer has to render templates internally.\
13
+
With the new solution, `MailService` requires no implementation of any renderer because it no longer has to render templates internally.
14
14
Instead, an implementation of `Api\App\Template\RendererInterface` is first injected in the handler:
15
15
16
16
```php
17
17
class ExampleHandler extends AbstractHandler
18
18
{
19
19
#[Inject(
20
-
MailService::class,
21
-
RendererInterface::class,
20
+
MailService::class,
21
+
RendererInterface::class,
22
22
)]
23
23
public function __construct(
24
24
protected MailService $mailService,
@@ -41,4 +41,4 @@ And finally, the handler calls the mail service with the composed $body being pa
0 commit comments