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\Order; |
15
|
|
|
|
16
|
|
|
use Eccube\Controller\AbstractController; |
17
|
|
|
use Eccube\Form\Type\Admin\OrderStatusType; |
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 StatusController extends AbstractController |
26
|
|
|
{ |
27
|
|
|
/** |
28
|
|
|
* @var OrderStatusRepository |
29
|
|
|
*/ |
30
|
|
|
protected $orderStatusRepository; |
31
|
|
|
|
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @var OrderStatusColorRepository |
35
|
|
|
*/ |
36
|
|
|
protected $orderStatusColorRepository; |
37
|
|
|
|
38
|
|
|
public function __construct( |
39
|
|
|
OrderStatusRepository $orderStatusRepository, |
40
|
|
|
OrderStatusColorRepository $orderStatusColorRepository |
41
|
|
|
) { |
42
|
|
|
$this->orderStatusRepository = $orderStatusRepository; |
43
|
|
|
$this->orderStatusColorRepository = $orderStatusColorRepository; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* 受注ステータス編集画面. |
48
|
|
|
* |
49
|
|
|
* @Route("/%eccube_admin_route%/order/status", name="admin_order_status") |
50
|
|
|
* @Template("@admin/Order/status.twig") |
51
|
|
|
*/ |
52
|
|
|
public function index(Request $request) |
53
|
|
|
{ |
54
|
|
|
$OrderStatuses = $this->orderStatusRepository->findBy([], ['sort_no' => 'ASC']); |
55
|
|
|
$builder = $this->formFactory->createBuilder(); |
56
|
|
|
$builder |
57
|
|
|
->add( |
58
|
|
|
'OrderStatuses', |
59
|
|
|
CollectionType::class, |
60
|
|
|
[ |
61
|
|
|
'entry_type' => OrderStatusType::class, |
62
|
|
|
'data' => $OrderStatuses, |
63
|
|
|
] |
64
|
|
|
); |
65
|
|
|
$form = $builder->getForm(); |
66
|
|
|
$form->handleRequest($request); |
67
|
|
|
|
68
|
|
|
if ($form->isSubmitted() && $form->isValid()) { |
69
|
|
|
foreach ($form['OrderStatuses'] as $child) { |
70
|
|
|
$OrderStatus = $child->getData(); |
71
|
|
|
$this->entityManager->persist($OrderStatus); |
72
|
|
|
|
73
|
|
|
$OrderStatusColor = $this->orderStatusColorRepository->find($OrderStatus->getId()); |
74
|
|
|
$OrderStatusColor->setName($child['color']->getData()); |
75
|
|
|
$this->entityManager->persist($OrderStatusColor); |
|
|
|
|
76
|
|
|
} |
77
|
|
|
$this->entityManager->flush(); |
78
|
|
|
|
79
|
|
|
$this->addSuccess('admin.common.save_complete', 'admin'); |
80
|
|
|
|
81
|
|
|
return $this->redirectToRoute('admin_order_status'); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
return [ |
85
|
|
|
'form' => $form->createView(), |
86
|
|
|
]; |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|
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.