Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

3 лет назад
3 лет назад
3 лет назад
3 лет назад
3 лет назад
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace Lc\CaracoleBundle\Notification;
  3. use Lc\CaracoleBundle\Resolver\MerchantResolver;
  4. use Lc\SovBundle\Notification\MailMailjetNotification as SovMailMailjetNotification;
  5. use Lc\CaracoleBundle\Definition\MerchantSettingDefinition;
  6. use Lc\SovBundle\Repository\Site\SiteStore;
  7. use Lc\SovBundle\Solver\Setting\SettingSolver;
  8. use Mailjet\MailjetSwiftMailer\SwiftMailer\MailjetTransport;
  9. use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
  10. use Twig\Environment;
  11. class MailMailjetNotification extends SovMailMailjetNotification
  12. {
  13. protected MerchantResolver $merchantResolver;
  14. const MERCHANT = 'merchant';
  15. public function __construct(
  16. MailjetTransport $mailjetTransport,
  17. Environment $templating,
  18. ParameterBagInterface $parameterBag,
  19. SettingSolver $settingSolver,
  20. MerchantResolver $merchantResolver,
  21. SiteStore $siteStore
  22. ) {
  23. parent::__construct($mailjetTransport, $templating, $parameterBag, $settingSolver, $siteStore);
  24. $this->merchantResolver = $merchantResolver;
  25. }
  26. public function send($params = [])
  27. {
  28. $merchant = isset($params[self::MERCHANT]) ? $params[self::MERCHANT] : $this->merchantResolver->getCurrent();
  29. $merchantConfigEmailFrom = $this->settingSolver->getSettingValue(
  30. $merchant,
  31. MerchantSettingDefinition::SETTING_EMAIL_FROM
  32. );
  33. $emailFrom = (isset($params[self::FROM_EMAIL]) && $params[self::FROM_EMAIL] && strlen(
  34. $params[self::FROM_EMAIL]
  35. )) ? $params[self::FROM_EMAIL] : $merchantConfigEmailFrom;
  36. $merchantConfigEmailFromName = $this->settingSolver->getSettingValue(
  37. $merchant,
  38. MerchantSettingDefinition::SETTING_EMAIL_FROM_NAME
  39. );
  40. $emailFromName = isset($params[self::FROM_NAME]) ? $params[self::FROM_NAME] : $merchantConfigEmailFromName;
  41. $merchantConfigEmailSubjectPrefix = $this->settingSolver->getSettingValue(
  42. $merchant,
  43. MerchantSettingDefinition::SETTING_EMAIL_SUBJECT_PREFIX
  44. );
  45. $emailSubjectPrefix = isset($params[self::SUBJECT_PREFIX]) ? $params[self::SUBJECT_PREFIX] : $merchantConfigEmailSubjectPrefix;
  46. if ($emailSubjectPrefix && strlen($emailSubjectPrefix)) {
  47. $emailSubjectPrefix .= ' ';
  48. }
  49. return parent::send(
  50. array_merge($params, [
  51. self::FROM_EMAIL => $emailFrom,
  52. self::FROM_NAME => $emailFromName,
  53. self::SUBJECT_PREFIX => $emailSubjectPrefix
  54. ])
  55. );
  56. }
  57. }