<?php
namespace App\EventSubscriber;
use App\Payment\InvoicePaymentOption;
use App\Payment\CashPaymentOption;
use App\Payment\PinPaymentOption;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Boldr\Shop\ReceiptPrinterBundle\Event\QueueReceiptEvent;
class ReceiptEventSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents()
{
return [
QueueReceiptEvent::class => [
['onQueueReceipt', 10]
]
];
}
public function onQueueReceipt(QueueReceiptEvent $event)
{
$printer = $event->getPrinter();
if (!str_contains($printer->getName(), 'factuur'))
{
return;
}
$orders = $event->getOrders();
foreach ($orders as $order)
{
if ($order->getSelectedPaymentOption() instanceof InvoicePaymentOption || $order->getSelectedPaymentOption() instanceof CashPaymentOption || $order->getSelectedPaymentOption() instanceof PinPaymentOption)
{
return;
}
}
$event->stopPropagation();
}
}