public function login(Application $app, Request $request)
{
if (!$app['eccube.service.cart']->isLocked()) {
return $app->redirect($app->url('cart'));
}
if ($app->isGranted('IS_AUTHENTICATED_FULLY')) {
return $app->redirect($app->url('shopping'));
}
/* @var $form \Symfony\Component\Form\FormInterface */
$builder = $app['form.factory']->createNamedBuilder('', 'customer_login');
if ($app->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
$Customer = $app->user();
if ($Customer) {
$builder->get('login_email')->setData($Customer->getEmail());
}
}
$event = new EventArgs(array('builder' => $builder), $request);
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_LOGIN_INITIALIZE, $event);
$form = $builder->getForm();
return $app->render('Shopping/login.twig', array('error' => $app['security.last_error']($request), 'form' => $form->createView()));
}