lib/composer/LisaBundle/src/VisualMedia/LisaBundle/Form/Type/GoogleRecaptchaType.php line 21

Open in your IDE?
  1. <?php
  2. /**
  3.  * GoogleRecaptchaType
  4.  *
  5.  * @author Bertin van den Ham <b.vandenham@visualmedia.nl>
  6.  */
  7. namespace VisualMedia\LisaBundle\Form\Type;
  8. use Symfony\Component\Form\AbstractType;
  9. use Symfony\Component\Form\Extension\Core\Type\HiddenType;
  10. use Symfony\Component\Form\FormInterface;
  11. use Symfony\Component\Form\FormView;
  12. use Symfony\Component\OptionsResolver\OptionsResolver;
  13. use Symfony\Component\Validator\Constraints\NotBlank;
  14. use VisualMedia\LisaBundle\Form\Constraint\GoogleRecaptchaConstraint;
  15. /**
  16.  * Class GoogleRecaptchaType
  17.  */
  18. class GoogleRecaptchaType extends AbstractType
  19. {
  20.     const VERSION 'v3.0';
  21.     /**
  22.      * {@inheritDoc}
  23.      */
  24.     public function getParent()
  25.     {
  26.         return HiddenType::class;
  27.     }
  28.     /**
  29.      * {@inheritDoc}
  30.      */
  31.     public function buildView(FormView $viewFormInterface $form, array $options): void
  32.     {
  33.         $view->vars['recaptcha_action'] = $form->getRoot()->getName();
  34.     }
  35.     /**
  36.      * {@inheritDoc}
  37.      */
  38.     public function configureOptions(OptionsResolver $resolver): void
  39.     {
  40.         $resolver->setDefaults(array(
  41.             'error_bubbling' => true,
  42.             'label' => false,
  43.             'translation_domain' => 'forms',
  44.             'attr' => array(
  45.                 'class' => 'google_recaptcha_token',
  46.             ),
  47.             'constraints' => array(
  48.                 new GoogleRecaptchaConstraint(),
  49.             ),
  50.         ));
  51.     }
  52. }