These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /* |
||
4 | * This file is part of EC-CUBE |
||
5 | * |
||
6 | * Copyright(c) LOCKON CO.,LTD. All Rights Reserved. |
||
7 | * |
||
8 | * http://www.lockon.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\Mypage; |
||
15 | |||
16 | use Eccube\Controller\AbstractController; |
||
17 | use Eccube\Entity\Master\CustomerStatus; |
||
18 | use Eccube\Event\EccubeEvents; |
||
19 | use Eccube\Event\EventArgs; |
||
20 | use Eccube\Repository\Master\CustomerStatusRepository; |
||
21 | use Eccube\Service\CartService; |
||
22 | use Eccube\Service\MailService; |
||
23 | use Eccube\Service\OrderHelper; |
||
24 | use Eccube\Util\StringUtil; |
||
25 | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; |
||
26 | use Symfony\Component\HttpFoundation\Request; |
||
27 | use Symfony\Component\Routing\Annotation\Route; |
||
28 | use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; |
||
29 | use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; |
||
30 | |||
31 | class WithdrawController extends AbstractController |
||
32 | { |
||
33 | /** |
||
34 | * @var MailService |
||
35 | */ |
||
36 | protected $mailService; |
||
37 | |||
38 | /** |
||
39 | * @var CustomerStatusRepository |
||
40 | */ |
||
41 | protected $customerStatusRepository; |
||
42 | |||
43 | /** |
||
44 | * @var TokenStorage |
||
45 | 4 | */ |
|
46 | protected $tokenStorage; |
||
47 | |||
48 | /** |
||
49 | * @var CartService |
||
50 | 4 | */ |
|
51 | 4 | private $cartService; |
|
52 | 4 | ||
53 | /** |
||
54 | * @var OrderHelper |
||
55 | */ |
||
56 | private $orderHelper; |
||
57 | |||
58 | /** |
||
59 | * WithdrawController constructor. |
||
60 | * |
||
61 | 3 | * @param MailService $mailService |
|
62 | * @param CustomerStatusRepository $customerStatusRepository |
||
63 | 3 | * @param TokenStorageInterface $tokenStorage |
|
64 | * @param CartService $cartService |
||
65 | 3 | * @param OrderHelper $orderHelper |
|
66 | */ |
||
67 | 3 | public function __construct( |
|
68 | MailService $mailService, |
||
69 | 3 | CustomerStatusRepository $customerStatusRepository, |
|
70 | TokenStorageInterface $tokenStorage, |
||
71 | 3 | CartService $cartService, |
|
72 | OrderHelper $orderHelper |
||
73 | 3 | ) { |
|
74 | $this->mailService = $mailService; |
||
75 | 3 | $this->customerStatusRepository = $customerStatusRepository; |
|
76 | $this->tokenStorage = $tokenStorage; |
||
0 ignored issues
–
show
|
|||
77 | 3 | $this->cartService = $cartService; |
|
78 | 2 | $this->orderHelper = $orderHelper; |
|
79 | } |
||
80 | 1 | ||
81 | /** |
||
82 | 1 | * 退会画面. |
|
83 | 1 | * |
|
84 | * @Route("/mypage/withdraw", name="mypage_withdraw") |
||
85 | 1 | * @Template("Mypage/withdraw.twig") |
|
86 | */ |
||
87 | public function index(Request $request) |
||
88 | { |
||
89 | $builder = $this->formFactory->createBuilder(); |
||
90 | 1 | ||
91 | $event = new EventArgs( |
||
92 | [ |
||
93 | 1 | 'builder' => $builder, |
|
94 | 1 | ], |
|
95 | $request |
||
96 | ); |
||
97 | 1 | $this->eventDispatcher->dispatch(EccubeEvents::FRONT_MYPAGE_WITHDRAW_INDEX_INITIALIZE, $event); |
|
98 | 1 | ||
99 | $form = $builder->getForm(); |
||
100 | 1 | ||
101 | $form->handleRequest($request); |
||
102 | 1 | ||
103 | if ($form->isSubmitted() && $form->isValid()) { |
||
104 | 1 | switch ($request->get('mode')) { |
|
105 | case 'confirm': |
||
106 | 1 | log_info('退会確認画面表示'); |
|
107 | 1 | ||
108 | 1 | return $this->render( |
|
109 | 'Mypage/withdraw_confirm.twig', |
||
110 | 1 | [ |
|
111 | 'form' => $form->createView(), |
||
112 | ] |
||
113 | 1 | ); |
|
114 | |||
115 | case 'complete': |
||
116 | 1 | log_info('退会処理開始'); |
|
117 | |||
118 | 1 | /* @var $Customer \Eccube\Entity\Customer */ |
|
119 | $Customer = $this->getUser(); |
||
120 | 1 | $email = $Customer->getEmail(); |
|
121 | |||
122 | // 退会ステータスに変更 |
||
123 | $CustomerStatus = $this->customerStatusRepository->find(CustomerStatus::WITHDRAWING); |
||
124 | $Customer->setStatus($CustomerStatus); |
||
125 | 1 | $Customer->setEmail(StringUtil::random(60).'@dummy.dummy'); |
|
126 | |||
127 | $this->entityManager->flush(); |
||
128 | |||
129 | log_info('退会処理完了'); |
||
130 | |||
131 | $event = new EventArgs( |
||
132 | [ |
||
133 | 'form' => $form, |
||
134 | 'Customer' => $Customer, |
||
135 | 1 | ], $request |
|
136 | ); |
||
137 | 1 | $this->eventDispatcher->dispatch(EccubeEvents::FRONT_MYPAGE_WITHDRAW_INDEX_COMPLETE, $event); |
|
138 | |||
139 | // メール送信 |
||
140 | $this->mailService->sendCustomerWithdrawMail($Customer, $email); |
||
141 | |||
142 | // カートと受注のセッションを削除 |
||
143 | $this->cartService->clear(); |
||
144 | $this->orderHelper->removeSession(); |
||
145 | |||
146 | // ログアウト |
||
147 | $this->tokenStorage->setToken(null); |
||
148 | |||
149 | log_info('ログアウト完了'); |
||
150 | |||
151 | return $this->redirect($this->generateUrl('mypage_withdraw_complete')); |
||
152 | } |
||
153 | } |
||
154 | |||
155 | return [ |
||
156 | 'form' => $form->createView(), |
||
157 | ]; |
||
158 | } |
||
159 | |||
160 | /** |
||
161 | * 退会完了画面. |
||
162 | * |
||
163 | * @Route("/mypage/withdraw_complete", name="mypage_withdraw_complete") |
||
164 | * @Template("Mypage/withdraw_complete.twig") |
||
165 | */ |
||
166 | public function complete(Request $request) |
||
0 ignored issues
–
show
|
|||
167 | { |
||
168 | return []; |
||
169 | } |
||
170 | } |
||
171 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.
Either this assignment is in error or an instanceof check should be added for that assignment.