Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

AutomaticEmailManager.php 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace domain\Communication\AutomaticEmail;
  3. use domain\_\AbstractManager;
  4. use domain\Communication\Email\Email;
  5. use domain\Communication\Email\EmailGenerator;
  6. use domain\Distribution\Distribution\Distribution;
  7. use domain\Producer\Producer\Producer;
  8. class AutomaticEmailManager extends AbstractManager
  9. {
  10. protected AutomaticEmailBuilder $automaticEmailBuilder;
  11. protected EmailGenerator $emailGenerator;
  12. public function loadDependencies(): void
  13. {
  14. $this->automaticEmailBuilder = $this->loadService(AutomaticEmailBuilder::class);
  15. $this->emailGenerator = $this->loadService(EmailGenerator::class);
  16. }
  17. public function createAutomaticEmail(
  18. Producer $producer,
  19. int $day,
  20. int $delayBeforeDistribution,
  21. string $subject,
  22. string $message,
  23. bool $integrateProductList = null
  24. ): AutomaticEmail
  25. {
  26. $automaticEmail = $this->automaticEmailBuilder->instanciateAutomaticEmail($producer);
  27. $automaticEmail->setDay($day);
  28. $automaticEmail->setDelayBeforeDistribution($delayBeforeDistribution);
  29. $automaticEmail->setSubject($subject);
  30. $automaticEmail->setMessage($message);
  31. $automaticEmail->setIntegrateProductList($integrateProductList);
  32. $automaticEmail->save();
  33. return $automaticEmail;
  34. }
  35. public function createEmailFromAutomaticEmail(AutomaticEmail $automaticEmail, Distribution $distribution): Email
  36. {
  37. return $this->emailGenerator->createEmail(
  38. $automaticEmail->getSubject(),
  39. $automaticEmail->getMessage(),
  40. $automaticEmail->getIntegrateProductList(),
  41. $automaticEmail->getProducer(),
  42. $distribution
  43. );
  44. }
  45. }