From 8e81bf20a6ae10ed1890d3dea6315435f58b4811 Mon Sep 17 00:00:00 2001 From: "Eric Richer eric.richer@vistoconsulting.com" Date: Wed, 10 Apr 2024 10:47:34 -0400 Subject: [PATCH] Minor update lmc-mail docs to correct typos --- docs/lmc-mail/Configuration.md | 5 ++++- docs/lmc-mail/Introduction.md | 5 +++-- docs/lmc-mail/Usage.md | 4 ++-- docs/lmc-mail/advanced-customization.md | 20 ++++++++++++++------ 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/docs/lmc-mail/Configuration.md b/docs/lmc-mail/Configuration.md index 4a0163b..d6b8bcb 100644 --- a/docs/lmc-mail/Configuration.md +++ b/docs/lmc-mail/Configuration.md @@ -37,7 +37,10 @@ return [ ], ]; ``` -In a development environment, it is typical to use a File Mail Transport. In a production environment, an SMTP Mail Transport will more likely be used. +In a production environment, an SMTP Mail Transport will more likely be used. + +In a development environment, it is typical to use a File Mail Transport to write message to files to validate the +rendered output. The `'transport'` configuration must comply with the `Laminas\Mail\Transport\Factory\Factory::create` method. diff --git a/docs/lmc-mail/Introduction.md b/docs/lmc-mail/Introduction.md index fb41b7e..9af8bcd 100644 --- a/docs/lmc-mail/Introduction.md +++ b/docs/lmc-mail/Introduction.md @@ -2,11 +2,12 @@ sidebar_position: 1 --- -LmcMail is an email service module that provides the ability to use the View renderer of a Laminas MVC application +LmcMail is an email service module that provides the ability to use the View Manager of a Laminas MVC application and the installed View Helper plugins to render HTML emails. ## Requirements - PHP 8.1 or higher -- Laminas MVC +- Laminas View +- Laminas Mail diff --git a/docs/lmc-mail/Usage.md b/docs/lmc-mail/Usage.md index c8214d5..3f1ca99 100644 --- a/docs/lmc-mail/Usage.md +++ b/docs/lmc-mail/Usage.md @@ -9,7 +9,7 @@ $messageService = $serviceManager->get(LmcMail\Service\MessageService::class); Basic example to send an HTML email: -````php +```php $viewModel = new \Laminas\View\Model\ViewModel(); $viewModel->setTemplate('mail/html'); $message = $messageService->createHtmlMessage( @@ -19,7 +19,7 @@ $message = $messageService->createHtmlMessage( $viewModel); // View model $messageService->send($message); -```` +``` The `'mail/html'` template must exist in the application's view template map. The HTML mail renderer will use a layout template aliased as `'mail/layout'` in the view template map. This is defined in the `module.config.php` file. diff --git a/docs/lmc-mail/advanced-customization.md b/docs/lmc-mail/advanced-customization.md index 04e7e1f..d8efc68 100644 --- a/docs/lmc-mail/advanced-customization.md +++ b/docs/lmc-mail/advanced-customization.md @@ -1,5 +1,6 @@ --- sidebar_position: 5 +title: Advanced Configuration --- LmcMail can be customized to the applications needs. @@ -8,18 +9,24 @@ LmcMail can be customized to the applications needs. LmcMail uses nested view models to render the body of HTML messages. In a similar fashion to the view model structure of the Laminas MVC Skeleton, -the body is rendered using a layout view model to which the view model parameter (`$nameOrModel`) to the `createHtmlMessage` method is added a child. +the body is rendered using a layout view model to which the view model parameter (`$nameOrModel`) to the +`createHtmlMessage` method is added a child. The rendered output of the `$nameOrModel` view model is captured in the variable `message` which is passed to the layout view model. -A default template `mail/layout` is supplied is `view/layout/layout.phtml`. This template can be the starting point for your own layout template. +A default template `'mail/layout'` is supplied in `lm-commons/lmc-mail/view/layout/layout.phtml`. This template can be +the starting point for your own layout template. The layout template can be set using the `setLayoutTemplate()` method. Alternatively, -the `mail/layout` entry in the View Manager template map can be overridden to point to your template. Another alternative is to use a factory delegator to the `MessageServiceFactory::class` to set the layout template after the Message Service is created. +the `'mail/layout'` entry in the View Manager template map can be overridden to point to your template. Another +alternative is to use a factory delegator to the `MessageServiceFactory::class` to set the layout template after the +Message Service is created. -View Helpers can be used when rendering view models. A common use case is to use `$this->url()` to render a link to your application. +View Helpers can be used when rendering view models. A common use case is to use `$this->url()` to render a link to your +application. #### Use alternate View Resolved and View Helper Manager -LmcMail uses Service Manager aliases to get the View Resolver and View Helper Manager which resolves to the Laminas MVC resolver and manager. This allows to use any view template and helpers already defined in the application. +LmcMail uses Service Manager aliases to get the View Resolver and View Helper Manager which resolves to the +Laminas MVC View resolver and manager. This allows to use any view template and helpers already defined in the application. ````php 'aliases' => [ @@ -54,7 +61,8 @@ If you want to use your own renderer, then you can override the Service Manager - `MessageEvent::SEND` is triggered right before the message is sent by the transport service. - `MessageEvent::SEND_POST` is triggered right after the message has been sent by the transport service. -The listener to these events will receive an event of class`MessageEvent` that extends the `Event` class with: +A listener to these events will receive an event of class `LmcMail\Service\MessageEvent` that extends the `\Laminas\EventManager\Event` +class with: - A `$message` property containing the message. The message is also stored in an event parameter named 'message'. - A `getMessage()` method to get the `$message` property.