<?php

namespace Lc\ShopBundle\Form\Frontend;

use Lc\ShopBundle\Services\UtilsManager;
use Lc\ShopBundle\Validator\Constraints\UniqueEmailValidator;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\Email;
use Symfony\Component\Validator\Constraints\EqualTo;
use Symfony\Component\Validator\Constraints\GreaterThanOrEqual;
use Symfony\Component\Validator\Constraints\NotNull;

class NewsletterType extends AbstractType
{
        protected $utils ;

        public function __construct(UtilsManager $utilsManager)
        {
                $this->utils = $utilsManager->getUtils() ;
        }

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

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

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

                ]);
        }
}
