<?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\Entity\Category;
use Eccube\Entity\ProductCategory;
use Eccube\Repository\CategoryRepository;
use Eccube\Repository\ProductRepository;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\Routing\Annotation\Route;
class HelpController extends AbstractController
{
/**
* HelpController constructor.
*/
public function __construct(
ProductRepository $productRepository,
CategoryRepository $categoryRepository,
) {
$this->productRepository = $productRepository;
$this->categoryRepository = $categoryRepository;
}
/**
* ご利用ガイド.
*
* @Route("/guide", name="help_guide", methods={"GET"})
* @Template("Help/guide.twig")
*/
public function guide()
{
return [];
}
/**
* 当サイトについて.
*
* @Route("/help/about", name="help_about", methods={"GET"})
* @Template("Help/about.twig")
*/
public function about()
{
return [];
}
/**
* プライバシーポリシー.
*
* @Route("/help/privacy", name="help_privacy", methods={"GET"})
* @Template("Help/privacy.twig")
*/
public function privacy()
{
return [];
}
/**
* 利用規約.
*
* @Route("/help/agreement", name="help_agreement", methods={"GET"})
* @Template("Help/agreement.twig")
*/
public function agreement()
{
return [];
}
/**
* サイトマップ.
*
* @Route("/help/sitemap", name="help_sitemap", methods={"GET"})
* @Template("Help/sitemap.twig")
*/
public function sitemap()
{
$categoryIds = [
Category::OIHAI,
Category::OBUTSUDAN_KUYOUDAI,
Category::BUTSUGU_SET,
Category::BUTSUGU_OTHER,
Category::TEMOTO_KUYOU,
];
foreach ($categoryIds as $key => $categoryId) {
$Category = $this->categoryRepository->find($categoryId);
$searchData["category_id"] = $Category;
$qb = $this->productRepository->getQueryBuilderBySearchData($searchData);
$query = $qb->getQuery();
$Products = $query->getResult();
// MEMO: categoryProductsはkeyにカテゴリーの名前、valueにそのカテゴリーIDに対応した商品の配列を持つ
if($Category->getName() === "お仏壇・供養台"){
$categoryProducts["お仏壇・ステージ"] = $Products;
} elseif ($Category->getName() === "仏具・その他"){
$categoryProducts["仏具・日用品"] = $Products;
} else {
$categoryProducts[$Category->getName()] = $Products;
}
}
$desiredOrder = ["お仏壇・ステージ", "お位牌", "仏具・日用品", "仏壇・仏具セット", "手元供養"];
$sortedArray = [];
foreach ($desiredOrder as $key) {
if (isset($categoryProducts[$key])) {
$sortedArray[$key] = $categoryProducts[$key];
}
}
return [
'Products' => $sortedArray,
];
}
}