<?php declare(strict_types=1);
namespace Wexo\Relewise\Subscriber;
use Shopware\Storefront\Page\GenericPageLoadedEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class PageSubscriber implements EventSubscriberInterface
{
public const RELEWISE_SEO_TITLE = 'relewiseSeoTitle';
/**
* @return string[]
*/
public static function getSubscribedEvents(): array
{
return [
GenericPageLoadedEvent::class => 'onPageLoaded'
];
}
/**
* @param GenericPageLoadedEvent $event
*/
public function onPageLoaded(GenericPageLoadedEvent $event)
{
$request = $event->getRequest();
if ($metaInformation = $event->getPage()->getMetaInformation()) {
$request->request->set(self::RELEWISE_SEO_TITLE, $metaInformation->getMetaTitle());
}
}
}