1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of EC-CUBE |
5
|
|
|
* |
6
|
|
|
* Copyright(c) LOCKON CO.,LTD. All Rights Reserved. |
7
|
|
|
* |
8
|
|
|
* http://www.lockon.co.jp/ |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Eccube\Controller; |
15
|
|
|
|
16
|
|
|
use Eccube\Entity\Master\DeviceType; |
17
|
|
|
use Eccube\Entity\Page; |
18
|
|
|
use Eccube\Event\EccubeEvents; |
19
|
|
|
use Eccube\Event\EventArgs; |
20
|
|
|
use Eccube\Repository\Master\DeviceTypeRepository; |
21
|
|
|
use Eccube\Repository\PageRepository; |
22
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; |
23
|
|
|
use Symfony\Component\HttpFoundation\Request; |
24
|
|
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |
25
|
|
|
|
26
|
|
|
class UserDataController extends AbstractController |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* @var PageRepository |
30
|
|
|
*/ |
31
|
|
|
protected $pageRepository; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @var DeviceTypeRepository |
35
|
|
|
*/ |
36
|
|
|
protected $deviceTypeRepository; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* UserDataController constructor. |
40
|
|
|
* |
41
|
|
|
* @param PageRepository $pageRepository |
42
|
|
|
* @param DeviceTypeRepository $deviceTypeRepository |
43
|
|
|
*/ |
44
|
2 |
|
public function __construct( |
45
|
|
|
PageRepository $pageRepository, |
46
|
|
|
DeviceTypeRepository $deviceTypeRepository |
47
|
|
|
) { |
48
|
2 |
|
$this->pageRepository = $pageRepository; |
49
|
2 |
|
$this->deviceTypeRepository = $deviceTypeRepository; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @Route("/%eccube_user_data_route%/{route}", name="user_data", requirements={"route": "([0-9a-zA-Z_\-]+\/?)+(?<!\/)"}) |
54
|
|
|
*/ |
55
|
2 |
|
public function index(Request $request, $route) |
56
|
|
|
{ |
57
|
2 |
|
$DeviceType = $this->deviceTypeRepository |
58
|
2 |
|
->find(DeviceType::DEVICE_TYPE_PC); |
59
|
|
|
|
60
|
2 |
|
$Page = $this->pageRepository->findOneBy( |
61
|
|
|
[ |
62
|
2 |
|
'url' => $route, |
63
|
2 |
|
'DeviceType' => $DeviceType, |
64
|
2 |
|
'edit_type' => Page::EDIT_TYPE_USER, |
65
|
|
|
] |
66
|
|
|
); |
67
|
|
|
|
68
|
2 |
|
if (null === $Page) { |
69
|
1 |
|
throw new NotFoundHttpException(); |
70
|
|
|
} |
71
|
|
|
|
72
|
1 |
|
$file = sprintf('@user_data/%s.twig', $Page->getFileName()); |
73
|
|
|
|
74
|
1 |
|
$event = new EventArgs( |
75
|
|
|
[ |
76
|
1 |
|
'DeviceType' => $DeviceType, |
77
|
1 |
|
'Page' => $Page, |
78
|
1 |
|
'file' => $file, |
79
|
|
|
], |
80
|
1 |
|
$request |
81
|
|
|
); |
82
|
1 |
|
$this->eventDispatcher->dispatch(EccubeEvents::FRONT_USER_DATA_INDEX_INITIALIZE, $event); |
83
|
|
|
|
84
|
1 |
|
return $this->render($file); |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|