<?php declare(strict_types=1);
/**
* GourmopsProductShortDescription
* Copyright (c) Simone Gottwald GOURMOPS
*/
namespace GourmopsProductShortDescription\Subscriber;
use GourmopsProductShortDescription\GourmopsProductShortDescription;
use Shopware\Core\Framework\Struct\ArrayStruct;
use Shopware\Storefront\Pagelet\Footer\FooterPagelet;
use Shopware\Storefront\Pagelet\Footer\FooterPageletLoadedEvent;
/**
* Class FooterPageletSubscriber
*/
class FooterPageletSubscriber extends AbstractSubscriber
{
/**
* @return string[]
*/
public static function getSubscribedEvents(): array
{
return [
FooterPageletLoadedEvent::class => 'onFooterPageletLoaded',
];
}
/**
* @param FooterPageletLoadedEvent $event
*
* @return void
*/
public function onFooterPageletLoaded(FooterPageletLoadedEvent $event): void
{
/** @var array $config */
$config = $this->getConfig($event->getSalesChannelContext());
/** @var FooterPagelet $footerPagelet */
$footerPagelet = $event->getPagelet();
if (empty($config) ||
empty($config['activated'])
) {
return;
}
$footerPagelet->addExtension(GourmopsProductShortDescription::FIELD_PLACEHOLDER, new ArrayStruct());
}
}