-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* IBX-8137: Moved from swift mailer to symfony mailer * Dropped null sms related messages * Dropped checks for configured notifier as it just silently fails if config is missing * Added promotion constructor notation * Moved phpdoc to union typehint * Update src/contracts/Notification/UserInvitation.php Co-authored-by: Konrad Oboza <[email protected]> --------- Co-authored-by: Konrad Oboza <[email protected]>
- Loading branch information
1 parent
4398c55
commit 536f68b
Showing
9 changed files
with
113 additions
and
118 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
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,62 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Ibexa\Contracts\User\Notification; | ||
|
||
use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface; | ||
use Ibexa\Contracts\User\Invitation\Invitation; | ||
use Symfony\Bridge\Twig\Mime\NotificationEmail; | ||
use Symfony\Component\Notifier\Message\EmailMessage; | ||
use Symfony\Component\Notifier\Notification\EmailNotificationInterface; | ||
use Symfony\Component\Notifier\Notification\Notification; | ||
use Symfony\Component\Notifier\Recipient\EmailRecipientInterface; | ||
use Twig\Environment; | ||
|
||
final class UserInvitation extends Notification implements EmailNotificationInterface | ||
{ | ||
public function __construct( | ||
private readonly Invitation $invitation, | ||
private readonly ConfigResolverInterface $configResolver, | ||
private readonly Environment $twig | ||
) { | ||
parent::__construct(); | ||
} | ||
|
||
public function asEmailMessage(EmailRecipientInterface $recipient, string $transport = null): ?EmailMessage | ||
{ | ||
$templatePath = $this->twig->load( | ||
$this->configResolver->getParameter( | ||
'user_invitation.templates.mail', | ||
null, | ||
$this->invitation->getSiteAccessIdentifier() | ||
) | ||
); | ||
|
||
$template = $this->twig->load($templatePath); | ||
|
||
$subject = $template->renderBlock('subject'); | ||
$from = $template->renderBlock('from') ?: null; | ||
$body = $template->renderBlock('body', [ | ||
'invite_hash' => $this->invitation->getHash(), | ||
'siteaccess' => $this->invitation->getSiteAccessIdentifier(), | ||
'invitation' => $this->invitation, | ||
]); | ||
|
||
$email = NotificationEmail::asPublicEmail() | ||
->html($body) | ||
->to($recipient->getEmail()) | ||
->subject($subject) | ||
; | ||
|
||
if ($from !== null) { | ||
$email->from($from); | ||
} | ||
|
||
return new EmailMessage($email); | ||
} | ||
} |
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
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
Oops, something went wrong.