<?php
namespace Customize\Controller;
use Customize\Repository\CategoryRepository;
use Customize\Repository\ConstructionCaseRepository;
use Customize\Repository\ProductRepository;
use Eccube\Controller\AbstractController;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\Routing\Annotation\Route;
class HistoryController extends AbstractController
{
/**
* @var CategoryRepository
*/
private $categoryRepository;
/**
* @var ConstructionCaseRepository
*/
private $constructionCaseRepository;
/**
* @var ProductRepository
*/
private $productRepository;
/**
* HistoryController constructor.
*/
public function __construct(
CategoryRepository $categoryRepository,
ConstructionCaseRepository $constructionCaseRepository,
ProductRepository $productRepository
)
{
$this->categoryRepository = $categoryRepository;
$this->constructionCaseRepository = $constructionCaseRepository;
$this->productRepository = $productRepository;
}
/**
* @Route("/history", name="history")
* @Template("history.twig")
*/
public function index()
{
// 施工事例一覧を取得
$searchData = ['sortkey' => 'update_date', 'sorttype' => 'd'];
$queryBuilder = $this->constructionCaseRepository->getQueryBuilderBySearchDataForAdmin($searchData);
$queryBuilder->setMaxResults(16);
$constructions = $queryBuilder->getQuery()->getResult();
// カテゴリ1の商品(MADOBAシリーズ)を取得
$categoryId = 1;
$category1Products = $this->productRepository->findByCategoryId($categoryId, 12);
$category1 = $this->categoryRepository->find($categoryId);
return [
'Constructions' => $constructions,
'Category1Products' => $category1Products,
'Category1' => $category1,
];
}
}