|
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\Customer; |
|
17
|
|
|
use Eccube\Event\EccubeEvents; |
|
18
|
|
|
use Eccube\Event\EventArgs; |
|
19
|
|
|
use Eccube\Form\Type\Front\ContactType; |
|
20
|
|
|
use Eccube\Service\MailService; |
|
21
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; |
|
22
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; |
|
23
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
24
|
|
|
|
|
25
|
|
|
class ContactController extends AbstractController |
|
|
|
|
|
|
26
|
|
|
{ |
|
27
|
|
|
/** |
|
28
|
|
|
* @var MailService |
|
29
|
|
|
*/ |
|
30
|
|
|
protected $mailService; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* ContactController constructor. |
|
34
|
|
|
* |
|
35
|
|
|
* @param MailService $mailService |
|
36
|
|
|
*/ |
|
37
|
5 |
|
public function __construct( |
|
38
|
|
|
MailService $mailService) |
|
|
|
|
|
|
39
|
|
|
{ |
|
|
|
|
|
|
40
|
5 |
|
$this->mailService = $mailService; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
|
|
|
|
|
44
|
|
|
* お問い合わせ画面. |
|
45
|
|
|
* |
|
46
|
|
|
* @Route("/contact", name="contact") |
|
47
|
|
|
* @Template("Contact/index.twig") |
|
48
|
|
|
*/ |
|
|
|
|
|
|
49
|
4 |
|
public function index(Request $request) |
|
50
|
|
|
{ |
|
51
|
4 |
|
$builder = $this->formFactory->createBuilder(ContactType::class); |
|
52
|
|
|
|
|
53
|
4 |
|
if ($this->isGranted('ROLE_USER')) { |
|
54
|
|
|
/** @var Customer $user */ |
|
55
|
1 |
|
$user = $this->getUser(); |
|
56
|
1 |
|
$builder->setData( |
|
57
|
|
|
[ |
|
58
|
1 |
|
'name01' => $user->getName01(), |
|
59
|
1 |
|
'name02' => $user->getName02(), |
|
60
|
1 |
|
'kana01' => $user->getKana01(), |
|
61
|
1 |
|
'kana02' => $user->getKana02(), |
|
62
|
1 |
|
'postal_code' => $user->getPostalCode(), |
|
63
|
1 |
|
'pref' => $user->getPref(), |
|
64
|
1 |
|
'addr01' => $user->getAddr01(), |
|
65
|
1 |
|
'addr02' => $user->getAddr02(), |
|
66
|
1 |
|
'phone_number' => $user->getPhoneNumber(), |
|
67
|
1 |
|
'email' => $user->getEmail(), |
|
68
|
|
|
] |
|
69
|
|
|
); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
// FRONT_CONTACT_INDEX_INITIALIZE |
|
73
|
4 |
|
$event = new EventArgs( |
|
74
|
|
|
[ |
|
75
|
4 |
|
'builder' => $builder, |
|
76
|
|
|
], |
|
77
|
4 |
|
$request |
|
78
|
|
|
); |
|
79
|
4 |
|
$this->eventDispatcher->dispatch(EccubeEvents::FRONT_CONTACT_INDEX_INITIALIZE, $event); |
|
80
|
|
|
|
|
81
|
4 |
|
$form = $builder->getForm(); |
|
82
|
4 |
|
$form->handleRequest($request); |
|
83
|
|
|
|
|
84
|
4 |
|
if ($form->isSubmitted() && $form->isValid()) { |
|
85
|
3 |
|
switch ($request->get('mode')) { |
|
86
|
|
|
case 'confirm': |
|
87
|
|
|
$builder->setAttribute('freeze', true); |
|
88
|
|
|
$form = $builder->getForm(); |
|
89
|
|
|
$form->handleRequest($request); |
|
90
|
|
|
|
|
91
|
|
|
return $this->render('Contact/confirm.twig', [ |
|
92
|
|
|
'form' => $form->createView(), |
|
93
|
|
|
]); |
|
94
|
|
|
|
|
95
|
|
|
case 'complete': |
|
|
|
|
|
|
96
|
|
|
|
|
97
|
3 |
|
$data = $form->getData(); |
|
98
|
|
|
|
|
99
|
3 |
|
$event = new EventArgs( |
|
100
|
|
|
[ |
|
101
|
3 |
|
'form' => $form, |
|
102
|
3 |
|
'data' => $data, |
|
103
|
|
|
], |
|
104
|
3 |
|
$request |
|
105
|
|
|
); |
|
106
|
3 |
|
$this->eventDispatcher->dispatch(EccubeEvents::FRONT_CONTACT_INDEX_COMPLETE, $event); |
|
107
|
|
|
|
|
108
|
3 |
|
$data = $event->getArgument('data'); |
|
109
|
|
|
|
|
110
|
|
|
// メール送信 |
|
111
|
3 |
|
$this->mailService->sendContactMail($data); |
|
112
|
|
|
|
|
113
|
3 |
|
return $this->redirect($this->generateUrl('contact_complete')); |
|
114
|
|
|
} |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
return [ |
|
118
|
1 |
|
'form' => $form->createView(), |
|
119
|
|
|
]; |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
/** |
|
123
|
|
|
* お問い合わせ完了画面. |
|
124
|
|
|
* |
|
125
|
|
|
* @Route("/contact/complete", name="contact_complete") |
|
126
|
|
|
* @Template("Contact/complete.twig") |
|
127
|
|
|
*/ |
|
|
|
|
|
|
128
|
1 |
|
public function complete() |
|
129
|
|
|
{ |
|
130
|
1 |
|
return []; |
|
131
|
|
|
} |
|
132
|
|
|
} |
|
133
|
|
|
|