app/Customize/Controller/FaqController.php line 111

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of EC-CUBE, Addition by INSPIRATION
  4.  *
  5.  */
  6. namespace Customize\Controller;
  7. use Customize\Repository\CategoriesRepository;
  8. use Customize\Repository\FaqsRepository;
  9. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  10. use Symfony\Component\Routing\Annotation\Route;
  11. use Symfony\Component\HttpFoundation\Request;
  12. use Eccube\Controller\AbstractController;
  13. class FaqController extends AbstractController
  14. {
  15.     /**
  16.      * @var CategoriesRepository
  17.      */
  18.     protected $categoriesRepository;
  19.     /**
  20.      * @var FaqsRepository
  21.      */
  22.     protected $faqsRepository;
  23.     /**
  24.      * FaqController constructor.
  25.      *
  26.      * @param FaqsRepository $faqsRepository
  27.      */
  28.     public function __construct(
  29.         CategoriesRepository $categoriesRepository,
  30.         FaqsRepository $faqsRepository
  31.     )
  32.     {
  33.         $this->categoriesRepository $categoriesRepository;
  34.         $this->faqsRepository $faqsRepository;
  35.     }
  36.     /**
  37.      * よくある質問.
  38.      *
  39.      * @Route("/faq", name="faq", methods={"GET"})
  40.      * @Template("Faq/index.twig")
  41.      */
  42.     public function index()
  43.     {
  44.         $qb $this->categoriesRepository->createQueryBuilder('c')
  45.             ->andWhere('c.del_flg = 0')
  46.             ->andWhere('c.release_flg = 1')
  47.             ->andWhere('c.program_name = :programName')
  48.             ->setParameter(':programName''Faq')
  49.             ->orderBy('c.rank');
  50.         $CategoryDatas $qb->getQuery()->getResult();
  51.         return [
  52.             'CategoryDatas' => $CategoryDatas,
  53.         ];
  54.     }
  55.     /**
  56.      * よくある質問検索結果.
  57.      *
  58.      * @Route("/faq/result", name="faq_result", methods={"GET"})
  59.      * @Template("Faq/result.twig")
  60.      */
  61.     public function result(Request $request)
  62.     {
  63.         $Result $request->query->get('query');
  64.         return [
  65.             'Result' => $Result,
  66.         ];
  67.     }
  68.     /**
  69.      * よくある質問カテゴリー画面.
  70.      *
  71.      * @Route("/faq/category/{id}", name="faq_category", methods={"GET"}, requirements={"id" = "\d+"})
  72.      * @Template("Faq/category.twig")
  73.      */
  74.     public function category($id)
  75.     {
  76.         $CategoryData $this->categoriesRepository->findOneBy(['id' => $id]);
  77.         $qb $this->faqsRepository->createQueryBuilder('f')
  78.             ->andWhere('f.del_flg = 0')
  79.             ->andWhere('f.release_flg = 1')
  80.             ->andWhere('f.category = :findCategory')
  81.             ->setParameter(':findCategory'$id)
  82.             ->orderBy('f.rank');
  83.         $FaqListDatas $qb->getQuery()->getResult();
  84.         return [
  85.             'CategoryData' => $CategoryData,
  86.             'FaqListDatas' => $FaqListDatas,
  87.         ];
  88.     }
  89.     /**
  90.      * よくある質問詳細画面.
  91.      *
  92.      * @Route("/faq/detail/{id}", name="faq_detail", methods={"GET"}, requirements={"id" = "\d+"})
  93.      * @Template("Faq/detail.twig")
  94.      */
  95.     public function detail($id)
  96.     {
  97.         $FaqData $this->faqsRepository->findOneBy(['id' => $id]);
  98.         $qb $this->faqsRepository->createQueryBuilder('f')
  99.             ->andWhere('f.del_flg = 0')
  100.             ->andWhere('f.release_flg = 1')
  101.             ->andWhere('f.category = :findCategory')
  102.             ->andWhere('f.id NOT IN (:excludes)')
  103.             ->setParameter(':findCategory'$FaqData['category'])
  104.             ->setParameter(':excludes'$FaqData['id'])
  105.             ->orderBy('f.rank');
  106.         $RelationDatas $qb->getQuery()->getResult();
  107.         return [
  108.             'FaqData' => $FaqData,
  109.             'RelationDatas' => $RelationDatas,
  110.         ];
  111.     }
  112. }