src/Eccube/Form/Type/RepeatedEmailType.php line 25

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;
  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\EmailType;
  17. use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
  18. use Symfony\Component\OptionsResolver\Options;
  19. use Symfony\Component\OptionsResolver\OptionsResolver;
  20. use Symfony\Component\Validator\Constraints as Assert;
  21. class RepeatedEmailType extends AbstractType
  22. {
  23.     /**
  24.      * @var EccubeConfig
  25.      */
  26.     protected $eccubeConfig;
  27.     /**
  28.      * ContactType constructor.
  29.      *
  30.      * @param EccubeConfig $eccubeConfig
  31.      */
  32.     public function __construct(EccubeConfig $eccubeConfig)
  33.     {
  34.         $this->eccubeConfig $eccubeConfig;
  35.     }
  36.     /**
  37.      * {@inheritdoc}
  38.      */
  39.     public function configureOptions(OptionsResolver $resolver)
  40.     {
  41.         $resolver->setDefaults([
  42.             'entry_type' => EmailType::class,
  43.             'required' => true,
  44.             'invalid_message' => 'form_error.same_email',
  45.             'options' => [
  46.                 'constraints' => [
  47.                     new Assert\NotBlank(),
  48.                     new Email(nullnull$this->eccubeConfig['eccube_rfc_email_check'] ? 'strict' null),
  49.                     new Assert\Length([
  50.                         'max' => $this->eccubeConfig['eccube_email_len'],
  51.                     ]),
  52.                 ],
  53.             ],
  54.             'first_options' => [
  55.                 'attr' => [
  56.                     'placeholder' => 'common.mail_address_sample',
  57.                 ],
  58.             ],
  59.             'second_options' => [
  60.                 'attr' => [
  61.                     'placeholder' => 'common.repeated_confirm',
  62.                 ],
  63.             ],
  64.             'error_bubbling' => false,
  65.             'trim' => true,
  66.             'error_mapping' => function (Options $options) {
  67.                 return ['.' => $options['second_name']];
  68.             },
  69.         ]);
  70.     }
  71.     /**
  72.      * {@inheritdoc}
  73.      */
  74.     public function getParent()
  75.     {
  76.         return RepeatedType::class;
  77.     }
  78.     /**
  79.      * {@inheritdoc}
  80.      */
  81.     public function getBlockPrefix()
  82.     {
  83.         return 'repeated_email';
  84.     }
  85. }