custom/static-plugins/NdSRS/src/Core/Content/Flow/Dispatching/Action/SendOrderAction.php line 40

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Nd\Srs\Core\Content\Flow\Dispatching\Action;
  3. use Shopware\Core\Content\Flow\Dispatching\Action\FlowAction;
  4. use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
  5. use Shopware\Core\Framework\Uuid\Uuid;
  6. use Nd\Srs\Core\Framework\Event\OrderAware;
  7. use Nd\Srs\Service\OrderCommunicator;
  8. use Shopware\Core\Framework\Event\FlowEvent;
  9. class SendOrderAction extends FlowAction
  10. {
  11.     private OrderCommunicator $OrderCommunicator;
  12.     public function __construct(OrderCommunicator $OrderCommunicator)
  13.     {
  14.         // you would need this repository to create a tag
  15.         $this->OrderCommunicator $OrderCommunicator;
  16.     }
  17.     public static function getName(): string
  18.     {
  19.         // your own action name
  20.         return 'action.send.order';
  21.     }
  22.     public static function getSubscribedEvents(): array
  23.     {
  24.         return [
  25.             self::getName() => 'handle',
  26.         ];
  27.     }
  28.     public function requirements(): array
  29.     {
  30.         return [OrderAware::class];
  31.     }
  32.     public function handle(FlowEvent $event): void
  33.     {
  34.         // config is the config data when created a flow sequence
  35.         $config $event->getConfig();
  36. //        mail('mick@nodots.nl', 'DEV: Action triggered', 'Send order');
  37.         try {
  38.             $result $this->OrderCommunicator->createOrder($event->getEvent()->getOrder()->getId(), $event->getContext());
  39.         }catch(\Exception $e){
  40.             mail('mick@nodots.nl''DEV: Action error''Error:' json_encode($e->getLine()) . json_encode($e->getMessage()));
  41.         }
  42. //        mail('mick@nodots.nl', 'DEV: Action completed', 'Send order' . json_encode($result));
  43.     }
  44. }