vendor/kematjaya/user-bundle/src/Form/LoginType.php line 21

Open in your IDE?
  1. <?php
  2. /**
  3.  * This file is part of the user-bundle.
  4.  */
  5. namespace Kematjaya\UserBundle\Form;
  6. use Symfony\Component\Form\AbstractType;
  7. use Symfony\Component\Form\FormBuilderInterface;
  8. use Symfony\Component\Form\Extension\Core\Type\TextType;
  9. use Symfony\Component\Form\Extension\Core\Type\PasswordType;
  10. use Gregwar\CaptchaBundle\Type\CaptchaType;
  11. use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
  12. /**
  13.  * @package Kematjaya\UserBundle\Form
  14.  * @license https://opensource.org/licenses/MIT MIT
  15.  * @author  Nur Hidayatullah <[email protected]>
  16.  */
  17. class LoginType extends AbstractType
  18. {
  19.     const NAME 'kmj_login';
  20.     
  21.     /**
  22.      * 
  23.      * @var array
  24.      */
  25.     private $configs;
  26.     
  27.     public function __construct(ParameterBagInterface $bag
  28.     {
  29.         $this->configs $bag->get('user');
  30.     }
  31.     
  32.     public function buildForm(FormBuilderInterface $builder, array $options)
  33.     {
  34.         $builder
  35.                 ->add('username'TextType::class, [
  36.                     'label' => 'username'
  37.                 ])
  38.                 ->add('password'PasswordType::class, [
  39.                     'label' => 'password'
  40.                 ]);
  41.                 
  42.         if ($this->configs['use_captcha']) {
  43.             $builder->add('captcha'CaptchaType::class, [
  44.                 'label' => 'captcha'
  45.             ]);
  46.         }
  47.     }
  48.     
  49.     /**
  50.      * 
  51.      * @return string
  52.      */
  53.     public function getBlockPrefix() 
  54.     {
  55.         return self::NAME;
  56.     }
  57. }