src/Eccube/Controller/UserDataController.php line 58

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\Page;
  14. use Eccube\Event\EccubeEvents;
  15. use Eccube\Event\EventArgs;
  16. use Eccube\Repository\Master\DeviceTypeRepository;
  17. use Eccube\Repository\PageRepository;
  18. use Symfony\Component\HttpFoundation\Request;
  19. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  20. use Symfony\Component\Routing\Annotation\Route;
  21. class UserDataController extends AbstractController
  22. {
  23.     /**
  24.      * @var PageRepository
  25.      */
  26.     protected $pageRepository;
  27.     /**
  28.      * @var DeviceTypeRepository
  29.      */
  30.     protected $deviceTypeRepository;
  31.     /**
  32.      * UserDataController constructor.
  33.      *
  34.      * @param PageRepository $pageRepository
  35.      * @param DeviceTypeRepository $deviceTypeRepository
  36.      */
  37.     public function __construct(
  38.         PageRepository $pageRepository,
  39.         DeviceTypeRepository $deviceTypeRepository
  40.     ) {
  41.         $this->pageRepository $pageRepository;
  42.         $this->deviceTypeRepository $deviceTypeRepository;
  43.     }
  44.     // hanari@20240512
  45.     //https://techmemo.biz/ec-cube/user_data-url-delete-change/
  46.     /**
  47.      * @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/1|products/add_cart/2|products/add_cart/3|news).*$"}, methods={"GET"})
  48.     */
  49.     
  50.     public function index(Request $request$route)
  51.     {
  52.         $Page $this->pageRepository->findOneBy(
  53.             [
  54.                 'url' => $route,
  55.                 'edit_type' => Page::EDIT_TYPE_USER,
  56.             ]
  57.         );
  58.         if (null === $Page) {
  59.             throw new NotFoundHttpException();
  60.         }
  61.         $file sprintf('@user_data/%s.twig'$Page->getFileName());
  62.         $event = new EventArgs(
  63.             [
  64.                 'Page' => $Page,
  65.                 'file' => $file,
  66.             ],
  67.             $request
  68.         );
  69.         $this->eventDispatcher->dispatch($eventEccubeEvents::FRONT_USER_DATA_INDEX_INITIALIZE);
  70.         return $this->render($file);
  71.     }
  72. }