|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* This file is part of EC-CUBE |
|
4
|
|
|
* |
|
5
|
|
|
* Copyright(c) 2000-2015 LOCKON CO.,LTD. All Rights Reserved. |
|
6
|
|
|
* |
|
7
|
|
|
* http://www.lockon.co.jp/ |
|
8
|
|
|
* |
|
9
|
|
|
* This program is free software; you can redistribute it and/or |
|
10
|
|
|
* modify it under the terms of the GNU General Public License |
|
11
|
|
|
* as published by the Free Software Foundation; either version 2 |
|
12
|
|
|
* of the License, or (at your option) any later version. |
|
13
|
|
|
* |
|
14
|
|
|
* This program is distributed in the hope that it will be useful, |
|
15
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
16
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
17
|
|
|
* GNU General Public License for more details. |
|
18
|
|
|
* |
|
19
|
|
|
* You should have received a copy of the GNU General Public License |
|
20
|
|
|
* along with this program; if not, write to the Free Software |
|
21
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
22
|
|
|
*/ |
|
23
|
|
|
|
|
24
|
|
|
|
|
25
|
|
|
namespace Eccube\Controller; |
|
26
|
|
|
|
|
27
|
|
|
use Eccube\Application; |
|
28
|
|
|
use Eccube\Event\EccubeEvents; |
|
29
|
|
|
use Eccube\Event\EventArgs; |
|
30
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
31
|
|
|
|
|
32
|
|
|
class ContactController |
|
|
|
|
|
|
33
|
|
|
{ |
|
34
|
|
|
/** |
|
35
|
|
|
* お問い合わせ画面. |
|
36
|
|
|
* |
|
37
|
|
|
* @param Application $app |
|
38
|
|
|
* @param Request $request |
|
|
|
|
|
|
39
|
|
|
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response |
|
40
|
|
|
*/ |
|
41
|
7 |
|
public function index(Application $app, Request $request) |
|
42
|
|
|
{ |
|
43
|
7 |
|
$builder = $app['form.factory']->createBuilder('contact'); |
|
44
|
|
|
|
|
45
|
7 |
|
if ($app->isGranted('ROLE_USER')) { |
|
46
|
|
|
$user = $app['user']; |
|
47
|
|
|
$builder->setData( |
|
48
|
|
|
array( |
|
49
|
|
|
'name01' => $user->getName01(), |
|
50
|
|
|
'name02' => $user->getName02(), |
|
51
|
|
|
'kana01' => $user->getKana01(), |
|
52
|
|
|
'kana02' => $user->getKana02(), |
|
53
|
|
|
'zip01' => $user->getZip01(), |
|
54
|
|
|
'zip02' => $user->getZip02(), |
|
55
|
|
|
'pref' => $user->getPref(), |
|
56
|
|
|
'addr01' => $user->getAddr01(), |
|
57
|
|
|
'addr02' => $user->getAddr02(), |
|
58
|
|
|
'tel01' => $user->getTel01(), |
|
59
|
|
|
'tel02' => $user->getTel02(), |
|
60
|
|
|
'tel03' => $user->getTel03(), |
|
61
|
|
|
'email' => $user->getEmail(), |
|
62
|
|
|
) |
|
63
|
|
|
); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
// FRONT_CONTACT_INDEX_INITIALIZE |
|
67
|
7 |
|
$event = new EventArgs( |
|
68
|
|
|
array( |
|
69
|
7 |
|
'builder' => $builder, |
|
70
|
|
|
), |
|
71
|
|
|
$request |
|
72
|
|
|
); |
|
73
|
7 |
|
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_CONTACT_INDEX_INITIALIZE, $event); |
|
74
|
|
|
|
|
75
|
7 |
|
$form = $builder->getForm(); |
|
76
|
7 |
|
$form->handleRequest($request); |
|
77
|
|
|
|
|
78
|
7 |
|
if ($form->isSubmitted() && $form->isValid()) { |
|
79
|
5 |
|
switch ($request->get('mode')) { |
|
80
|
5 |
|
case 'confirm': |
|
81
|
1 |
|
$builder->setAttribute('freeze', true); |
|
82
|
1 |
|
$form = $builder->getForm(); |
|
83
|
1 |
|
$form->handleRequest($request); |
|
84
|
|
|
|
|
85
|
1 |
|
return $app->render('Contact/confirm.twig', array( |
|
86
|
1 |
|
'form' => $form->createView(), |
|
87
|
|
|
)); |
|
88
|
|
|
|
|
89
|
4 |
|
case 'complete': |
|
|
|
|
|
|
90
|
|
|
|
|
91
|
4 |
|
$data = $form->getData(); |
|
92
|
|
|
|
|
93
|
4 |
|
$event = new EventArgs( |
|
94
|
|
|
array( |
|
95
|
4 |
|
'form' => $form, |
|
96
|
4 |
|
'data' => $data, |
|
97
|
|
|
), |
|
98
|
|
|
$request |
|
99
|
|
|
); |
|
100
|
4 |
|
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_CONTACT_INDEX_COMPLETE, $event); |
|
101
|
|
|
|
|
102
|
4 |
|
$data = $event->getArgument('data'); |
|
103
|
|
|
|
|
104
|
|
|
// メール送信 |
|
105
|
4 |
|
$app['eccube.service.mail']->sendContactMail($data); |
|
106
|
|
|
|
|
107
|
4 |
|
return $app->redirect($app->url('contact_complete')); |
|
108
|
|
|
} |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
2 |
|
return $app->render('Contact/index.twig', array( |
|
112
|
2 |
|
'form' => $form->createView(), |
|
113
|
|
|
)); |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* お問い合わせ完了画面. |
|
118
|
|
|
* |
|
119
|
|
|
* @param Application $app |
|
120
|
|
|
* @return \Symfony\Component\HttpFoundation\Response |
|
121
|
|
|
*/ |
|
122
|
1 |
|
public function complete(Application $app) |
|
123
|
|
|
{ |
|
124
|
1 |
|
return $app->render('Contact/complete.twig'); |
|
125
|
|
|
} |
|
126
|
|
|
} |
|
127
|
|
|
|