1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of EC-CUBE |
5
|
|
|
* |
6
|
|
|
* Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved. |
7
|
|
|
* |
8
|
|
|
* http://www.ec-cube.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\Admin\Setting\Shop; |
15
|
|
|
|
16
|
|
|
use Eccube\Controller\AbstractController; |
17
|
|
|
use Eccube\Form\Type\Admin\OrderStatusSettingType; |
18
|
|
|
use Eccube\Repository\Master\OrderStatusColorRepository; |
19
|
|
|
use Eccube\Repository\Master\OrderStatusRepository; |
20
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; |
21
|
|
|
use Symfony\Component\Form\Extension\Core\Type\CollectionType; |
22
|
|
|
use Symfony\Component\HttpFoundation\Request; |
23
|
|
|
use Symfony\Component\Routing\Annotation\Route; |
24
|
|
|
|
25
|
|
|
class OrderStatusController extends AbstractController |
26
|
|
|
{ |
27
|
|
|
/** |
28
|
|
|
* @var OrderStatusRepository |
29
|
|
|
*/ |
30
|
|
|
protected $orderStatusRepository; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @var OrderStatusColorRepository |
34
|
|
|
*/ |
35
|
|
|
protected $orderStatusColorRepository; |
36
|
|
|
|
37
|
|
|
public function __construct( |
38
|
|
|
OrderStatusRepository $orderStatusRepository, |
39
|
|
|
OrderStatusColorRepository $orderStatusColorRepository |
40
|
|
|
) { |
41
|
|
|
$this->orderStatusRepository = $orderStatusRepository; |
42
|
|
|
$this->orderStatusColorRepository = $orderStatusColorRepository; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* 受注ステータス編集画面. |
47
|
|
|
* |
48
|
|
|
* @Route("/%eccube_admin_route%/setting/shop/order_status", name="admin_setting_shop_order_status") |
49
|
|
|
* @Template("@admin/Setting/Shop/order_status.twig") |
50
|
|
|
*/ |
51
|
|
|
public function index(Request $request) |
52
|
|
|
{ |
53
|
|
|
$OrderStatuses = $this->orderStatusRepository->findBy([], ['sort_no' => 'ASC']); |
54
|
|
|
$builder = $this->formFactory->createBuilder(); |
55
|
|
|
$builder |
56
|
|
|
->add( |
57
|
|
|
'OrderStatuses', |
58
|
|
|
CollectionType::class, |
59
|
|
|
[ |
60
|
|
|
'entry_type' => OrderStatusSettingType::class, |
61
|
|
|
'data' => $OrderStatuses, |
62
|
|
|
] |
63
|
|
|
); |
64
|
|
|
$form = $builder->getForm(); |
65
|
|
|
$form->handleRequest($request); |
66
|
|
|
|
67
|
|
|
if ($form->isSubmitted() && $form->isValid()) { |
68
|
|
|
foreach ($form['OrderStatuses'] as $child) { |
69
|
|
|
$OrderStatus = $child->getData(); |
70
|
|
|
$this->entityManager->persist($OrderStatus); |
71
|
|
|
|
72
|
|
|
$OrderStatusColor = $this->orderStatusColorRepository->find($OrderStatus->getId()); |
73
|
|
|
$OrderStatusColor->setName($child['color']->getData()); |
74
|
|
|
$this->entityManager->persist($OrderStatusColor); |
|
|
|
|
75
|
|
|
} |
76
|
|
|
$this->entityManager->flush(); |
77
|
|
|
|
78
|
|
|
$this->addSuccess('admin.common.save_complete', 'admin'); |
79
|
|
|
|
80
|
|
|
return $this->redirectToRoute('admin_setting_shop_order_status'); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
return [ |
84
|
|
|
'form' => $form->createView(), |
85
|
|
|
]; |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.