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\OptionsResolver;
  19. use Symfony\Component\Validator\Constraints as Assert;
  20. use Symfony\Component\OptionsResolver\Options;
  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(['strict' => $this->eccubeConfig['eccube_rfc_email_check']]),
  49.                 ],
  50.             ],
  51.             'first_options' => [
  52.                 'attr' => [
  53.                     'placeholder' => 'common.mail_address_sample',
  54.                 ],
  55.             ],
  56.             'second_options' => [
  57.                 'attr' => [
  58.                     'placeholder' => 'common.repeated_confirm',
  59.                 ],
  60.             ],
  61.             'error_bubbling' => false,
  62.             'trim' => true,
  63.             'error_mapping' => function (Options $options) {
  64.                 return ['.' => $options['second_name']];
  65.             },
  66.         ]);
  67.     }
  68.     /**
  69.      * {@inheritdoc}
  70.      */
  71.     public function getParent()
  72.     {
  73.         return RepeatedType::class;
  74.     }
  75.     /**
  76.      * {@inheritdoc}
  77.      */
  78.     public function getBlockPrefix()
  79.     {
  80.         return 'repeated_email';
  81.     }
  82. }