app/Plugin/EccubePaymentLite4/EventListener/EventSubscriber/Admin/Product/AddRegularCycleFormToProductClassEditType.php line 30

Open in your IDE?
  1. <?php
  2. namespace Plugin\EccubePaymentLite4\EventListener\EventSubscriber\Admin\Product;
  3. use Eccube\Entity\Master\SaleType;
  4. use Eccube\Event\TemplateEvent;
  5. use Eccube\Repository\Master\SaleTypeRepository;
  6. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  7. class AddRegularCycleFormToProductClassEditType implements EventSubscriberInterface
  8. {
  9.     /**
  10.      * @var SaleTypeRepository
  11.      */
  12.     private $saleTypeRepository;
  13.     public function __construct(
  14.         SaleTypeRepository $saleTypeRepository
  15.     ) {
  16.         $this->saleTypeRepository $saleTypeRepository;
  17.     }
  18.     public static function getSubscribedEvents()
  19.     {
  20.         return [
  21.             '@admin/Product/product_class.twig' => 'index',
  22.         ];
  23.     }
  24.     public function index(TemplateEvent $event)
  25.     {
  26.         /** @var SaleType $SaleType */
  27.         $SaleType $this->saleTypeRepository->findOneBy([
  28.             'name' => '定期商品',
  29.         ]);
  30.         if (is_null($SaleType)) {
  31.             return;
  32.         }
  33.         $event->setParameter('regularSaleTypeId'$SaleType->getId());
  34.         $event->addSnippet('@EccubePaymentLite4/admin/Product/ProductClass/regular_cycle_form.twig');
  35.     }
  36. }