<?php declare(strict_types=1);
namespace S360ListingViewSwitch\Storefront\Subscriber;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Shopware\Core\Content\Product\ProductEvents;
use S360ListingViewSwitch\Storefront\Helper\ViewSwitchHelper;
// for initial listing opening
class ListingViewSubscriber implements EventSubscriberInterface {
/**
* @var ViewSwitchHelper
*/
protected $viewSwitchHelper;
public function __construct(ViewSwitchHelper $viewSwitchHelper)
{
$this->viewSwitchHelper = $viewSwitchHelper;
}
public static function getSubscribedEvents(): array
{
return [
ProductEvents::PRODUCT_LISTING_RESULT => 'onLoadedEvent',
];
}
public function onLoadedEvent()
{
$this->viewSwitchHelper->checkListing();
}
}