vendor/bluue/adelya-bundle/src/EventSubscriber/ReceiptSubscriber.php line 47

Open in your IDE?
  1. <?php
  2. /**
  3.  * @author Léo BANNHOLTZER (contact@scaledev.fr)
  4.  * @copyright 2021 - ScaleDEV SAS, 12 RUE CHARLES MORET, 10120 ST ANDRE LES VERGERS
  5.  * @license commercial
  6.  */
  7. declare(strict_types=1);
  8. namespace Bluue\AdelyaBundle\EventSubscriber;
  9. use Bluue\AdelyaBundle\Message\ValidateReceiptMessage;
  10. use Bluue\CashRegisterBundle\Event\ReceiptMovementsEvent;
  11. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  12. use Symfony\Component\Messenger\MessageBusInterface;
  13. class ReceiptSubscriber implements EventSubscriberInterface
  14. {
  15.     /**
  16.      * @var MessageBusInterface
  17.      */
  18.     private MessageBusInterface $messageBus;
  19.     /**
  20.      * @param MessageBusInterface $messageBus
  21.      */
  22.     public function __construct(MessageBusInterface $messageBus)
  23.     {
  24.         $this->messageBus $messageBus;
  25.     }
  26.     /**
  27.      * @return array
  28.      */
  29.     public static function getSubscribedEvents(): array
  30.     {
  31.         return [
  32.             ReceiptMovementsEvent::VALIDATE_RECEIPT => 'validateReceipt'
  33.         ];
  34.     }
  35.     /**
  36.      * @param ReceiptMovementsEvent $event
  37.      * @return void
  38.      */
  39.     public function validateReceipt(ReceiptMovementsEvent $event): void
  40.     {
  41.         $receipt $event->getReceipt();
  42.         $this->messageBus->dispatch(new ValidateReceiptMessage((string) $receipt->getId()));
  43.     }
  44. }