src/Eccube/Form/Type/Front/CustomerLoginType.php line 47

Open in your IDE?
  1. <?php
  2. /*
  3. * This file is part of EC-CUBE
  4. *
  5. * Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
  6. *
  7. * http://www.ec-cube.co.jp/
  8. *
  9. * For the full copyright and license information, please view the LICENSE
  10. * file that was distributed with this source code.
  11. */
  12. namespace Eccube\Form\Type\Front;
  13. use Eccube\Common\EccubeConfig;
  14. use Eccube\Form\Validator\Email;
  15. use Symfony\Component\Form\AbstractType;
  16. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  17. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  18. use Symfony\Component\Form\Extension\Core\Type\PasswordType;
  19. use Symfony\Component\Form\FormBuilderInterface;
  20. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  21. use Symfony\Component\Validator\Constraints as Assert;
  22. class CustomerLoginType extends AbstractType
  23. {
  24. /**
  25. * @var EccubeConfig
  26. */
  27. protected $eccubeConfig;
  28. /**
  29. * @var AuthenticationUtils
  30. */
  31. protected $authenticationUtils;
  32. public function __construct(AuthenticationUtils $authenticationUtils, EccubeConfig $eccubeConfig)
  33. {
  34. $this->authenticationUtils = $authenticationUtils;
  35. $this->eccubeConfig = $eccubeConfig;
  36. }
  37. /**
  38. * {@inheritdoc}
  39. */
  40. public function buildForm(FormBuilderInterface $builder, array $options)
  41. {
  42. $builder->add('login_email', EmailType::class, [
  43. 'attr' => [
  44. 'maxlength' => $this->eccubeConfig['eccube_stext_len'],
  45. ],
  46. 'constraints' => [
  47. new Assert\NotBlank(),
  48. new Email(null, null, $this->eccubeConfig['eccube_rfc_email_check'] ? 'strict' : null),
  49. ],
  50. 'data' => $this->authenticationUtils->getLastUsername(),
  51. ]);
  52. $builder->add('login_memory', CheckboxType::class, [
  53. 'required' => false,
  54. ]);
  55. $builder->add('login_pass', PasswordType::class, [
  56. 'attr' => [
  57. 'maxlength' => $this->eccubeConfig['eccube_stext_len'],
  58. ],
  59. 'constraints' => [
  60. new Assert\NotBlank(),
  61. ],
  62. ]);
  63. }
  64. /**
  65. * {@inheritdoc}
  66. */
  67. public function getBlockPrefix()
  68. {
  69. return 'customer_login';
  70. }
  71. }