app/Customize/EventListener/SchemaOrgEventListener.php line 26

Open in your IDE?
  1. <?php
  2. namespace Customize\EventListener;
  3. use Eccube\Event\TemplateEvent;
  4. use Lm\Engine\EC\Entity\GoodsWithRelated;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. class SchemaOrgEventListener implements EventSubscriberInterface
  7. {
  8.     /**
  9.     * @inheritDoc
  10.     */
  11.     public static function getSubscribedEvents()
  12.     {
  13.         return [
  14.             'Item/detail.twig' => 'onProductDetail',
  15.         ];
  16.     }
  17.     /**
  18.      * @param TemplateEvent $event
  19.      * @return void
  20.      */
  21.     public function onProductDetail(TemplateEvent $event)
  22.     {
  23.         /**
  24.          * @var GoodsWithRelated $goods
  25.          */
  26.         $goods $event->getParameter('goods');
  27.         //
  28.         $schemaOrgProduct $goods->getSchemaOrgProduct();
  29.         //
  30.         $event->setParameter('SchemaOrgProduct'$schemaOrgProduct);
  31.         //
  32.         $event->addSnippet('SchemaOrg/Product/detail.twig');
  33.     }
  34. }