custom/static-plugins/relewise/src/Subscriber/PageSubscriber.php line 25

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Wexo\Relewise\Subscriber;
  3. use Shopware\Storefront\Page\GenericPageLoadedEvent;
  4. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  5. class PageSubscriber implements EventSubscriberInterface
  6. {
  7.     public const RELEWISE_SEO_TITLE 'relewiseSeoTitle';
  8.     /**
  9.      * @return string[]
  10.      */
  11.     public static function getSubscribedEvents(): array
  12.     {
  13.         return [
  14.             GenericPageLoadedEvent::class => 'onPageLoaded'
  15.         ];
  16.     }
  17.     /**
  18.      * @param GenericPageLoadedEvent $event
  19.      */
  20.     public function onPageLoaded(GenericPageLoadedEvent $event)
  21.     {
  22.         $request $event->getRequest();
  23.         if ($metaInformation $event->getPage()->getMetaInformation()) {
  24.             $request->request->set(self::RELEWISE_SEO_TITLE$metaInformation->getMetaTitle());
  25.         }
  26.     }
  27. }