vendor/boldr/receipt-printer-multishop-bundle/src/EventSubscriber/PrinterEventSubscriber.php line 17

Open in your IDE?
  1. <?php
  2. namespace Boldr\Shop\ReceiptPrinterMultishopBundle\EventSubscriber;
  3. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  4. class PrinterEventSubscriber implements EventSubscriberInterface
  5. {
  6. public static function getSubscribedEvents(): array
  7. {
  8. return [
  9. QueueReceiptEvent::class => ['onReceiptQueued']
  10. ];
  11. }
  12. public function onReceiptQueued(QueueReceiptEvent $event)
  13. {
  14. $shop = $this->em->getRepository(OrderShop::class)->find($event->getOrder())?->getShop();
  15. if ($shop === null)
  16. {
  17. return;
  18. }
  19. $printerShops = $this->em->getRepository(PrinterShop::class)->findBy([
  20. 'printer' => $event->getPrinter(),
  21. 'shop' => $shop
  22. ]);
  23. if (count($printerShops) === 0)
  24. {
  25. $event->stopPropagation();
  26. }
  27. }
  28. }