<?php
declare(strict_types=1);
namespace Drupal\MYMODULE\EventSubscriber;
use Drupal\commerce_order\Event\OrderEvent;
use Drupal\commerce_order\Event\OrderEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
* Order Paid Subscriber.
*/
final class OrderPaidSubscriber implements EventSubscriberInterface {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents(): array {
return [
OrderEvents::ORDER_PAID => ['onPaid', -100],
];
}
/**
* Apply transition to validate order.
*
* @param \Drupal\commerce_order\Event\OrderEvent $event
* The event.
*/
public function onPaid(OrderEvent $event) {
// Some code.
}
}