<?php
/*
* This file is part of EC-CUBE
*
* Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
*
* http://www.ec-cube.co.jp/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Eccube\Controller;
use Eccube\Repository\NewsRepository;
use Eccube\Repository\ProductRepository;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\Routing\Annotation\Route;
class TopController extends AbstractController
{
/**
* @var NewsRepository
*/
protected $newsRepository;
/**
* @var ProductRepository
*/
protected $productRepository;
/**
* TopController constructor.
*
* @param NewsRepository $newsRepository
* @param ProductRepository $productRepository
*/
public function __construct(NewsRepository $newsRepository, ProductRepository $productRepository)
{
$this->newsRepository = $newsRepository;
$this->productRepository = $productRepository;
}
/**
* @Route("/", name="homepage", methods={"GET"})
* @Template("index.twig")
*/
public function index()
{
$latestNews = $this->newsRepository->getLatestNews(3);
$topRankingProducts = $this->productRepository->findTopRankingProducts(6);
return [
'latestNews' => $latestNews,
'topRankingProducts' => $topRankingProducts,
];
}
}