-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Adds Event before sending out testmail
This event can be used to deactivate the internal sending of test emails and implement your own logic, e.g. sending test newsletters via a separate queue. Relates to: https://projekte.in2code.de/issues/61246
- Loading branch information
1 parent
eda7e11
commit bc27dd3
Showing
5 changed files
with
176 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
namespace In2code\Luxletter\Events; | ||
|
||
use Psr\Http\Message\ServerRequestInterface; | ||
|
||
final class AfterTestMailButtonClickedEvent | ||
{ | ||
const STATUS_SEVERITY_SUCCESS = 'alert-success'; | ||
const STATUS_SEVERITY_WARNING = 'alert-warning'; | ||
const STATUS_SEVERITY_ERROR = 'alert-danger'; | ||
|
||
protected bool $testMailIsSendExternal = false; | ||
|
||
protected bool $status = false; | ||
|
||
protected string $statusTitle = ''; | ||
|
||
protected string $statusMessage = ''; | ||
|
||
protected string $statusSeverity = self::STATUS_SEVERITY_ERROR; | ||
|
||
protected ServerRequestInterface $request; | ||
|
||
public function isTestMailIsSendExternal(): bool | ||
{ | ||
return $this->testMailIsSendExternal; | ||
} | ||
|
||
public function setTestMailIsSendExternal(bool $testMailIsSendExternal): void | ||
{ | ||
$this->testMailIsSendExternal = $testMailIsSendExternal; | ||
} | ||
|
||
public function getStatus(): bool | ||
{ | ||
return $this->status; | ||
} | ||
|
||
public function setStatus(bool $status): void | ||
{ | ||
$this->status = $status; | ||
} | ||
|
||
public function getRequest(): ServerRequestInterface | ||
{ | ||
return $this->request; | ||
} | ||
|
||
public function setRequest(ServerRequestInterface $request): void | ||
{ | ||
$this->request = $request; | ||
} | ||
|
||
public function getStatusTitle(): string | ||
{ | ||
return $this->statusTitle; | ||
} | ||
|
||
public function setStatusTitle(string $statusTitle): void | ||
{ | ||
$this->statusTitle = $statusTitle; | ||
} | ||
|
||
public function getStatusMessage(): string | ||
{ | ||
return $this->statusMessage; | ||
} | ||
|
||
public function setStatusMessage(string $statusMessage): void | ||
{ | ||
$this->statusMessage = $statusMessage; | ||
} | ||
|
||
public function getStatusSeverity(): string | ||
{ | ||
return $this->statusSeverity; | ||
} | ||
|
||
public function setStatusSeverity(string $statusSeverity): void | ||
{ | ||
$this->statusSeverity = $statusSeverity; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<img align="left" src="../../Resources/Public/Icons/lux.svg" width="50" /> | ||
|
||
# Luxletter - Email marketing in TYPO3. Send newsletters the easy way. | ||
|
||
## Events | ||
|
||
There are many events that can be used to extend Luxletter. | ||
This documentation is under construction and not all events are documented yet. | ||
|
||
### AfterTestMailButtonClickedEvent | ||
|
||
This event can be used to deactivate the internal sending of test emails and implement your own logic, e.g. sending test newsletters via a separate queue. | ||
|
||
To deactivate the internal logic, the `$testMailIsSendExternal` property of the event must be set to true. | ||
If the general status `$status` is set to `false`, no message is shown. | ||
If the general status `$status` is set to `true`, a message with the properties `$statusTitle`, `$statusMessage` and `$statusSeverity` is shown. | ||
The values for `$statusSeverity` can be `AfterTestMailButtonClickedEvent::STATUS_SEVERITY_SUCCESS`, `AfterTestMailButtonClickedEvent::STATUS_SEVERITY_WARNING` and `AfterTestMailButtonClickedEvent::STATUS_SEVERITY_ERROR`, the default value is `AfterTestMailButtonClickedEvent::STATUS_SEVERITY_ERROR`. | ||
|
||
The `$request` property is available in the event, from which all necessary data can be obtained to send the test e-mail. | ||
|
||
Sample Eventlistener: | ||
|
||
``` | ||
<?php | ||
declare(strict_types=1); | ||
namespace Vendor\Extension\EventListener; | ||
use In2code\Luxletter\Events\AfterTestMailButtonClickedEvent; | ||
final class DemoEventlistener | ||
{ | ||
public function __invoke(AfterTestMailButtonClickedEvent $event): void | ||
{ | ||
$event->setTestMailIsSendExternal(true); | ||
// ... handle email sending | ||
$event->setStatus(true); | ||
$event->setStatusSeverity(AfterTestMailButtonClickedEvent::STATUS_SEVERITY_SUCCESS); | ||
$event->setStatusTitle('Success'); | ||
$event->setStatusMessage('The test email is successfully added to the queue'); | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.