<?php

namespace Lc\SovBundle\Form\Newsletter;

use Lc\SovBundle\Component\FormComponent;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\Email;
use Symfony\Component\Validator\Constraints\NotNull;

class NewsletterType extends AbstractType
{
    protected FormComponent $formComponent;

    public function __construct(FormComponent $formComponent)
    {
        $this->formComponent = $formComponent;
    }

    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add(
                'email',
                EmailType::class,
                [
                        'label' => 'Renseignez votre adresse email :',
                        'constraints' => [
                                new Email(),
                                new NotNull()
                        ]
                ]
        );

        // captcha
        $this->formComponent->addCaptchaType($builder);
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults(
                [

                ]
        );
    }
}
