<?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 Customize\Controller;
use Customize\Controller\LM\LmAbstractController;
use Customize\Entity\CacheTrait;
use Customize\Service\LmHelper;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\Routing\Annotation\Route;
use Customize\Converter\DynamicConverter;
use Customize\Service\CommonService;
use Eccube\Common\EccubeConfig;
use Symfony\Component\HttpFoundation\Request;
class TopController extends LmAbstractController
{
use CacheTrait;
protected $DynamicConverter;
protected $EccubeConfig;
public function __construct(
CommonService $CommonService,
LmHelper $LmHelper,
DynamicConverter $DynamicConverter,
EccubeConfig $EccubeConfig
)
{
//
parent::__construct($CommonService, $LmHelper);
//
$this->DynamicConverter = $DynamicConverter;
$this->EccubeConfig = $EccubeConfig;
}
/**
* @Route("/", name="homepage", methods={"GET"})
* @param Request $request
* @Template("Top/index.twig")
* @return array
*/
public function index(Request $request)
{
//
$device = strtolower($this->CommonService->GetDevice());
//
$masterCacheKey = self::getMasterCacheKey();
// TODO: $suffix
$suffix = '';
//
$viewCacheKey = "{$masterCacheKey}__{$device}_view__{$suffix}";
//
$masterCache = $this->handleMasterCache($masterCacheKey, $device, [
$viewCacheKey,
]);
//
return $this->getCacheByKey($viewCacheKey, function () {
//
return $this->_index();
});
}
/**
* @param Request $request
* @return array
*/
public function _index()
{
$upperColumnData = $this->DynamicConverter->getUpperColumnByCategory()['upper_one_column_content'] ?? null;
$mainContent['pc_content_html'] = $this->DynamicConverter->getPageContent('pc', 'top', 'main')['pc_content_html'];
$mainContent['pc_content_html'] = str_replace('alt="0"', 'alt="0" width="18px" height="22px"', $mainContent['pc_content_html']);
$mainContent['pc_content_html'] = str_replace('src="https://img0.land-mark.biz/ut_img/public_images/top/main_banner/saitan.png"', 'src="https://img0.land-mark.biz/ut_img/public_images/top/main_banner/saitan.png" width="30px" height="15px"', $mainContent['pc_content_html']);
$mainContent['pc_content_html'] = str_replace('src="https://img0.land-mark.biz/ut_img/public_images/categorypage/banner/work/work-burtle-reservation-2022aw-nyuuka-1col.jpg"', 'src="https://img0.land-mark.biz/ut_img/public_images/categorypage/banner/work/work-burtle-reservation-2022aw-nyuuka-1col.jpg" width="805px" height="200px"', $mainContent['pc_content_html']);
$mainContent['pc_content_html'] = str_replace('src="https://img0.land-mark.biz/ut_img/public_images/categorypage/banner/work/work-burtle-reservation-2022ss-nyuuka-1col.jpg"', 'src="https://img0.land-mark.biz/ut_img/public_images/categorypage/banner/work/work-burtle-reservation-2022ss-nyuuka-1col.jpg" width="805px" height="200px"', $mainContent['pc_content_html']);
$mainContent['sp_content_html'] = $this->DynamicConverter->getPageContent('sp', 'top', 'main')['pc_content_html'];
$visitSubCategoryList = $this->DynamicConverter->getVisitSubCategoryList();
$messageList = $this->DynamicConverter->getMessageList('', 5, 1);
$custom_menu = $this->DynamicConverter->getMenuGroup($this->EccubeConfig['EditSpMenu']['MENU_NAME_COMMON'], $this->EccubeConfig['EditSpMenu']['BOOL_TRUE']);
$custom_frequently_searched_word = $this->DynamicConverter->getSearchWordGroup($this->EccubeConfig['EditSpMenu']['MENU_NAME_COMMON'], $this->EccubeConfig['EditSpMenu']['BOOL_TRUE']);
$updatedContent = true;
return [
'mainContent' => $mainContent,
'upperColumnData' => $upperColumnData,
'visitSubCategoryList' => $visitSubCategoryList,
'messageList' => $messageList,
'custom_menu' => $custom_menu,
'custom_frequently_searched_word' => $custom_frequently_searched_word,
'updatedContent' => $updatedContent,
'dataLayer' => $this->dataLayer,
];
}
/**
* #Route("/top", name="top", methods={"GET"})
* @Template()
*/
public function top(Request $request)
{
return $this->redirectToRoute('homepage');
}
/**
* @return string
*/
public static function getMasterCacheKey()
{
//
$masterCacheKey = "index_index";
//
$masterCacheKey = str_replace('-', '_', $masterCacheKey);
//
return $masterCacheKey;
}
}