-
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] Add two basic events to LUXletter
1) to stop testmails and implement own testmail service 2) to set own bodytext for newsletter mails Related: https://github.com/in2code-de/luxletter/pull/205/files
- Loading branch information
1 parent
9ecde16
commit b16c18f
Showing
9 changed files
with
290 additions
and
16 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
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,96 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
namespace In2code\Luxletter\Events; | ||
|
||
use Psr\Http\Message\ServerRequestInterface; | ||
|
||
final class AfterTestMailButtonClickedEvent | ||
{ | ||
public const STATUS_SEVERITY_SUCCESS = 'alert-success'; | ||
public const STATUS_SEVERITY_WARNING = 'alert-warning'; | ||
public const STATUS_SEVERITY_ERROR = 'alert-danger'; | ||
|
||
protected ServerRequestInterface $request; | ||
|
||
protected bool $testMailIsSendExternal = false; | ||
protected bool $status = false; | ||
|
||
protected string $statusTitle = ''; | ||
protected string $statusMessage = ''; | ||
protected string $statusSeverity = self::STATUS_SEVERITY_ERROR; | ||
|
||
public function __construct(ServerRequestInterface $request) | ||
{ | ||
$this->request = $request; | ||
} | ||
|
||
public function getRequest(): ServerRequestInterface | ||
{ | ||
return $this->request; | ||
} | ||
|
||
public function isTestMailIsSendExternal(): bool | ||
{ | ||
return $this->testMailIsSendExternal; | ||
} | ||
|
||
public function setTestMailIsSendExternal(): self | ||
{ | ||
$this->testMailIsSendExternal = true; | ||
return $this; | ||
} | ||
|
||
public function getStatus(): bool | ||
{ | ||
return $this->status; | ||
} | ||
|
||
public function setStatus(bool $status): self | ||
{ | ||
$this->status = $status; | ||
return $this; | ||
} | ||
|
||
public function getStatusTitle(): string | ||
{ | ||
return $this->statusTitle; | ||
} | ||
|
||
public function setStatusTitle(string $statusTitle): self | ||
{ | ||
$this->statusTitle = $statusTitle; | ||
return $this; | ||
} | ||
|
||
public function getStatusMessage(): string | ||
{ | ||
return $this->statusMessage; | ||
} | ||
|
||
public function setStatusMessage(string $statusMessage): self | ||
{ | ||
$this->statusMessage = $statusMessage; | ||
return $this; | ||
} | ||
|
||
public function getStatusSeverity(): string | ||
{ | ||
return $this->statusSeverity; | ||
} | ||
|
||
public function setStatusSeverity(string $statusSeverity): self | ||
{ | ||
$this->statusSeverity = $statusSeverity; | ||
return $this; | ||
} | ||
|
||
public function getStatusResponse(): array | ||
{ | ||
return [ | ||
'statusTitle' => $this->getStatusTitle(), | ||
'statusMessage' => $this->getStatusMessage(), | ||
'statusSeverity' => $this->getStatusSeverity(), | ||
]; | ||
} | ||
} |
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,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
namespace In2code\Luxletter\Events; | ||
|
||
use In2code\Luxletter\Domain\Model\Queue; | ||
|
||
final class BeforeBodytextIsParsedEvent | ||
{ | ||
protected Queue $queue; | ||
|
||
protected string $bodytext = ''; | ||
|
||
public function __construct(Queue $queue) | ||
{ | ||
$this->queue = $queue; | ||
$this->bodytext = $queue->getNewsletter()->getBodytext(); | ||
} | ||
|
||
public function getQueue(): Queue | ||
{ | ||
return $this->queue; | ||
} | ||
|
||
public function getBodytext(): string | ||
{ | ||
return $this->bodytext; | ||
} | ||
|
||
public function setBodytext(string $bodytext): self | ||
{ | ||
$this->bodytext = $bodytext; | ||
return $this; | ||
} | ||
} |
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
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,70 @@ | ||
<img align="left" src="../../Resources/Public/Icons/lux.svg" width="50" /> | ||
|
||
# Luxletter - Email marketing in TYPO3. Send newsletters the easy way. | ||
|
||
## Events | ||
|
||
There are some 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` should 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'); | ||
} | ||
} | ||
``` | ||
|
||
### BeforeBodytextIsParsedEvent | ||
|
||
This event is executed before the body text for the individual newsletter is processed. The event can be used to change or reset the body text that is used for parsing. | ||
|
||
The `$queue` property is available in the event, which can be used to access all relevant data for the newsletter. | ||
If the `$bodytext` property is set via an event listener, the content of this property is used for further processing. If there is no content in the property, the standard text from the newsletter is used. | ||
|
||
Sample Eventlistener: | ||
|
||
``` | ||
<?php | ||
declare(strict_types=1); | ||
namespace Vendor\Extension\EventListener; | ||
use In2code\Luxletter\Events\AfterTestMailButtonClickedEvent; | ||
use In2code\Luxletter\Events\BeforeBodytextIsParsedEvent; | ||
final class DemoEventlistener | ||
{ | ||
public function __invoke(BeforeBodytextIsParsedEvent $event): void | ||
{ | ||
$event->setBodytext('<h1>I am the new body</h1>'); | ||
} | ||
} | ||
``` |
Oops, something went wrong.