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/|news|plugin).*$"}, methods={"GET"})
  48.     */
  49.     
  50.     public function index(Request $request$route)
  51.     {
  52.         dump($request);
  53.         dump($route);
  54.         $Page $this->pageRepository->findOneBy(
  55.             [
  56.                 'url' => $route,
  57.                 'edit_type' => Page::EDIT_TYPE_USER,
  58.             ]
  59.         );
  60.         if (null === $Page) {
  61.             throw new NotFoundHttpException();
  62.         }
  63.         $file sprintf('@user_data/%s.twig'$Page->getFileName());
  64.         $event = new EventArgs(
  65.             [
  66.                 'Page' => $Page,
  67.                 'file' => $file,
  68.             ],
  69.             $request
  70.         );
  71.         $this->eventDispatcher->dispatch($eventEccubeEvents::FRONT_USER_DATA_INDEX_INITIALIZE);
  72.         return $this->render($file);
  73.     }
  74. }