1 | <?php |
||
36 | class EntryController extends AbstractController |
||
|
|||
37 | { |
||
38 | |||
39 | /** |
||
40 | * 会員登録画面. |
||
41 | * |
||
42 | * @param Application $app |
||
43 | * @param Request $request |
||
44 | * @return \Symfony\Component\HttpFoundation\Response |
||
45 | */ |
||
46 | 8 | public function index(Application $app, Request $request) |
|
47 | { |
||
48 | 8 | if ($app->isGranted('ROLE_USER')) { |
|
49 | log_info('認証済のためログイン処理をスキップ'); |
||
50 | |||
51 | return $app->redirect($app->url('mypage')); |
||
52 | } |
||
53 | |||
54 | /** @var $Customer \Eccube\Entity\Customer */ |
||
55 | 8 | $Customer = $app['eccube.repository.customer']->newCustomer(); |
|
56 | |||
57 | /* @var $builder \Symfony\Component\Form\FormBuilderInterface */ |
||
58 | 8 | $builder = $app['form.factory']->createBuilder('entry', $Customer); |
|
59 | |||
60 | 8 | $event = new EventArgs( |
|
61 | array( |
||
62 | 8 | 'builder' => $builder, |
|
63 | 8 | 'Customer' => $Customer, |
|
64 | ), |
||
65 | $request |
||
66 | ); |
||
67 | 8 | $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_ENTRY_INDEX_INITIALIZE, $event); |
|
68 | |||
69 | /* @var $form \Symfony\Component\Form\FormInterface */ |
||
70 | 8 | $form = $builder->getForm(); |
|
71 | |||
72 | 8 | $form->handleRequest($request); |
|
73 | |||
74 | 8 | if ($form->isSubmitted() && $form->isValid()) { |
|
75 | 5 | switch ($request->get('mode')) { |
|
76 | 5 | case 'confirm': |
|
77 | 2 | log_info('会員登録確認開始'); |
|
78 | 2 | $builder->setAttribute('freeze', true); |
|
79 | 2 | $form = $builder->getForm(); |
|
80 | 2 | $form->handleRequest($request); |
|
81 | 2 | log_info('会員登録確認完了'); |
|
82 | |||
83 | 2 | return $app->render('Entry/confirm.twig', array( |
|
84 | 2 | 'form' => $form->createView(), |
|
85 | )); |
||
86 | |||
87 | 3 | case 'complete': |
|
88 | 2 | log_info('会員登録開始'); |
|
89 | $Customer |
||
90 | 2 | ->setSalt( |
|
91 | 2 | $app['eccube.repository.customer']->createSalt(5) |
|
92 | ) |
||
93 | 2 | ->setPassword( |
|
94 | 2 | $app['eccube.repository.customer']->encryptPassword($app, $Customer) |
|
95 | ) |
||
96 | 2 | ->setSecretKey( |
|
97 | 2 | $app['eccube.repository.customer']->getUniqueSecretKey($app) |
|
98 | ); |
||
99 | |||
100 | 2 | $CustomerAddress = new \Eccube\Entity\CustomerAddress(); |
|
101 | $CustomerAddress |
||
102 | 2 | ->setFromCustomer($Customer); |
|
103 | |||
104 | 2 | $app['orm.em']->persist($Customer); |
|
105 | 2 | $app['orm.em']->persist($CustomerAddress); |
|
106 | 2 | $app['orm.em']->flush(); |
|
107 | |||
108 | 2 | log_info('会員登録完了'); |
|
109 | |||
110 | 2 | $event = new EventArgs( |
|
111 | array( |
||
112 | 2 | 'form' => $form, |
|
113 | 2 | 'Customer' => $Customer, |
|
114 | 2 | 'CustomerAddress' => $CustomerAddress, |
|
115 | ), |
||
116 | $request |
||
117 | ); |
||
118 | 2 | $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_ENTRY_INDEX_COMPLETE, $event); |
|
119 | |||
120 | 2 | $activateUrl = $app->url('entry_activate', array('secret_key' => $Customer->getSecretKey())); |
|
121 | |||
122 | /** @var $BaseInfo \Eccube\Entity\BaseInfo */ |
||
123 | 2 | $BaseInfo = $app['eccube.repository.base_info']->get(); |
|
124 | 2 | $activateFlg = $BaseInfo->getOptionCustomerActivate(); |
|
125 | |||
126 | // 仮会員設定が有効な場合は、確認メールを送信し完了画面表示. |
||
127 | 2 | if ($activateFlg) { |
|
128 | // メール送信 |
||
129 | 2 | $app['eccube.service.mail']->sendCustomerConfirmMail($Customer, $activateUrl); |
|
130 | |||
131 | 2 | if ($event->hasResponse()) { |
|
132 | return $event->getResponse(); |
||
133 | } |
||
134 | |||
135 | 2 | log_info('仮会員登録完了画面へリダイレクト'); |
|
136 | |||
137 | 2 | return $app->redirect($app->url('entry_complete')); |
|
138 | // 仮会員設定が無効な場合は認証URLへ遷移させ、会員登録を完了させる. |
||
139 | } else { |
||
140 | log_info('本会員登録画面へリダイレクト'); |
||
141 | |||
142 | 1 | return $app->redirect($activateUrl); |
|
143 | } |
||
144 | } |
||
145 | } |
||
146 | |||
147 | 4 | return $app->render('Entry/index.twig', array( |
|
148 | 4 | 'form' => $form->createView(), |
|
149 | )); |
||
150 | } |
||
151 | |||
152 | /** |
||
153 | * 会員登録完了画面. |
||
154 | * |
||
155 | * @param Application $app |
||
156 | * @return \Symfony\Component\HttpFoundation\Response |
||
157 | */ |
||
158 | 1 | public function complete(Application $app) |
|
162 | |||
163 | /** |
||
164 | * 会員のアクティベート(本会員化)を行う. |
||
165 | * |
||
166 | * @param Application $app |
||
167 | * @param Request $request |
||
168 | * @param $secret_key |
||
169 | * @return \Symfony\Component\HttpFoundation\Response |
||
170 | */ |
||
171 | 4 | public function activate(Application $app, Request $request, $secret_key) |
|
219 | } |
||
220 |