custom/plugins/NxsShippingCosts/src/Communication/Subscriber/DetailSubscriber.php line 40

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Nxs\NxsShippingCosts\Communication\Subscriber;
  3. use Nxs\NxsShippingCosts\Business\Services\ShippingDataHandlerServiceFacadeInterface;
  4. use Shopware\Storefront\Page\Product\ProductPageLoadedEvent;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. class DetailSubscriber implements EventSubscriberInterface
  7. {
  8.     /**
  9.      * @var ShippingDataHandlerServiceFacadeInterface
  10.      */
  11.     private $shippingDataHandlerServiceFacade;
  12.     /**
  13.      * DetailSubscriber constructor.
  14.      * @param ShippingDataHandlerServiceFacadeInterface $shippingDataHandlerServiceFacade
  15.      */
  16.     public function __construct(ShippingDataHandlerServiceFacadeInterface $shippingDataHandlerServiceFacade)
  17.     {
  18.         $this->shippingDataHandlerServiceFacade $shippingDataHandlerServiceFacade;
  19.     }
  20.     /**
  21.      * @return array|string[]
  22.      */
  23.     public static function getSubscribedEvents(): array
  24.     {
  25.         return [
  26.             ProductPageLoadedEvent::class => 'onProductPageLoaded'
  27.         ];
  28.     }
  29.     /**
  30.      * @param ProductPageLoadedEvent $event
  31.      */
  32.     public function onProductPageLoaded(ProductPageLoadedEvent $event)
  33.     {
  34.         $this->shippingDataHandlerServiceFacade->getShippingDataAndAssignToContext($event);
  35.     }
  36. }