src/Eccube/Controller/UserDataController.php line 78

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.     /**
  45.      * @Route("/%eccube_user_data_route%/{route}", name="user_data", requirements={"route": "([0-9a-zA-Z_\-]+\/?)+(?<!\/)"}, methods={"GET"})
  46.      */
  47.     public function index(Request $request$route)
  48.     {
  49.         $Page $this->pageRepository->findOneBy(
  50.             [
  51.                 'url' => $route,
  52.                 'edit_type' => Page::EDIT_TYPE_USER,
  53.             ]
  54.         );
  55.         if (null === $Page) {
  56.             throw new NotFoundHttpException();
  57.         }
  58.         $file sprintf('@user_data/%s.twig'$Page->getFileName());
  59.         $event = new EventArgs(
  60.             [
  61.                 'Page' => $Page,
  62.                 'file' => $file,
  63.             ],
  64.             $request
  65.         );
  66.         $this->eventDispatcher->dispatch($eventEccubeEvents::FRONT_USER_DATA_INDEX_INITIALIZE);
  67.         return $this->render($file);
  68.     }
  69. }