|
123456789101112131415161718192021222324252627282930 |
- <?php
-
- namespace common\components\BulkMailer;
-
- use domain\Communication\Email\Email;
- use domain\Setting\AdminSettingBag;
- use yii\base\ErrorException;
-
- class BulkMailerProxy implements BulkMailerInterface
- {
- public function getBulkMailer(): BulkMailerInterface
- {
- $bulkMailerSetting = AdminSettingBag::getInstance()->get('bulkMailer');
-
- if($bulkMailerSetting == BulkMailerInterface::MAILJET) {
- return new BulkMailerMailjet();
- }
- elseif($bulkMailerSetting == BulkMailerInterface::BREVO) {
- return new BulkMailerBrevo();
- }
- else {
- throw new ErrorException("Le mailer pour les emails en masse n'est pas défini dans les paramètres admin.");
- }
- }
-
- public function sendEmail(Email $email, array $usersArray)
- {
- $this->getBulkMailer()->sendEmail($email, $usersArray);
- }
- }
|