src/Eccube/Controller/TopController.php line 49

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 Eccube\Controller;
  13. use Eccube\Repository\NewsRepository;
  14. use Eccube\Repository\ProductRepository;
  15. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  16. use Symfony\Component\Routing\Annotation\Route;
  17. class TopController extends AbstractController
  18. {
  19.     /**
  20.      * @var NewsRepository
  21.      */
  22.     protected $newsRepository;
  23.     /**
  24.      * @var ProductRepository
  25.      */
  26.     protected $productRepository;
  27.     /**
  28.      * TopController constructor.
  29.      *
  30.      * @param NewsRepository $newsRepository
  31.      * @param ProductRepository $productRepository
  32.      */
  33.     public function __construct(NewsRepository $newsRepositoryProductRepository $productRepository)
  34.     {
  35.         $this->newsRepository $newsRepository;
  36.         $this->productRepository $productRepository;
  37.     }
  38.     /**
  39.      * @Route("/", name="homepage", methods={"GET"})
  40.      * @Template("index.twig")
  41.      */
  42.     public function index()
  43.     {
  44.         $latestNews $this->newsRepository->getLatestNews(3);
  45.         $topRankingProducts $this->productRepository->findTopRankingProducts(6);
  46.         return [
  47.             'latestNews' => $latestNews,
  48.             'topRankingProducts' => $topRankingProducts,
  49.         ];
  50.     }
  51. }