src/Eccube/Form/Type/Admin/LoginType.php line 57

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\Admin;
  13. use Eccube\Common\EccubeConfig;
  14. use Symfony\Component\Form\AbstractType;
  15. use Symfony\Component\Form\Extension\Core\Type\PasswordType;
  16. use Symfony\Component\Form\Extension\Core\Type\TextType;
  17. use Symfony\Component\Form\FormBuilderInterface;
  18. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  19. use Symfony\Component\OptionsResolver\OptionsResolver;
  20. use Symfony\Component\Validator\Constraints as Assert;
  21. class LoginType extends AbstractType
  22. {
  23.     /**
  24.      * @var EccubeConfig
  25.      */
  26.     protected $eccubeConfig;
  27.     /**
  28.      * @var SessionInterface
  29.      */
  30.     protected $session;
  31.     public function __construct(
  32.         EccubeConfig $eccubeConfig,
  33.         SessionInterface $session
  34.     ) {
  35.         $this->eccubeConfig $eccubeConfig;
  36.         $this->session $session;
  37.     }
  38.     /**
  39.      * {@inheritdoc}
  40.      */
  41.     public function buildForm(FormBuilderInterface $builder, array $options)
  42.     {
  43.         $builder->add('login_id'TextType::class, [
  44.             'attr' => [
  45.                 'maxlength' => $this->eccubeConfig['eccube_id_max_len'],
  46.             ],
  47.             'constraints' => [
  48.                 new Assert\NotBlank(),
  49.             ],
  50.             'data' => $this->session->get('_security.last_username'),
  51.         ]);
  52.         $builder->add('password'PasswordType::class, [
  53.             'attr' => [
  54.                 'maxlength' => $this->eccubeConfig['eccube_password_max_len'],
  55.             ],
  56.             'constraints' => [
  57.                 new Assert\NotBlank(),
  58.             ],
  59.         ]);
  60.     }
  61.     /**
  62.      * {@inheritdoc}
  63.      */
  64.     public function configureOptions(OptionsResolver $resolver)
  65.     {
  66.         $resolver->setDefaults([
  67.             'csrf_protection' => false,
  68.         ]);
  69.     }
  70.     /**
  71.      * {@inheritdoc}
  72.      */
  73.     public function getBlockPrefix()
  74.     {
  75.         return 'admin_login';
  76.     }
  77. }