<?php
namespace Ecd\econdWebAnalytics\Storefront\Event\Subscriber;
use Shopware\Core\System\SystemConfig\SystemConfigService;
use Shopware\Storefront\Event\StorefrontRenderEvent;
use \Symfony\Component\EventDispatcher\EventSubscriberInterface;
class StorefrontRenderEventSubscriber implements EventSubscriberInterface
{
protected $systemConfigService;
/**
* StorefrontRenderEventSubscriber constructor.
* @param SystemConfigService $systemConfigService
*/
public function __construct(SystemConfigService $systemConfigService)
{
$this->systemConfigService = $systemConfigService;
}
/**
* @inheritDoc
*/public static function getSubscribedEvents()
{
return [
StorefrontRenderEvent::class => 'onStorefrontRenderEvent'
];
}
public function onStorefrontRenderEvent (StorefrontRenderEvent $event)
{
$content = strtok($_SERVER["REQUEST_URI"], '?');
if ($content == '/') {
$content = "Startseite";
}
$ana = [
'content' => $content,
'pageId' => md5($content)
];
$event->setParameter('ANA', $ana);
}
}