<?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\AdelyaBundle\EventSubscriber;
use Bluue\AdelyaBundle\Message\ValidateReceiptMessage;
use Bluue\CashRegisterBundle\Event\EditCustomerReceiptEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Messenger\MessageBusInterface;
class EditCustomerReceiptSubscriber implements EventSubscriberInterface
{
/**
* @var MessageBusInterface
*/
private MessageBusInterface $messageBus;
/**
* @param MessageBusInterface $messageBus
*/
public function __construct(MessageBusInterface $messageBus)
{
$this->messageBus = $messageBus;
}
/**
* @return array
*/
public static function getSubscribedEvents(): array
{
return [
EditCustomerReceiptEvent::EDIT => 'edit'
];
}
/**
* @param EditCustomerReceiptEvent $event
* @return void
*/
public function edit(EditCustomerReceiptEvent $event): void
{
$receipt = $event->getReceipt();
$this->messageBus->dispatch(new ValidateReceiptMessage((string) $receipt->getId()));
}
}