src/Eccube/Form/Type/RepeatedPasswordType.php line 26

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 Symfony\Component\Form\AbstractType;
  15. use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
  16. use Symfony\Component\Form\Extension\Core\Type\TextType;
  17. use Symfony\Component\OptionsResolver\OptionsResolver;
  18. use Symfony\Component\Validator\Constraints as Assert;
  19. /**
  20.  * Class RepeatedPasswordType
  21.  */
  22. class RepeatedPasswordType extends AbstractType
  23. {
  24.     /**
  25.      * @var EccubeConfig
  26.      */
  27.     protected $eccubeConfig;
  28.     /**
  29.      * RepeatedPasswordType constructor.
  30.      *
  31.      * @param EccubeConfig $eccubeConfig
  32.      */
  33.     public function __construct(EccubeConfig $eccubeConfig)
  34.     {
  35.         $this->eccubeConfig $eccubeConfig;
  36.     }
  37.     /**
  38.      * {@inheritdoc}
  39.      */
  40.     public function configureOptions(OptionsResolver $resolver)
  41.     {
  42.         $resolver->setDefaults([
  43.             'entry_type' => TextType::class, // type password だと入力欄を空にされてしまうので、widgetで対応
  44.             'invalid_message' => 'form_error.same_password',
  45.             'required' => true,
  46.             'error_bubbling' => false,
  47.             'options' => [
  48.                 'constraints' => [
  49.                     new Assert\NotBlank(),
  50.                     new Assert\Length([
  51.                         'min' => $this->eccubeConfig['eccube_password_min_len'],
  52.                         'max' => $this->eccubeConfig['eccube_password_max_len'],
  53.                     ]),
  54.                     new Assert\Regex([
  55.                         'pattern' => '/^[[:graph:][:space:]]+$/i',
  56.                         'message' => 'form_error.graph_only',
  57.                     ]),
  58.                 ],
  59.             ],
  60.             'first_options' => [
  61.                 'attr' => [
  62.                     'placeholder' => trans('common.password_sample', [
  63.                         '%min%' => $this->eccubeConfig['eccube_password_min_len'],
  64.                         '%max%' => $this->eccubeConfig['eccube_password_max_len'], ]),
  65.                 ],
  66.             ],
  67.             'second_options' => [
  68.                 'attr' => [
  69.                     'placeholder' => 'common.repeated_confirm',
  70.                 ],
  71.             ],
  72.         ]);
  73.     }
  74.     /**
  75.      * {@inheritdoc}
  76.      */
  77.     public function getParent()
  78.     {
  79.         return RepeatedType::class;
  80.     }
  81.     /**
  82.      * {@inheritdoc}
  83.      */
  84.     public function getBlockPrefix()
  85.     {
  86.         return 'repeated_password';
  87.     }
  88. }