src/EventSubscriber/Order/NotifyAdminPrinterCancelOrErrorRequestSubscriber.php line 36
<?php/** This file is part of the Pellipop project.** (c) Mobizel** For the full copyright and license information, please view the LICENSE* file that was distributed with this source code.*/declare(strict_types=1);namespace App\EventSubscriber\Order;use App\Entity\Order\Order;use App\Message\SendOrderEmailMessage;use App\OrderProductionStates;use Symfony\Component\EventDispatcher\EventSubscriberInterface;use Symfony\Component\Messenger\MessageBusInterface;use Symfony\Component\Workflow\Event\Event;/*** Quand un imprimeur demande une annulation/erreur, notifie l'admin (async).* L'email client d'annulation n'est envoyé qu'après validation admin (canceled/errored).* Les états cancel_pending/error_pending ne sont atteignables que via les actions* imprimeur (gardées par printer_workflow_enabled), donc pas de garde ici en plus.*/final class NotifyAdminPrinterCancelOrErrorRequestSubscriber implements EventSubscriberInterface{public function __construct(private MessageBusInterface $messageBus,) {}public function onEnter(Event $event): void{/** @var Order $order */$order = $event->getSubject();$orderId = $order->getId();if (null === $orderId) {return;}$this->messageBus->dispatch(new SendOrderEmailMessage($orderId,SendOrderEmailMessage::TYPE_ADMIN_CANCEL_OR_ERROR_REQUEST,$order->getProductionState() ?? OrderProductionStates::STATE_CANCEL_PENDING,));}public static function getSubscribedEvents(): array{return ['workflow.order_production.entered.cancel_pending' => 'onEnter','workflow.order_production.entered.error_pending' => 'onEnter',];}}