<?php declare(strict_types=1);
namespace Nimbits\NimbitsLazyLoadingNext\Subscriber;
use Shopware\Core\Framework\DataAbstractionLayer\Event\EntityLoadedEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Shopware\Core\Content\Product\ProductEvents;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Storefront\Page\Product\ProductPageLoadedEvent;
use Shopware\Core\Content\Cms\CmsPageEntity;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\KernelEvent;
use Shopware\Storefront\Event\StorefrontRenderEvent;
use Shopware\Storefront\Pagelet\Footer\FooterPageletLoadedEvent;
use Nimbits\NimbitsLazyLoadingNext\Setting\Service\SettingService;
use Shopware\Core\Framework\Struct\ArrayEntity;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\System\SalesChannel\Entity\SalesChannelEntityLoadedEvent;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter;
use Shopware\Core\Framework\Struct\StructCollection;
use Shopware\Core\Content\Product\SalesChannel\SalesChannelProductEntity;
use Shopware\Core\Content\Media\DataAbstractionLayer\MediaRepositoryDecorator;
class Subscriber implements EventSubscriberInterface
{
/** @var SettingService $settingsService */
protected $settingsService;
public function __construct(
SettingService $settingsService
)
{
$this->settingsService = $settingsService;
}
public static function getSubscribedEvents(): array
{
// Return the events to listen to as array like this: <event to listen to> => <method to execute>
return [
FooterPageletLoadedEvent::class => 'onFooterLoaded'
];
}
public function onFooterLoaded(FooterPageletLoadedEvent $event)
{
$event->getPagelet()->addExtension('nimbitsLazyLoadingSettings',
$this->settingsService->getSettingsAsStruct($event->getSalesChannelContext()->getSalesChannel()->getId())
);
}
}
?>