<?php
namespace App\EventSubscriber;
use App\Entity\OrderRequest;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Workflow\Event\Event;
class OrderRequestStateChangeEventSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents()
{
return [
'workflow.order_request.completed' => 'onTransitionComplete',
];
}
public function onTransitionComplete(Event $event): void
{
/**
* @var OrderRequest $orderRequest
*/
$orderRequest = $event->getSubject();
$orderRequest->setStateUpdatedAt(new \DateTimeImmutable());
}
}