Eccube\Controller\Mypage\WithdrawController::index PHP Method

index() public method

退会画面.
public index ( Application $app, Request $request ) : RedirectResponse | Response
$app Eccube\Application
$request Symfony\Component\HttpFoundation\Request
return Symfony\Component\HttpFoundation\RedirectResponse | Symfony\Component\HttpFoundation\Response
    public function index(Application $app, Request $request)
    {
        $builder = $app->form();
        $event = new EventArgs(array('builder' => $builder), $request);
        $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_MYPAGE_WITHDRAW_INDEX_INITIALIZE, $event);
        $form = $builder->getForm();
        $form->handleRequest($request);
        if ($form->isSubmitted() && $form->isValid()) {
            switch ($request->get('mode')) {
                case 'confirm':
                    log_info('退会確認画面表示');
                    return $app->render('Mypage/withdraw_confirm.twig', array('form' => $form->createView()));
                case 'complete':
                    log_info('退会処理開始');
                    /* @var $Customer \Eccube\Entity\Customer */
                    $Customer = $app->user();
                    // 会員削除
                    $email = $Customer->getEmail();
                    // メールアドレスにダミーをセット
                    $Customer->setEmail(Str::random(60) . '@dummy.dummy');
                    $Customer->setDelFlg(Constant::ENABLED);
                    $app['orm.em']->flush();
                    log_info('退会処理完了');
                    $event = new EventArgs(array('form' => $form, 'Customer' => $Customer), $request);
                    $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_MYPAGE_WITHDRAW_INDEX_COMPLETE, $event);
                    // メール送信
                    $app['eccube.service.mail']->sendCustomerWithdrawMail($Customer, $email);
                    // ログアウト
                    $this->getSecurity($app)->setToken(null);
                    log_info('ログアウト完了');
                    return $app->redirect($app->url('mypage_withdraw_complete'));
            }
        }
        return $app->render('Mypage/withdraw.twig', array('form' => $form->createView()));
    }
WithdrawController