custom/plugins/ATNTheme/src/Subscriber/CmsFooterSubscriber.php line 44

Open in your IDE?
  1. <?php
  2. namespace ATNTheme\Subscriber;
  3. use ATNTheme\Service\CmsFooterService;
  4. use Shopware\Storefront\Pagelet\Footer\FooterPageletLoadedEvent;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. /**
  7.  * Class CmsFooterSubscriber
  8.  */
  9. class CmsFooterSubscriber implements EventSubscriberInterface
  10. {
  11.     /**
  12.      * @var CmsFooterService
  13.      **/
  14.     protected $cmsFooterService;
  15.     /**
  16.      * @param CmsFooterService $cmsFooterService
  17.      */
  18.     public function __construct(CmsFooterService $cmsFooterService)
  19.     {
  20.         $this->cmsFooterService $cmsFooterService;
  21.     }
  22.     /**
  23.      * undocumented function
  24.      *
  25.      * @return void
  26.      */
  27.     public static function getSubscribedEvents(): array
  28.     {
  29.         return [
  30.             FooterPageletLoadedEvent::class => 'onFooterLoaded',
  31.         ];
  32.     }
  33.     /**
  34.      * @param FooterPageletLoadedEvent $event
  35.      *
  36.      * @return void
  37.      */
  38.     public function onFooterLoaded(FooterPageletLoadedEvent $event)
  39.     {
  40.         $page $this
  41.             ->cmsFooterService
  42.             ->getFooterContent(
  43.                 $event->getSalesChannelContext(),
  44.                 $event->getRequest()
  45.             );
  46.         if ($page) {
  47.             $event
  48.                 ->getPagelet()
  49.                 ->addExtension(
  50.                     'cms_page',
  51.                     $page
  52.                 );
  53.         }
  54.     }
  55. }