src/EventSubscriber/Order/OrderStateUpdaterSubscriber.php line 31
<?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\OrderProductionStates;use App\OrderStates;use Symfony\Component\EventDispatcher\EventSubscriberInterface;use Symfony\Component\Workflow\Event\Event;use Symfony\Component\Workflow\WorkflowInterface;use Webmozart\Assert\Assert;class OrderStateUpdaterSubscriber implements EventSubscriberInterface{public function __construct(private WorkflowInterface $orderStateMachine,) {}public function onCompleted(Event $event){/** @var Order $order */$order = $event->getSubject();Assert::isInstanceOf($order, Order::class);switch ($order->getProductionState()) {case OrderProductionStates::STATE_ARCHIVED:$this->orderStateMachine->apply($order, OrderStates::TRANSITION_FUFILL);break;case OrderProductionStates::STATE_CANCELED:$this->orderStateMachine->apply($order, OrderStates::TRANSITION_CANCEL);break;case OrderProductionStates::STATE_ERRORED:$this->orderStateMachine->apply($order, OrderStates::TRANSITION_CANCEL);break;}}public static function getSubscribedEvents(){return ['workflow.order_production.completed' => 'onCompleted',];}}