app/Plugin/Paid4/Form/Type/PaidRepeatedEmailType.php line 19

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