app/Customize/Form/Type/RepeatedEmailType.php line 13

Open in your IDE?
  1. <?php
  2. namespace Customize\Form\Type;
  3. use Eccube\Common\EccubeConfig;
  4. use Eccube\Form\Validator\Email;
  5. use Symfony\Component\Form\AbstractType;
  6. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  7. use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
  8. use Symfony\Component\OptionsResolver\Options;
  9. use Symfony\Component\OptionsResolver\OptionsResolver;
  10. use Symfony\Component\Validator\Constraints as Assert;
  11. class RepeatedEmailType extends AbstractType
  12. {
  13.     /**
  14.      * @var EccubeConfig
  15.      */
  16.     protected $eccubeConfig;
  17.     /**
  18.      * ContactType constructor.
  19.      *
  20.      * @param EccubeConfig $eccubeConfig
  21.      */
  22.     public function __construct(EccubeConfig $eccubeConfig)
  23.     {
  24.         $this->eccubeConfig $eccubeConfig;
  25.     }
  26.     /**
  27.      * {@inheritdoc}
  28.      */
  29.     public function configureOptions(OptionsResolver $resolver)
  30.     {
  31.         $resolver->setDefaults([
  32.             'entry_type' => EmailType::class,
  33.             'required' => false,
  34.             'invalid_message' => 'form_error.same_email',
  35.             'options' => [
  36.                 'constraints' => [
  37.                     new Assert\NotBlank(),
  38.                     new Email(nullnull$this->eccubeConfig['eccube_rfc_email_check'] ? 'strict' null),
  39.                     new Assert\Length([
  40.                         'max' => $this->eccubeConfig['eccube_email_len'],
  41.                     ]),
  42.                 ],
  43.             ],
  44.             'first_options' => [
  45.                 'attr' => [
  46.                     'placeholder' => 'common.mail_address_sample',
  47.                 ],
  48.             ],
  49.             'second_options' => [
  50.                 'attr' => [
  51.                     'placeholder' => 'common.repeated_confirm',
  52.                 ],
  53.             ],
  54.             'error_bubbling' => false,
  55.             'trim' => true,
  56.             'error_mapping' => function (Options $options) {
  57.                 return ['.' => $options['second_name']];
  58.             },
  59.         ]);
  60.     }
  61.     /**
  62.      * {@inheritdoc}
  63.      */
  64.     public function getParent()
  65.     {
  66.         return RepeatedType::class;
  67.     }
  68.     /**
  69.      * {@inheritdoc}
  70.      */
  71.     public function getBlockPrefix()
  72.     {
  73.         return 'repeated_email';
  74.     }
  75. }