app/Plugin/BrandManager/Event.php line 46

Open in your IDE?
  1. <?php
  2. namespace Plugin\BrandManager;
  3. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  4. use Eccube\Event\TemplateEvent;
  5. use Eccube\Repository\TagRepository;
  6. class Event implements EventSubscriberInterface
  7. {
  8.     
  9.     /**
  10.      * @var TagRepository
  11.      */
  12.     private $tagRepository;
  13.     public function __construct(
  14.         TagRepository $tagRepository
  15.     ) {
  16.         $this->tagRepository $tagRepository;
  17.     }
  18.   
  19.     /**
  20.      * {@inheritdoc}
  21.      *
  22.      * @return array
  23.      */
  24.     public static function getSubscribedEvents()
  25.     {
  26.         return [
  27.             'Product/detail.twig' => ['onTemplateProductDetail'10],
  28.             'Brand/view.twig' => 'onTemplateBrandDetail',
  29.         ];
  30.     }
  31.     /**
  32.      * Append JS to display maker
  33.      *
  34.      * @param TemplateEvent $templateEvent
  35.      */
  36.     public function onTemplateProductDetail(TemplateEvent $templateEvent)
  37.     {
  38.         $templateEvent->addSnippet('@BrandManager/default/brand.twig');
  39.     }
  40.     
  41.     public function onTemplateBrandDetail(TemplateEvent $templateEvent)
  42.     {
  43.       $DesignTags $this->tagRepository->findBy(['show_product_list_flg' => true]);
  44.       $templateEvent->setParameter('DesignTags'$DesignTags);
  45.       $templateEvent->addAsset('@DesignTag4/tag_list_css.twig');
  46.     }
  47. }