<?php declare(strict_types=1);
namespace Nxs\NxsShippingCosts\Communication\Subscriber;
use Nxs\NxsShippingCosts\Business\Services\ShippingDataHandlerServiceFacadeInterface;
use Shopware\Storefront\Page\Product\ProductPageLoadedEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class DetailSubscriber implements EventSubscriberInterface
{
/**
* @var ShippingDataHandlerServiceFacadeInterface
*/
private $shippingDataHandlerServiceFacade;
/**
* DetailSubscriber constructor.
* @param ShippingDataHandlerServiceFacadeInterface $shippingDataHandlerServiceFacade
*/
public function __construct(ShippingDataHandlerServiceFacadeInterface $shippingDataHandlerServiceFacade)
{
$this->shippingDataHandlerServiceFacade = $shippingDataHandlerServiceFacade;
}
/**
* @return array|string[]
*/
public static function getSubscribedEvents(): array
{
return [
ProductPageLoadedEvent::class => 'onProductPageLoaded'
];
}
/**
* @param ProductPageLoadedEvent $event
*/
public function onProductPageLoaded(ProductPageLoadedEvent $event)
{
$this->shippingDataHandlerServiceFacade->getShippingDataAndAssignToContext($event);
}
}