<?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\Page;
use Eccube\Event\EccubeEvents;
use Eccube\Event\EventArgs;
use Eccube\Repository\Master\DeviceTypeRepository;
use Eccube\Repository\PageRepository;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Routing\Annotation\Route;
class UserDataController extends AbstractController
{
/**
* @var PageRepository
*/
protected $pageRepository;
/**
* @var DeviceTypeRepository
*/
protected $deviceTypeRepository;
/**
* UserDataController constructor.
*
* @param PageRepository $pageRepository
* @param DeviceTypeRepository $deviceTypeRepository
*/
public function __construct(
PageRepository $pageRepository,
DeviceTypeRepository $deviceTypeRepository
) {
$this->pageRepository = $pageRepository;
$this->deviceTypeRepository = $deviceTypeRepository;
}
// hanari@20240512
//https://techmemo.biz/ec-cube/user_data-url-delete-change/
/**
* @Route("/{route}", name="user_data", requirements={"route": "^(?=([0-9a-zA-Z_\-]+\/?)+(?<!\/))(?!logout|%eccube_admin_route%/logout|install|administrator|shopping|products|cart|productoption_cart|products/add_cart/|news|plugin).*$"}, methods={"GET"})
*/
public function index(Request $request, $route)
{
dump($request);
dump($route);
$Page = $this->pageRepository->findOneBy(
[
'url' => $route,
'edit_type' => Page::EDIT_TYPE_USER,
]
);
if (null === $Page) {
throw new NotFoundHttpException();
}
$file = sprintf('@user_data/%s.twig', $Page->getFileName());
$event = new EventArgs(
[
'Page' => $Page,
'file' => $file,
],
$request
);
$this->eventDispatcher->dispatch($event, EccubeEvents::FRONT_USER_DATA_INDEX_INITIALIZE);
return $this->render($file);
}
}