Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

BulkMailerProxy.php 883B

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