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\Admin\Setting\Shop; |
26
|
|
|
|
27
|
|
|
use Eccube\Application; |
28
|
|
|
use Eccube\Controller\AbstractController; |
29
|
|
|
use Eccube\Event\EccubeEvents; |
30
|
|
|
use Eccube\Event\EventArgs; |
31
|
|
|
use Symfony\Component\HttpFoundation\Request; |
32
|
|
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |
33
|
|
|
|
34
|
|
|
class MailController extends AbstractController |
|
|
|
|
35
|
|
|
{ |
36
|
5 |
|
public function index(Application $app, Request $request, $id = null) |
|
|
|
|
37
|
|
|
{ |
38
|
5 |
|
$Mail = null; |
39
|
|
|
|
40
|
5 |
|
if ($id) { |
41
|
3 |
|
$Mail = $app['orm.em'] |
42
|
3 |
|
->getRepository('\Eccube\Entity\MailTemplate') |
43
|
3 |
|
->find($id); |
44
|
3 |
|
if (is_null($Mail)) { |
45
|
1 |
|
throw new NotFoundHttpException(); |
46
|
|
|
} |
47
|
2 |
|
} |
48
|
|
|
|
49
|
4 |
|
$builder = $app['form.factory'] |
50
|
4 |
|
->createBuilder('mail', $Mail); |
51
|
|
|
|
52
|
4 |
|
$event = new EventArgs( |
53
|
|
|
array( |
54
|
4 |
|
'builder' => $builder, |
55
|
4 |
|
'Mail' => $Mail, |
56
|
4 |
|
), |
57
|
|
|
$request |
58
|
4 |
|
); |
59
|
4 |
|
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_SETTING_SHOP_MAIL_INDEX_INITIALIZE, $event); |
60
|
|
|
|
61
|
4 |
|
$form = $builder->getForm(); |
62
|
|
|
|
63
|
4 |
|
$form['template']->setData($Mail); |
64
|
|
|
|
65
|
4 |
View Code Duplication |
if ('POST' === $request->getMethod()) { |
|
|
|
|
66
|
2 |
|
$form->handleRequest($request); |
67
|
|
|
|
68
|
|
|
// 新規登録は現時点では未実装とする. |
69
|
2 |
|
if (is_null($Mail)) { |
70
|
1 |
|
$app->addError('admin.shop.mail.save.error', 'admin'); |
71
|
|
|
|
72
|
1 |
|
return $app->redirect($app->url('admin_setting_shop_mail')); |
73
|
|
|
} |
74
|
|
|
|
75
|
1 |
|
if ($form->isValid()) { |
|
|
|
|
76
|
|
|
|
77
|
1 |
|
$app['orm.em']->flush(); |
78
|
|
|
|
79
|
1 |
|
$event = new EventArgs( |
80
|
|
|
array( |
81
|
1 |
|
'form' => $form, |
82
|
1 |
|
'Mail' => $Mail, |
83
|
1 |
|
), |
84
|
|
|
$request |
85
|
1 |
|
); |
86
|
1 |
|
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_SETTING_SHOP_MAIL_INDEX_COMPLETE, $event); |
87
|
|
|
|
88
|
1 |
|
$app->addSuccess('admin.shop.mail.save.complete', 'admin'); |
89
|
|
|
|
90
|
1 |
|
return $app->redirect($app->url('admin_setting_shop_mail_edit', array('id' => $id))); |
91
|
|
|
} |
92
|
|
|
} |
93
|
|
|
|
94
|
2 |
|
return $app->render('Setting/Shop/mail.twig', array( |
95
|
2 |
|
'form' => $form->createView(), |
96
|
2 |
|
'id' => $id, |
97
|
2 |
|
)); |
98
|
|
|
} |
99
|
|
|
} |
100
|
|
|
|