You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
995B

  1. <?php
  2. namespace common\components\BulkMailer;
  3. use domain\Setting\AdminSettingBag;
  4. use yii\base\ErrorException;
  5. class BulkMailerProxy implements BulkMailerInterface
  6. {
  7. public function getBulkMailer(): BulkMailerInterface
  8. {
  9. $bulkMailerSetting = AdminSettingBag::getInstance()->get('bulkMailer');
  10. if($bulkMailerSetting == BulkMailerInterface::MAILJET) {
  11. return new BulkMailerMailjet();
  12. }
  13. elseif($bulkMailerSetting == BulkMailerInterface::BREVO) {
  14. return new BulkMailerBrevo();
  15. }
  16. else {
  17. throw new ErrorException("Le mailer pour les emails en masse n'est pas défini dans les paramètres admin.");
  18. }
  19. }
  20. public function sendEmails(array $contactsArray, string $fromName, string $fromEmail, string $subject, string $htmlContent, string $textContent = null)
  21. {
  22. $this->getBulkMailer()->sendEmails($contactsArray, $fromName, $fromEmail, $subject, $htmlContent, $textContent);
  23. }
  24. }