<?php
namespace ATNTheme\Subscriber;
use ATNTheme\Service\CmsFooterService;
use Shopware\Storefront\Pagelet\Footer\FooterPageletLoadedEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
* Class CmsFooterSubscriber
*/
class CmsFooterSubscriber implements EventSubscriberInterface
{
/**
* @var CmsFooterService
**/
protected $cmsFooterService;
/**
* @param CmsFooterService $cmsFooterService
*/
public function __construct(CmsFooterService $cmsFooterService)
{
$this->cmsFooterService = $cmsFooterService;
}
/**
* undocumented function
*
* @return void
*/
public static function getSubscribedEvents(): array
{
return [
FooterPageletLoadedEvent::class => 'onFooterLoaded',
];
}
/**
* @param FooterPageletLoadedEvent $event
*
* @return void
*/
public function onFooterLoaded(FooterPageletLoadedEvent $event)
{
$page = $this
->cmsFooterService
->getFooterContent(
$event->getSalesChannelContext(),
$event->getRequest()
);
if ($page) {
$event
->getPagelet()
->addExtension(
'cms_page',
$page
);
}
}
}