custom/plugins/NextagFlow/src/Flow/MailAction.php line 40

Open in your IDE?
  1. <?php
  2. namespace Nextag\Flow\Flow;
  3. use Exception;
  4. use Shopware\Core\Content\Flow\Dispatching\Action\FlowAction;
  5. use Shopware\Core\Framework\Event\FlowEvent;
  6. use Nextag\Flow\Helper\Log;
  7. class MailAction extends FlowAction
  8. {
  9.     private Log $logHelper;
  10.     private \Nextag\Mail\Helper\MailGenerator $mailGenerator;
  11.     public function __construct(
  12.         Log $logHelper,
  13.         \Nextag\Mail\Helper\MailGenerator $mailGenerator
  14.     )
  15.     {
  16.         $this->logHelper $logHelper;
  17.         $this->mailGenerator $mailGenerator;
  18.     }
  19.     public static function getName(): string
  20.     {
  21.         return 'action.flow.nextag.mail';
  22.     }
  23.     public static function getSubscribedEvents(): array
  24.     {
  25.         return [
  26.             self::getName() => 'handle'
  27.         ];
  28.     }
  29.     public function requirements(): array
  30.     {
  31.         return [];
  32.     }
  33.     public function handle(FlowEvent $event): void
  34.     {
  35.         $config $event->getConfig();
  36.         $order null;
  37.         $mailEvent $event->getEvent();
  38.         try {
  39.             $order $mailEvent->getOrder();
  40.         } catch(Exception $e) {
  41.             return;
  42.         }
  43.         if($order === null) {
  44.             return;
  45.         }
  46.         $this->mailGenerator->sendEmail($order$config);
  47.     }
  48. }