app/Customize/Controller/UserDataController.php line 66

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 Customize\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. use Eccube\Controller\AbstractController;
  22. class UserDataController extends AbstractController
  23. {
  24.     /**
  25.      * @var PageRepository
  26.      */
  27.     protected $pageRepository;
  28.     /**
  29.      * @var DeviceTypeRepository
  30.      */
  31.     protected $deviceTypeRepository;
  32.     /**
  33.      * UserDataController constructor.
  34.      *
  35.      * @param PageRepository $pageRepository
  36.      * @param DeviceTypeRepository $deviceTypeRepository
  37.      */
  38.     public function __construct(
  39.         PageRepository $pageRepository,
  40.         DeviceTypeRepository $deviceTypeRepository
  41.     ) {
  42.         $this->pageRepository $pageRepository;
  43.         $this->deviceTypeRepository $deviceTypeRepository;
  44.     }
  45.     /**
  46.      * @Route("/{route}", name="user_data", requirements={"route": "([0-9a-zA-Z_\-]+\/?)+(?<!\/)"}, methods={"GET"})
  47.      */
  48.     public function index(Request $request$route)
  49.     {
  50.         $Page $this->pageRepository->findOneBy(
  51.             [
  52.                 'url' => $route,
  53.                 'edit_type' => Page::EDIT_TYPE_USER,
  54.             ]
  55.         );
  56.         if (null === $Page) {
  57.             throw new NotFoundHttpException();
  58.         }
  59.         $file sprintf('@user_data/%s.twig'$Page->getFileName());
  60.         $event = new EventArgs(
  61.             [
  62.                 'Page' => $Page,
  63.                 'file' => $file,
  64.             ],
  65.             $request
  66.         );
  67.         $this->eventDispatcher->dispatch(EccubeEvents::FRONT_USER_DATA_INDEX_INITIALIZE$event);
  68.         return $this->render($file);
  69.     }
  70. }