app/Plugin/AddBanner/Event.php line 46

Open in your IDE?
  1. <?php
  2. namespace Plugin\AddBanner;
  3. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  4. use Eccube\Event\EccubeEvents;
  5. use Eccube\Event\EventArgs;
  6. use Twig\Environment;
  7. use Plugin\AddBanner\Repository\AddBannerRepository;
  8. class Event implements EventSubscriberInterface
  9. {
  10.         /**
  11.      * @var Environment
  12.      */
  13.     protected $twig;
  14.     /**
  15.      * @var AddBannerRepository
  16.      */
  17.     protected $addBannerRepository;
  18.     /**
  19.      * ProductController constructor.
  20.      *
  21.      * @param AddBannerRepository $addBannerRepository
  22.      */
  23.     public function __construct(
  24.         Environment $twig,
  25.         AddBannerRepository $addBannerRepository
  26.     ) {
  27.         $this->twig $twig;
  28.         $this->addBannerRepository $addBannerRepository;
  29.     }
  30.     /**
  31.      * @return array
  32.      */
  33.     public static function getSubscribedEvents()
  34.     {
  35.         return [
  36.             EccubeEvents::FRONT_PRODUCT_INDEX_INITIALIZE => 'addBannerFunction',
  37.         ];
  38.     }
  39.     public function addBannerFunction(EventArgs $event)
  40.     {
  41.         // バナー情報を追加
  42.         $searchData = array();
  43.         $addBanners $this->addBannerRepository->getQueryBuilderBySearchData($searchData);
  44.         //$addBanners = $app['eccube.plugin.addBanner.repository.addBanner']->findBy(array(), array('order_no' => 'DESC'));
  45.         $this->twig->addGlobal('AddBanners'$addBanners);
  46.     }
  47. }