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\Product; |
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
|
3 |
|
class ClassNameController extends AbstractController |
|
|
|
|
35
|
|
|
{ |
36
|
3 |
|
public function index(Application $app, Request $request, $id = null) |
|
|
|
|
37
|
|
|
{ |
38
|
1 |
|
if ($id) { |
39
|
|
|
$TargetClassName = $app['eccube.repository.class_name']->find($id); |
40
|
|
|
if (!$TargetClassName) { |
41
|
|
|
throw new NotFoundHttpException(); |
42
|
|
|
} |
43
|
1 |
|
} else { |
44
|
|
|
$TargetClassName = new \Eccube\Entity\ClassName(); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
$builder = $app['form.factory'] |
48
|
|
|
->createBuilder('admin_class_name', $TargetClassName); |
49
|
|
|
|
50
|
|
|
$event = new EventArgs( |
51
|
|
|
array( |
52
|
|
|
'builder' => $builder, |
53
|
|
|
'TargetClassName' => $TargetClassName, |
54
|
1 |
|
), |
55
|
|
|
$request |
56
|
|
|
); |
57
|
|
|
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_PRODUCT_CLASS_NAME_INDEX_INITIALIZE, $event); |
58
|
|
|
|
59
|
|
|
$form = $builder->getForm(); |
60
|
|
|
|
61
|
|
View Code Duplication |
if ($request->getMethod() === 'POST') { |
|
|
|
|
62
|
|
|
$form->handleRequest($request); |
63
|
|
|
if ($form->isValid()) { |
64
|
|
|
$status = $app['eccube.repository.class_name']->save($TargetClassName); |
65
|
|
|
|
66
|
2 |
|
if ($status) { |
67
|
2 |
|
|
68
|
|
|
$event = new EventArgs( |
69
|
|
|
array( |
70
|
|
|
'form' => $form, |
71
|
3 |
|
'TargetClassName' => $TargetClassName, |
72
|
|
|
), |
73
|
1 |
|
$request |
74
|
|
|
); |
75
|
|
|
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_PRODUCT_CLASS_NAME_INDEX_COMPLETE, $event); |
76
|
|
|
|
77
|
|
|
$app->addSuccess('admin.class_name.save.complete', 'admin'); |
78
|
1 |
|
|
79
|
|
|
return $app->redirect($app->url('admin_product_class_name')); |
80
|
|
|
} else { |
81
|
|
|
$app->addError('admin.class_name.save.error', 'admin'); |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
} |
85
|
1 |
|
|
86
|
|
|
$ClassNames = $app['eccube.repository.class_name']->getList(); |
87
|
|
|
|
88
|
|
|
return $app->render('Product/class_name.twig', array( |
89
|
1 |
|
'form' => $form->createView(), |
90
|
|
|
'ClassNames' => $ClassNames, |
91
|
|
|
'TargetClassName' => $TargetClassName, |
92
|
1 |
|
)); |
93
|
|
|
} |
94
|
1 |
|
|
95
|
|
|
public function delete(Application $app, Request $request, $id) |
|
|
|
|
96
|
|
|
{ |
97
|
|
|
$this->isTokenValid($app); |
98
|
|
|
|
99
|
|
|
$TargetClassName = $app['eccube.repository.class_name']->find($id); |
100
|
|
|
if (!$TargetClassName) { |
101
|
|
|
$app->deleteMessage(); |
102
|
|
|
return $app->redirect($app->url('admin_product_class_name')); |
|
|
|
|
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
$status = $app['eccube.repository.class_name']->delete($TargetClassName); |
106
|
1 |
|
|
107
|
1 |
|
if ($status === true) { |
108
|
|
|
|
109
|
|
|
$event = new EventArgs( |
110
|
|
|
array( |
111
|
|
|
'TargetClassName' => $TargetClassName, |
112
|
|
|
), |
113
|
|
|
$request |
114
|
|
|
); |
115
|
|
|
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_PRODUCT_CLASS_NAME_DELETE_COMPLETE, $event); |
116
|
|
|
|
117
|
|
|
$app->addSuccess('admin.class_name.delete.complete', 'admin'); |
118
|
|
|
} else { |
119
|
|
|
$app->addError('admin.class_name.delete.error', 'admin'); |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
return $app->redirect($app->url('admin_product_class_name')); |
123
|
|
|
} |
124
|
|
|
|
125
|
|
View Code Duplication |
public function moveRank(Application $app, Request $request) |
|
|
|
|
126
|
|
|
{ |
127
|
|
|
if ($request->isXmlHttpRequest()) { |
128
|
|
|
$ranks = $request->request->all(); |
129
|
|
|
foreach ($ranks as $classNameId => $rank) { |
130
|
|
|
$ClassName = $app['eccube.repository.class_name'] |
131
|
|
|
->find($classNameId); |
132
|
|
|
$ClassName->setRank($rank); |
133
|
|
|
$app['orm.em']->persist($ClassName); |
134
|
|
|
} |
135
|
|
|
$app['orm.em']->flush(); |
136
|
|
|
} |
137
|
|
|
return true; |
|
|
|
|
138
|
|
|
} |
139
|
|
|
} |
140
|
|
|
|