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
|
1 |
|
$title = 'お問い合わせ(確認ページ)'; |
85
|
|
|
|
86
|
1 |
|
return $app->render('Contact/confirm.twig', array( |
87
|
1 |
|
'form' => $form->createView(), |
88
|
1 |
|
'title' => $title, |
89
|
|
|
)); |
90
|
|
|
|
91
|
4 |
|
case 'complete': |
|
|
|
|
92
|
|
|
|
93
|
4 |
|
$data = $form->getData(); |
94
|
|
|
|
95
|
4 |
|
$event = new EventArgs( |
96
|
|
|
array( |
97
|
4 |
|
'form' => $form, |
98
|
4 |
|
'data' => $data, |
99
|
|
|
), |
100
|
|
|
$request |
101
|
|
|
); |
102
|
4 |
|
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_CONTACT_INDEX_COMPLETE, $event); |
103
|
|
|
|
104
|
4 |
|
$data = $event->getArgument('data'); |
105
|
|
|
|
106
|
|
|
// メール送信 |
107
|
4 |
|
$app['eccube.service.mail']->sendContactMail($data); |
108
|
|
|
|
109
|
4 |
|
return $app->redirect($app->url('contact_complete')); |
110
|
|
|
} |
111
|
|
|
} |
112
|
|
|
|
113
|
2 |
|
return $app->render('Contact/index.twig', array( |
114
|
2 |
|
'form' => $form->createView(), |
115
|
|
|
)); |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* お問い合わせ完了画面. |
120
|
|
|
* |
121
|
|
|
* @param Application $app |
122
|
|
|
* @return \Symfony\Component\HttpFoundation\Response |
123
|
|
|
*/ |
124
|
1 |
|
public function complete(Application $app) |
125
|
|
|
{ |
126
|
1 |
|
return $app->render('Contact/complete.twig'); |
127
|
|
|
} |
128
|
|
|
} |
129
|
|
|
|
According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.