src/Eccube/Controller/HelpController.php line 97

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\Entity\Category;
  14. use Eccube\Entity\ProductCategory;
  15. use Eccube\Repository\CategoryRepository;
  16. use Eccube\Repository\ProductRepository;
  17. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  18. use Symfony\Component\Routing\Annotation\Route;
  19. class HelpController extends AbstractController
  20. {
  21.     /**
  22.      * HelpController constructor.
  23.      */
  24.     public function __construct(
  25.         ProductRepository $productRepository,
  26.         CategoryRepository $categoryRepository,
  27.     ) {
  28.         $this->productRepository $productRepository;
  29.         $this->categoryRepository $categoryRepository;
  30.     }
  31.     /**
  32.      * ご利用ガイド.
  33.      *
  34.      * @Route("/guide", name="help_guide", methods={"GET"})
  35.      * @Template("Help/guide.twig")
  36.      */
  37.     public function guide()
  38.     {
  39.         return [];
  40.     }
  41.     /**
  42.      * 当サイトについて.
  43.      *
  44.      * @Route("/help/about", name="help_about", methods={"GET"})
  45.      * @Template("Help/about.twig")
  46.      */
  47.     public function about()
  48.     {
  49.         return [];
  50.     }
  51.     /**
  52.      * プライバシーポリシー.
  53.      *
  54.      * @Route("/help/privacy", name="help_privacy", methods={"GET"})
  55.      * @Template("Help/privacy.twig")
  56.      */
  57.     public function privacy()
  58.     {
  59.         return [];
  60.     }
  61.     /**
  62.      * 利用規約.
  63.      *
  64.      * @Route("/help/agreement", name="help_agreement", methods={"GET"})
  65.      * @Template("Help/agreement.twig")
  66.      */
  67.     public function agreement()
  68.     {
  69.         return [];
  70.     }
  71.     /**
  72.      * サイトマップ.
  73.      *
  74.      * @Route("/help/sitemap", name="help_sitemap", methods={"GET"})
  75.      * @Template("Help/sitemap.twig")
  76.      */
  77.     public function sitemap()
  78.     {
  79.         $categoryIds = [
  80.             Category::OIHAI,
  81.             Category::OBUTSUDAN_KUYOUDAI,
  82.             Category::BUTSUGU_SET,
  83.             Category::BUTSUGU_OTHER,
  84.             Category::TEMOTO_KUYOU,
  85.         ];
  86.         foreach ($categoryIds as $key => $categoryId) {
  87.             $Category $this->categoryRepository->find($categoryId);
  88.             $searchData["category_id"] = $Category;
  89.             $qb $this->productRepository->getQueryBuilderBySearchData($searchData);
  90.             $query $qb->getQuery();
  91.             $Products $query->getResult();
  92.             // MEMO: categoryProductsはkeyにカテゴリーの名前、valueにそのカテゴリーIDに対応した商品の配列を持つ
  93.             if($Category->getName() === "お仏壇・供養台"){
  94.                 $categoryProducts["お仏壇・ステージ"] = $Products;
  95.             } elseif ($Category->getName() === "仏具・その他"){
  96.                 $categoryProducts["仏具・日用品"] = $Products;
  97.             } else {
  98.                 $categoryProducts[$Category->getName()] = $Products;
  99.             }
  100.         }
  101.         $desiredOrder = ["お仏壇・ステージ""お位牌""仏具・日用品""仏壇・仏具セット""手元供養"];
  102.         $sortedArray = [];
  103.         foreach ($desiredOrder as $key) {
  104.             if (isset($categoryProducts[$key])) {
  105.                 $sortedArray[$key] = $categoryProducts[$key];
  106.             }
  107.         }
  108.         return [
  109.             'Products' => $sortedArray,
  110.         ];
  111.     }
  112. }