Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #47191 [Mailer] Add a way to inject Stamps when sending an em…
…ail via Messenger (fabpot) This PR was merged into the 6.2 branch. Discussion ---------- [Mailer] Add a way to inject Stamps when sending an email via Messenger | Q | A | ------------- | --- | Branch? | 6.2 | Bug fix? | no | New feature? | yes <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | n/a <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT | Doc PR | In #47190, we add a way to add a specific stamp to the message sent to the Messenger bus. I think we should make this possibility more generic. Commits ------- 77381fa [Mailer] Add a way to inject Stamps when sending an email via Messenger
- Loading branch information
Showing
4 changed files
with
62 additions
and
5 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
45 changes: 45 additions & 0 deletions
45
src/Symfony/Component/Mailer/Event/QueuingMessageEvent.php
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,45 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Mailer\Event; | ||
|
||
use Symfony\Component\Mailer\Envelope; | ||
use Symfony\Component\Messenger\Stamp\StampInterface; | ||
use Symfony\Component\Mime\RawMessage; | ||
|
||
/** | ||
* Allows the transformation of a Message, the Envelope, and the Messenger stamps before the email is sent to the Messenger bus. | ||
* | ||
* @author Fabien Potencier <fabien@symfony.com> | ||
*/ | ||
final class QueuingMessageEvent extends MessageEvent | ||
{ | ||
/** @var StampInterface[] */ | ||
private array $stamps = []; | ||
|
||
public function __construct(RawMessage $message, Envelope $envelope, string $transport) | ||
{ | ||
parent::__construct($message, $envelope, $transport, true); | ||
} | ||
|
||
public function addStamp(StampInterface $stamp): void | ||
{ | ||
$this->stamps[] = $stamp; | ||
} | ||
|
||
/** | ||
* @return StampInterface[] | ||
*/ | ||
public function getStamps(): array | ||
{ | ||
return $this->stamps; | ||
} | ||
} |
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