src/EventSubscriber/ReceiptEventSubscriber.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\EventSubscriber;
  3. use App\Payment\InvoicePaymentOption;
  4. use App\Payment\CashPaymentOption;
  5. use App\Payment\PinPaymentOption;
  6. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  7. use Boldr\Shop\ReceiptPrinterBundle\Event\QueueReceiptEvent;
  8. class ReceiptEventSubscriber implements EventSubscriberInterface
  9. {
  10.     public static function getSubscribedEvents()
  11.     {
  12.         return [
  13.             QueueReceiptEvent::class => [
  14.                 ['onQueueReceipt'10]
  15.             ]
  16.         ];
  17.     }
  18.     public function onQueueReceipt(QueueReceiptEvent $event)
  19.     {
  20.         $printer $event->getPrinter();
  21.         if (!str_contains($printer->getName(), 'factuur'))
  22.         {
  23.             return;
  24.         }
  25.         $orders $event->getOrders();
  26.         foreach ($orders as $order)
  27.         {
  28.             if ($order->getSelectedPaymentOption() instanceof InvoicePaymentOption || $order->getSelectedPaymentOption() instanceof CashPaymentOption || $order->getSelectedPaymentOption() instanceof PinPaymentOption)
  29.             {
  30.                 return;
  31.             }
  32.         }
  33.         $event->stopPropagation();
  34.     }
  35. }