custom/plugins/TraumPlugin/src/Storefront/Subscriber/FooterSubscriber.php line 36

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace TraumPlugin\Storefront\Subscriber;
  3. use Shopware\Core\System\SystemConfig\SystemConfigService;
  4. use Shopware\Storefront\Pagelet\Footer\FooterPageletLoadedEvent;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. class FooterSubscriber implements EventSubscriberInterface
  7. {
  8.     public const CONFIG_EXTENSION_NAME 'TraumPlugin';
  9.     /**
  10.      * @var SystemConfigService
  11.      */
  12.     private $systemConfigService;
  13.     public function __construct(
  14.         SystemConfigService $systemConfigService
  15.     )
  16.     {
  17.         $this->systemConfigService $systemConfigService;
  18.     }
  19.     /**
  20.      * @return string[
  21.      */
  22.     public static function getSubscribedEvents()
  23.     {
  24.         return [FooterPageletLoadedEvent::class => 'onFooterPageletLoaded'];
  25.     }
  26.     /**
  27.      * @param FooterPageletLoadedEvent $event
  28.      */
  29.     public function onFooterPageletLoaded(FooterPageletLoadedEvent $event)
  30.     {
  31.         if (!$this->systemConfigService->get('TraumPlugin.config.showInStorefront')) {
  32.             return;
  33.         }
  34.         $seo_text $this->systemConfigService->get('TraumPlugin.config.text');
  35.         $config = new ConfigStruct();
  36.         $config->setSeoText($seo_text);
  37.         $event->getPagelet()->addExtension(self::CONFIG_EXTENSION_NAME$config);
  38.     }
  39. }