Files
kupshop/bundles/External/HannahBundle/SAP/EventSubscriber/PurchaseStateSubscriber.php
2025-08-02 16:30:27 +02:00

43 lines
1.1 KiB
PHP

<?php
declare(strict_types=1);
namespace External\HannahBundle\SAP\EventSubscriber;
use External\HannahBundle\SAP\Util\PricingUtil;
use KupShop\KupShopBundle\Context\CurrencyContext;
use KupShop\KupShopBundle\Util\Contexts;
use KupShop\OrderingBundle\Event\PurchaseStateCreatedEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class PurchaseStateSubscriber implements EventSubscriberInterface
{
private $pricingUtil;
public function __construct(PricingUtil $pricingUtil)
{
$this->pricingUtil = $pricingUtil;
}
public static function getSubscribedEvents()
{
return [
PurchaseStateCreatedEvent::class => [
['updatePrices', 200],
],
];
}
public function updatePrices(PurchaseStateCreatedEvent $event): void
{
// ceneni kosiku pres SAP je povoleno pouze pro CZK menu
if (Contexts::get(CurrencyContext::class)->getActiveId() !== 'CZK') {
return;
}
$this->pricingUtil->updatePurchaseState(
$event->getPurchaseState()
);
}
}