-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Send mail to user at alias creation (Fixes: #108)
- Loading branch information
1 parent
e852007
commit 27a4d20
Showing
14 changed files
with
395 additions
and
43 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,79 @@ | ||
<?php | ||
|
||
namespace App\Builder; | ||
|
||
use Symfony\Component\Translation\TranslatorInterface; | ||
|
||
/** | ||
* Class AliasCreatedMessageBuilder. | ||
* | ||
* @author doobry <[email protected]> | ||
*/ | ||
class AliasCreatedMessageBuilder | ||
{ | ||
/** | ||
* @var TranslatorInterface | ||
*/ | ||
private $translator; | ||
/** | ||
* @var string | ||
*/ | ||
private $appUrl; | ||
/** | ||
* @var string | ||
*/ | ||
private $projectName; | ||
|
||
/** | ||
* AliasCreatedMessageBuilder constructor. | ||
* | ||
* @param TranslatorInterface $translator | ||
* @param string $appUrl | ||
* @param string $projectName | ||
*/ | ||
public function __construct(TranslatorInterface $translator, $appUrl, $projectName) | ||
{ | ||
$this->translator = $translator; | ||
$this->appUrl = $appUrl; | ||
$this->projectName = $projectName; | ||
} | ||
|
||
/** | ||
* @param string $locale | ||
* @param string $email | ||
* @param string $alias | ||
* | ||
* @return string | ||
*/ | ||
public function buildBody(string $locale, string $email, string $alias) | ||
{ | ||
$body = $this->translator->trans( | ||
'mail.alias-created-body', | ||
[ | ||
'%app_url%' => $this->appUrl, | ||
'%project_name%' => $this->projectName, | ||
'%email%' => $email, | ||
'%alias%' => $alias, | ||
], | ||
null, | ||
$locale | ||
); | ||
|
||
return $body; | ||
} | ||
|
||
/** | ||
* @param string $locale | ||
* @param string $email | ||
* | ||
* @return string | ||
*/ | ||
public function buildSubject(string $locale, string $email) | ||
{ | ||
$subject = $this->translator->trans( | ||
'mail.alias-created-subject', ['%email%' => $email], null, $locale | ||
); | ||
|
||
return $subject; | ||
} | ||
} |
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,27 @@ | ||
<?php | ||
|
||
namespace App\Event; | ||
|
||
use App\Entity\Alias; | ||
use App\Traits\AliasAwareTrait; | ||
use Symfony\Component\EventDispatcher\Event; | ||
|
||
/** | ||
* Class AliasCreatedEvent. | ||
*/ | ||
class AliasCreatedEvent extends Event | ||
{ | ||
use AliasAwareTrait; | ||
|
||
const NAME = 'alias.custom_created'; | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @param Alias $alias | ||
*/ | ||
public function __construct(Alias $alias) | ||
{ | ||
$this->alias = $alias; | ||
} | ||
} |
Oops, something went wrong.