SendEmails.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Sales\Observer\Virtual;
  7. use Magento\Framework\Event\ObserverInterface;
  8. /**
  9. * Sales emails sending observer.
  10. *
  11. * Performs handling of cron jobs related to sending emails to customers
  12. * after creation/modification of Order, Invoice, Shipment or Creditmemo.
  13. */
  14. class SendEmails implements ObserverInterface
  15. {
  16. /**
  17. * Global configuration storage.
  18. *
  19. * @var \Magento\Sales\Model\EmailSenderHandler
  20. */
  21. protected $emailSenderHandler;
  22. /**
  23. * @param \Magento\Sales\Model\EmailSenderHandler $emailSenderHandler
  24. */
  25. public function __construct(\Magento\Sales\Model\EmailSenderHandler $emailSenderHandler)
  26. {
  27. $this->emailSenderHandler = $emailSenderHandler;
  28. }
  29. /**
  30. * Handles asynchronous email sending during corresponding
  31. * cron job.
  32. *
  33. * Also method is used in the next events:
  34. *
  35. * - config_data_sales_email_general_async_sending_disabled
  36. *
  37. * Works only if asynchronous email sending is enabled
  38. * in global settings.
  39. *
  40. * @param \Magento\Framework\Event\Observer $observer
  41. * @return void
  42. * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  43. */
  44. public function execute(\Magento\Framework\Event\Observer $observer)
  45. {
  46. $this->emailSenderHandler->sendEmails();
  47. }
  48. }