|
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\MailService; |
|
22
|
|
|
use Eccube\Util\StringUtil; |
|
23
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; |
|
24
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; |
|
25
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
26
|
|
|
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; |
|
27
|
|
|
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; |
|
28
|
|
|
|
|
29
|
|
|
class WithdrawController extends AbstractController |
|
|
|
|
|
|
30
|
|
|
{ |
|
31
|
|
|
/** |
|
32
|
|
|
* @var MailService |
|
33
|
|
|
*/ |
|
34
|
|
|
protected $mailService; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @var CustomerStatusRepository |
|
38
|
|
|
*/ |
|
39
|
|
|
protected $customerStatusRepository; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @var TokenStorage |
|
43
|
|
|
*/ |
|
44
|
|
|
protected $tokenStorage; |
|
45
|
|
|
|
|
46
|
4 |
|
public function __construct( |
|
47
|
|
|
MailService $mailService, |
|
48
|
|
|
CustomerStatusRepository $customerStatusRepository, |
|
49
|
|
|
TokenStorageInterface $tokenStorage |
|
50
|
|
|
) { |
|
51
|
4 |
|
$this->mailService = $mailService; |
|
52
|
4 |
|
$this->customerStatusRepository = $customerStatusRepository; |
|
53
|
4 |
|
$this->tokenStorage = $tokenStorage; |
|
|
|
|
|
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
|
|
|
|
|
57
|
|
|
* 退会画面. |
|
58
|
|
|
* |
|
59
|
|
|
* @Route("/mypage/withdraw", name="mypage_withdraw") |
|
60
|
|
|
* @Template("Mypage/withdraw.twig") |
|
61
|
|
|
*/ |
|
|
|
|
|
|
62
|
3 |
|
public function index(Request $request) |
|
63
|
|
|
{ |
|
64
|
3 |
|
$builder = $this->formFactory->createBuilder(); |
|
65
|
|
|
|
|
66
|
3 |
|
$event = new EventArgs( |
|
67
|
|
|
[ |
|
68
|
3 |
|
'builder' => $builder, |
|
69
|
|
|
], |
|
70
|
3 |
|
$request |
|
71
|
|
|
); |
|
72
|
3 |
|
$this->eventDispatcher->dispatch(EccubeEvents::FRONT_MYPAGE_WITHDRAW_INDEX_INITIALIZE, $event); |
|
73
|
|
|
|
|
74
|
3 |
|
$form = $builder->getForm(); |
|
75
|
|
|
|
|
76
|
3 |
|
$form->handleRequest($request); |
|
77
|
|
|
|
|
78
|
3 |
|
if ($form->isSubmitted() && $form->isValid()) { |
|
79
|
2 |
|
switch ($request->get('mode')) { |
|
80
|
|
|
case 'confirm': |
|
81
|
1 |
|
log_info('退会確認画面表示'); |
|
82
|
|
|
|
|
83
|
1 |
|
return $this->render( |
|
84
|
1 |
|
'Mypage/withdraw_confirm.twig', |
|
85
|
|
|
[ |
|
86
|
1 |
|
'form' => $form->createView(), |
|
87
|
|
|
] |
|
88
|
|
|
); |
|
89
|
|
|
|
|
90
|
|
|
case 'complete': |
|
91
|
1 |
|
log_info('退会処理開始'); |
|
92
|
|
|
|
|
93
|
|
|
/* @var $Customer \Eccube\Entity\Customer */ |
|
94
|
1 |
|
$Customer = $this->getUser(); |
|
95
|
1 |
|
$email = $Customer->getEmail(); |
|
96
|
|
|
|
|
97
|
|
|
// 退会ステータスに変更 |
|
98
|
1 |
|
$CustomerStatus = $this->customerStatusRepository->find(CustomerStatus::WITHDRAWING); |
|
99
|
1 |
|
$Customer->setStatus($CustomerStatus); |
|
100
|
1 |
|
$Customer->setEmail(StringUtil::random(60).'@dummy.dummy'); |
|
101
|
|
|
|
|
102
|
1 |
|
$this->entityManager->flush(); |
|
103
|
|
|
|
|
104
|
1 |
|
log_info('退会処理完了'); |
|
105
|
|
|
|
|
106
|
1 |
|
$event = new EventArgs( |
|
107
|
|
|
[ |
|
108
|
1 |
|
'form' => $form, |
|
109
|
1 |
|
'Customer' => $Customer, |
|
110
|
1 |
|
], $request |
|
111
|
|
|
); |
|
112
|
1 |
|
$this->eventDispatcher->dispatch(EccubeEvents::FRONT_MYPAGE_WITHDRAW_INDEX_COMPLETE, $event); |
|
113
|
|
|
|
|
114
|
|
|
// メール送信 |
|
115
|
1 |
|
$this->mailService->sendCustomerWithdrawMail($Customer, $email); |
|
116
|
|
|
|
|
117
|
|
|
// ログアウト |
|
118
|
1 |
|
$this->tokenStorage->setToken(null); |
|
119
|
|
|
|
|
120
|
1 |
|
log_info('ログアウト完了'); |
|
121
|
|
|
|
|
122
|
1 |
|
return $this->redirect($this->generateUrl('mypage_withdraw_complete')); |
|
123
|
|
|
} |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
return [ |
|
127
|
1 |
|
'form' => $form->createView(), |
|
128
|
|
|
]; |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
/** |
|
|
|
|
|
|
132
|
|
|
* 退会完了画面. |
|
133
|
|
|
* |
|
134
|
|
|
* @Route("/mypage/withdraw_complete", name="mypage_withdraw_complete") |
|
135
|
|
|
* @Template("Mypage/withdraw_complete.twig") |
|
136
|
|
|
*/ |
|
|
|
|
|
|
137
|
1 |
|
public function complete(Request $request) |
|
|
|
|
|
|
138
|
|
|
{ |
|
139
|
1 |
|
return []; |
|
140
|
|
|
} |
|
141
|
|
|
} |
|
142
|
|
|
|