src/EventSubscriber/Order/SendOrderConfirmationMailSubsriber.php line 29

  1. <?php
  2. /*
  3.  * This file is part of the Pellipop project.
  4.  *
  5.  * (c) Mobizel
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. declare(strict_types=1);
  11. namespace App\EventSubscriber\Order;
  12. use App\Email\MailerInterface;
  13. use App\Entity\Order\Order;
  14. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  15. use Symfony\Component\Workflow\Event\Event;
  16. use Webmozart\Assert\Assert;
  17. class SendOrderConfirmationMailSubsriber implements EventSubscriberInterface
  18. {
  19.     public function __construct(
  20.         private MailerInterface $mailer,
  21.     ) {
  22.     }
  23.     public function onEnter(Event $event)
  24.     {
  25.         /** @var Order $order */
  26.         $order $event->getSubject();
  27.         Assert::isInstanceOf($orderOrder::class);
  28.         $this->mailer->sendOrderConfirmationEmail($order);
  29.     }
  30.     public static function getSubscribedEvents()
  31.     {
  32.         return [
  33.             'workflow.order_production.entered.order_received' => 'onEnter',
  34.         ];
  35.     }
  36. }