app/Customize/Controller/CustomTopController.php line 37

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of EC-CUBE
  4.  *
  5.  * Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
  6.  *
  7.  * http://www.ec-cube.co.jp/
  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 Customize\Controller;
  13. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  14. use Symfony\Component\Routing\Annotation\Route;
  15. use Eccube\Controller\AbstractController;
  16. use Eccube\Repository\ProductRepository;
  17. use Plugin\CMBlogPro42\Repository\BlogRepository;
  18. class CustomTopController extends AbstractController
  19. {
  20.     public function __construct(
  21.         BlogRepository $blogRepository,
  22.         ProductRepository $productRepository
  23.     )
  24.     {
  25.         $this->blogRepository $blogRepository;
  26.         $this->productRepository $productRepository;
  27.     }
  28.     /**
  29.      * @Route("/", name="homepage", methods={"GET"})
  30.      * @Template("index.twig")
  31.      */
  32.     public function index()
  33.     {
  34.         $news $this->blogRepository->getList();
  35.         $qb $this->productRepository->getQueryBuilderBySearchData([]);
  36.         // is_hiddenフラグで非表示商品を除外
  37.         $qb->andWhere('p.is_hidden = :is_hidden OR p.is_hidden IS NULL')
  38.            ->setParameter('is_hidden'false);
  39.         $qb->orderBy('p.id''ASC');
  40.         $products $qb->getQuery()->getResult();
  41.         $subMapRaw getenv('SUBSCRIPTION_MAP');
  42.         $subMap = [];
  43.         if (!empty($subMapRaw)) {
  44.             $subMapRaw explode(','$subMapRaw);
  45.             foreach ($subMapRaw as $map) {
  46.                 $map explode(':'$map);
  47.                 $subMap[$map[0]] = $map[1];
  48.             }
  49.         }
  50.         return ['news' => $news'products' => $products'subMap' => $subMap];
  51.     }
  52. }