<?php
namespace Plugin\BrandManager;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Eccube\Event\TemplateEvent;
use Eccube\Repository\TagRepository;
class Event implements EventSubscriberInterface
{
/**
* @var TagRepository
*/
private $tagRepository;
public function __construct(
TagRepository $tagRepository
) {
$this->tagRepository = $tagRepository;
}
/**
* {@inheritdoc}
*
* @return array
*/
public static function getSubscribedEvents()
{
return [
'Product/detail.twig' => ['onTemplateProductDetail', 10],
'Brand/view.twig' => 'onTemplateBrandDetail',
];
}
/**
* Append JS to display maker
*
* @param TemplateEvent $templateEvent
*/
public function onTemplateProductDetail(TemplateEvent $templateEvent)
{
$templateEvent->addSnippet('@BrandManager/default/brand.twig');
}
public function onTemplateBrandDetail(TemplateEvent $templateEvent)
{
$DesignTags = $this->tagRepository->findBy(['show_product_list_flg' => true]);
$templateEvent->setParameter('DesignTags', $DesignTags);
$templateEvent->addAsset('@DesignTag4/tag_list_css.twig');
}
}