<?php
namespace Customize\EventListener;
use Eccube\Event\TemplateEvent;
use Lm\Engine\EC\Entity\GoodsWithRelated;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class SchemaOrgEventListener implements EventSubscriberInterface
{
/**
* @inheritDoc
*/
public static function getSubscribedEvents()
{
return [
'Item/detail.twig' => 'onProductDetail',
];
}
/**
* @param TemplateEvent $event
* @return void
*/
public function onProductDetail(TemplateEvent $event)
{
/**
* @var GoodsWithRelated $goods
*/
$goods = $event->getParameter('goods');
//
$schemaOrgProduct = $goods->getSchemaOrgProduct();
//
$event->setParameter('SchemaOrgProduct', $schemaOrgProduct);
//
$event->addSnippet('SchemaOrg/Product/detail.twig');
}
}