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.

126 line
5.0KB

  1. <?php
  2. namespace Lc\SovBundle\Notification;
  3. use Lc\SovBundle\Definition\SiteSettingDefinition;
  4. use Lc\SovBundle\Repository\Site\SiteStore;
  5. use Lc\SovBundle\Solver\Setting\SettingSolver;
  6. use Mailjet\MailjetSwiftMailer\SwiftMailer\MailjetTransport;
  7. use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
  8. use Twig\Environment;
  9. class MailMailjetNotification
  10. {
  11. //TODO symfony6
  12. // const SUBJECT = 'subject';
  13. // const SUBJECT_PREFIX = 'subject-prefix';
  14. // const TO_EMAIL = 'to-email';
  15. // const COPY_TO = 'copy-to';
  16. // const COPY_HIDDEN_TO = 'copy-hidden-to';
  17. // const TO_NAME = 'to-name';
  18. // const FROM_EMAIL = 'from-email';
  19. // const FROM_NAME = 'from-name';
  20. // const REPLY_TO = 'reply-to';
  21. // const CONTENT_TEMPLATE = 'content-template';
  22. // const CONTENT_DATA = 'content-data';
  23. // const ATTACHMENT_DATA = 'attachment-data';
  24. // const ATTACHMENT_FILENAME = 'attachment-filename';
  25. // const ATTACHMENT_CONTENT_TYPE = 'attachment-content-type';
  26. //
  27. // protected MailjetTransport $transport;
  28. // protected Environment $templating;
  29. // protected ParameterBagInterface $parameterBag;
  30. // protected SettingSolver $settingSolver;
  31. // protected SiteStore $siteStore;
  32. //
  33. // public function __construct(
  34. // MailjetTransport $mailjetTransport,
  35. // Environment $templating,
  36. // ParameterBagInterface $parameterBag,
  37. // SettingSolver $settingSolver,
  38. // SiteStore $siteStore
  39. // ) {
  40. // $this->transport = $mailjetTransport;
  41. // $this->templating = $templating;
  42. // $this->parameterBag = $parameterBag;
  43. // $this->settingSolver = $settingSolver;
  44. // $this->siteStore = $siteStore;
  45. // }
  46. //
  47. // public function send($params = [])
  48. // {
  49. // $siteDefault = $this->siteStore->getOneDefault();
  50. //
  51. // $emailSubjectPrefix = (isset($params[self::SUBJECT_PREFIX]) && $params[self::SUBJECT_PREFIX] && strlen($params[self::SUBJECT_PREFIX]) > 0)
  52. // ? $params[self::SUBJECT_PREFIX]
  53. // : $this->settingSolver->getSettingValue(
  54. // $siteDefault,
  55. // SiteSettingDefinition::SETTING_EMAIL_SUBJECT_PREFIX
  56. // );
  57. //
  58. // $emailFrom = (isset($params[self::FROM_EMAIL]) && $params[self::FROM_EMAIL] && strlen($params[self::FROM_EMAIL]) > 0)
  59. // ? $params[self::FROM_EMAIL]
  60. // : $this->settingSolver->getSettingValue(
  61. // $siteDefault,
  62. // SiteSettingDefinition::SETTING_EMAIL_FROM
  63. // );
  64. //
  65. // $emailFromName = (isset($params[self::FROM_NAME]) && $params[self::FROM_NAME] && strlen($params[self::FROM_NAME]) > 0)
  66. // ? $params[self::FROM_NAME]
  67. // : $this->settingSolver->getSettingValue(
  68. // $siteDefault,
  69. // SiteSettingDefinition::SETTING_EMAIL_FROM_NAME
  70. // );
  71. //
  72. // $message = new \Swift_Message($emailSubjectPrefix . $params[self::SUBJECT]);
  73. //
  74. // if ($this->parameterBag->get('mailjet.dev.redirect.active') == 1) {
  75. // $message->addTo(
  76. // $this->parameterBag->get('mailjet.dev.redirect.email'),
  77. // isset($params[self::TO_NAME]) ?? null
  78. // );
  79. // } else {
  80. // $message->addTo(
  81. // $params[self::TO_EMAIL],
  82. // isset($params[self::TO_NAME]) ?? null
  83. // );
  84. // }
  85. //
  86. // $contentData = [];
  87. // if (isset($params[self::CONTENT_DATA])) {
  88. // $contentData = $params[self::CONTENT_DATA];
  89. // }
  90. //
  91. // $message->addFrom($emailFrom, $emailFromName)
  92. // ->setBody(
  93. // $this->templating->render($params[self::CONTENT_TEMPLATE] . '-html.html.twig', $contentData),
  94. // 'text/html'
  95. // )
  96. // ->addPart($this->templating->render($params[self::CONTENT_TEMPLATE] . '-text.html.twig', $contentData));
  97. //
  98. // if (isset($params[self::COPY_TO]) && strlen($params[self::COPY_TO])) {
  99. // $message->addCc($params[self::COPY_TO]);
  100. // }
  101. //
  102. // if (isset($params[self::COPY_HIDDEN_TO]) && strlen($params[self::COPY_HIDDEN_TO])) {
  103. // $message->addBcc($params[self::COPY_HIDDEN_TO]);
  104. // }
  105. //
  106. // if (isset($params[self::REPLY_TO]) && strlen($params[self::REPLY_TO])) {
  107. // $message->addReplyTo($params[self::REPLY_TO]);
  108. // }
  109. //
  110. // if (isset($params[self::ATTACHMENT_DATA]) && isset($params[self::ATTACHMENT_FILENAME]) && isset($params[self::ATTACHMENT_CONTENT_TYPE])) {
  111. // $message->attach(
  112. // \Swift_Attachment::newInstance(
  113. // $params[self::ATTACHMENT_DATA],
  114. // $params[self::ATTACHMENT_FILENAME],
  115. // $params[self::ATTACHMENT_CONTENT_TYPE]
  116. // )
  117. // );
  118. // }
  119. //
  120. // return $this->transport->send($message);
  121. // }
  122. }