<?php
/*
* This file is part of MultiCategorySearch
*
* Copyright(c) Akira Kurozumi <info@a-zumi.net>
*
* https://a-zumi.net
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Plugin\MultiCategorySearch42;
use Eccube\Event\TemplateEvent;
use Plugin\MultiCategorySearch42\Repository\SearchItemRepository;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class Event implements EventSubscriberInterface
{
/**
* @var SearchItemRepository
*/
private SearchItemRepository $searchItemRepository;
/**
* @return string[]
*/
public static function getSubscribedEvents(): array
{
return [
'@admin/Product/product.twig' => 'onTemplateAdminProduct',
];
}
public function __construct(SearchItemRepository $searchItemRepository)
{
$this->searchItemRepository = $searchItemRepository;
}
/**
* @param TemplateEvent $event
*
* @return void
*/
public function onTemplateAdminProduct(TemplateEvent $event): void
{
$searchItems = $this->searchItemRepository->findAll();
$event->setParameter('searchItems', $searchItems);
$event->addSnippet('@MultiCategorySearch42/admin/Product/product_search_item.twig');
}
}