<?php
/**
* @author Léo BANNHOLTZER (contact@scaledev.fr)
* @copyright 2021 - ScaleDEV SAS, 12 RUE CHARLES MORET, 10120 ST ANDRE LES VERGERS
* @license commercial
*/
declare(strict_types=1);
namespace Bluue\PrestashopConnectorBundle\EventSubscriber\SalesBundle;
use Bluue\SalesBundle\Event\OrderEditEvent;
use Symfony\Component\Messenger\MessageBusInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Bluue\PrestashopConnectorBundle\Message\EditDeliveryAddressOfOrderMessage;
class OrderEditSubscriber implements EventSubscriberInterface
{
/**
* @var MessageBusInterface $mappingmessageBusRepo
*/
private MessageBusInterface $messageBus;
public function __construct(MessageBusInterface $messageBus)
{
$this->messageBus = $messageBus;
}
/**
* @return array
*/
public static function getSubscribedEvents(): array
{
return [
OrderEditEvent::POST_SUBMIT => 'postSubmit'
];
}
/**
* @param OrderEditEvent $event
* @return void
*/
public function postSubmit(OrderEditEvent $event): void
{
$this->messageBus->dispatch(
new EditDeliveryAddressOfOrderMessage($event->getOrder()->getId()->toRfc4122())
);
}
}