Skip to content

Commit

Permalink
fixup! refactoring: mailer settings are now provided by new MailerSet…
Browse files Browse the repository at this point in the history
…tingProvider
  • Loading branch information
vitek-rostislav committed Jul 7, 2022
1 parent 28e3971 commit 58c6686
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

declare(strict_types=1);

namespace Shopsys\FrameworkBundle\Model\Mail\Exception;

use Exception;

class MasterMailNotSetException extends Exception implements MailException
{
public function __construct()
{
parent::__construct('Master mail is not set, please check MAILER_MASTER_EMAIL_ADDRESS env variable.');
}
}
10 changes: 8 additions & 2 deletions packages/framework/src/Model/Mail/MailerSettingProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Shopsys\FrameworkBundle\Model\Mail;

use Shopsys\FrameworkBundle\Model\Mail\Exception\MasterMailNotSetException;

class MailerSettingProvider
{
/**
Expand Down Expand Up @@ -45,10 +47,14 @@ public function getMailerWhitelistExpressions(): array
}

/**
* @return string|null
* @return string
*/
public function getMailerMasterEmailAddress(): ?string
public function getMailerMasterEmailAddress(): string
{
if ($this->isMailerMasterEmailSet() === false) {
throw new MasterMailNotSetException();
}

return $this->mailerMasterEmailAddress;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/framework/src/Twig/MailerSettingExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function getMailerSettingInfo()
{
return $this->twigEnvironment->render('@ShopsysFramework/Common/Mailer/settingInfo.html.twig', [
'isDeliveryDisabled' => $this->mailerSettingProvider->isDeliveryDisabled(),
'mailerMasterEmailAddress' => $this->mailerSettingProvider->getMailerMasterEmailAddress(),
'mailerMasterEmailAddress' => $this->mailerSettingProvider->isMailerMasterEmailSet() ? $this->mailerSettingProvider->getMailerMasterEmailAddress() : null,
'mailerWhitelistExpressions' => $this->mailerSettingProvider->getMailerWhitelistExpressions(),
]);
}
Expand Down

0 comments on commit 58c6686

Please sign in to comment.