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

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