app/Customize/Controller/HistoryController.php line 47

Open in your IDE?
  1. <?php
  2. namespace Customize\Controller;
  3. use Customize\Repository\CategoryRepository;
  4. use Customize\Repository\ConstructionCaseRepository;
  5. use Customize\Repository\ProductRepository;
  6. use Eccube\Controller\AbstractController;
  7. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  8. use Symfony\Component\Routing\Annotation\Route;
  9. class HistoryController extends AbstractController
  10. {
  11.     /**
  12.      * @var CategoryRepository
  13.      */
  14.     private $categoryRepository;
  15.     /**
  16.      * @var ConstructionCaseRepository
  17.      */
  18.     private $constructionCaseRepository;
  19.     /**
  20.      * @var ProductRepository
  21.      */
  22.     private $productRepository;
  23.     /**
  24.      * HistoryController constructor.
  25.      */
  26.     public function __construct(
  27.         CategoryRepository $categoryRepository,
  28.         ConstructionCaseRepository $constructionCaseRepository,
  29.         ProductRepository $productRepository
  30.     )
  31.     {
  32.         $this->categoryRepository $categoryRepository;
  33.         $this->constructionCaseRepository $constructionCaseRepository;
  34.         $this->productRepository $productRepository;
  35.     }
  36.     /**
  37.      * @Route("/history", name="history")
  38.      * @Template("history.twig")
  39.      */
  40.     public function index()
  41.     {
  42.         // 施工事例一覧を取得
  43.         $searchData = ['sortkey' => 'update_date''sorttype' => 'd'];
  44.         $queryBuilder $this->constructionCaseRepository->getQueryBuilderBySearchDataForAdmin($searchData);
  45.         $queryBuilder->setMaxResults(16);
  46.         $constructions $queryBuilder->getQuery()->getResult();
  47.         // カテゴリ1の商品(MADOBAシリーズ)を取得
  48.         $categoryId 1;
  49.         $category1Products $this->productRepository->findByCategoryId($categoryId12);
  50.         $category1 $this->categoryRepository->find($categoryId);
  51.         return [
  52.             'Constructions' => $constructions,
  53.             'Category1Products' => $category1Products,
  54.             'Category1' => $category1,
  55.         ];
  56.     }
  57. }