app/Customize/Controller/TopController.php line 57

Open in your IDE?
  1. <?php
  2. namespace Customize\Controller;
  3. use Eccube\Controller\AbstractController;
  4. use Customize\Repository\TopImageRepository;
  5. use Customize\Repository\NewsRepository;
  6. use Customize\Repository\ProductRepository;
  7. use Customize\Repository\TopProductRepository;
  8. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  9. use Symfony\Component\Routing\Annotation\Route;
  10. class TopController extends AbstractController
  11. {
  12.     /**
  13.      * @var TopImageRepository
  14.      */
  15.     protected $topImageRepository;
  16.     /**
  17.      * @var NewsRepository
  18.      */
  19.     protected $newsRepository;
  20.     /**
  21.      * @var ProductRepository
  22.      */
  23.     protected $productRepository;
  24.     /**
  25.      * @var TopProductRepository
  26.      */
  27.     protected $topProductRepository;
  28.     /**
  29.      * TopImageController constructor.
  30.      *
  31.      * @param TopImageRepository $topImageRepository
  32.      * @param NewsRepository $newsRepository
  33.      */
  34.     public function __construct(
  35.         TopImageRepository $topImageRepository,
  36.         NewsRepository $newsRepository,
  37.         TopProductRepository $topProductRepository,
  38.         ProductRepository $productRepository
  39.     ){
  40.         $this->topImageRepository $topImageRepository;
  41.         $this->newsRepository $newsRepository;
  42.         $this->productRepository $productRepository;
  43.         $this->topProductRepository $topProductRepository;
  44.     }
  45.     /**
  46.      * @Route("/", name="homepage")
  47.      * @Template("index.twig")
  48.      */
  49.     public function index()
  50.     {
  51.         $TopImages $this->topImageRepository->findBy([], ['sort_no' => 'DESC']);
  52.         
  53.         $NewsList1 $this->newsRepository->getList(3,0);
  54.         $NewsList2 $this->newsRepository->getList(3,3);
  55.         $productIntroduction $this->topProductRepository->getQueryBuilderAll()->getQuery()->getResult();
  56.         $ids = [];
  57.         foreach ($productIntroduction as $Product) {
  58.             $ids[] = $Product['product_id'];
  59.         }
  60.         $Products $this->productRepository->getProductIntroductionList($ids);
  61.         
  62.         return [
  63.             'TopImages' => $TopImages,
  64.             'NewsList1' => $NewsList1,
  65.             'NewsList2' => $NewsList2,
  66.             'Products'   => $Products
  67.         ];
  68.     }
  69. }