src/Form/ReCaptchaType/ReCaptchaType.php line 32

Open in your IDE?
  1. <?php
  2. namespace App\Form\ReCaptchaType;
  3. use ReCaptcha\ReCaptcha;
  4. use Symfony\Component\Form\AbstractType;
  5. use Symfony\Component\Form\FormBuilderInterface;
  6. use Symfony\Component\Form\FormInterface;
  7. use Symfony\Component\Form\FormView;
  8. use Symfony\Component\OptionsResolver\OptionsResolver;
  9. class ReCaptchaType extends AbstractType
  10. {
  11.     /**
  12.      * @var ReCaptcha
  13.      */
  14.     private ReCaptcha $reCaptcha;
  15.     /**
  16.      * ReCaptchaType constructor.
  17.      *
  18.      * @param ReCaptcha $reCaptcha
  19.      */
  20.     public function __construct(ReCaptcha $reCaptcha)
  21.     {
  22.         $this->reCaptcha $reCaptcha;
  23.     }
  24.     /**
  25.      * @inheritDoc
  26.      */
  27.     public function buildForm(FormBuilderInterface $builder, array $options)
  28.     {
  29.         $builder->addEventSubscriber(new ReCaptchaValidationListener($this->reCaptcha));
  30.     }
  31.     /**
  32.      * @inheritDoc
  33.      */
  34.     public function buildView(FormView $viewFormInterface $form,   array $options)
  35.     {
  36.         $view->vars['type'] = $options['type'];
  37.     }
  38.     /**
  39.      * @inheritDoc
  40.      */
  41.     public function configureOptions(OptionsResolver $resolver)
  42.     {
  43.         $resolver
  44.             ->setDefault('type''checkbox')
  45.             ->setDefault('mapped'false)
  46.             ->setAllowedValues('type', ['checkbox''invisible']);
  47.     }
  48. }