app/Plugin/MultiCategorySearch42/Event.php line 47

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of MultiCategorySearch
  4.  *
  5.  * Copyright(c) Akira Kurozumi <info@a-zumi.net>
  6.  *
  7.  * https://a-zumi.net
  8.  *
  9.  * For the full copyright and license information, please view the LICENSE
  10.  * file that was distributed with this source code.
  11.  */
  12. namespace Plugin\MultiCategorySearch42;
  13. use Eccube\Event\TemplateEvent;
  14. use Plugin\MultiCategorySearch42\Repository\SearchItemRepository;
  15. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  16. class Event implements EventSubscriberInterface
  17. {
  18.     /**
  19.      * @var SearchItemRepository
  20.      */
  21.     private SearchItemRepository $searchItemRepository;
  22.     /**
  23.      * @return string[]
  24.      */
  25.     public static function getSubscribedEvents(): array
  26.     {
  27.         return [
  28.             '@admin/Product/product.twig' => 'onTemplateAdminProduct',
  29.         ];
  30.     }
  31.     public function __construct(SearchItemRepository $searchItemRepository)
  32.     {
  33.         $this->searchItemRepository $searchItemRepository;
  34.     }
  35.     /**
  36.      * @param TemplateEvent $event
  37.      *
  38.      * @return void
  39.      */
  40.     public function onTemplateAdminProduct(TemplateEvent $event): void
  41.     {
  42.         $searchItems $this->searchItemRepository->findAll();
  43.         $event->setParameter('searchItems'$searchItems);
  44.         $event->addSnippet('@MultiCategorySearch42/admin/Product/product_search_item.twig');
  45.     }
  46. }