<?php
namespace App\Form\Type;

use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints as Assert;

class FontType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $resolver = new OptionsResolver();
        $this->configureOptions($resolver);

        $builder
            ->add('font', ChoiceType::class, [
                'label' => 'Font',
                'choices'  => [
                    'Arial' => 'Arial',
                    'Verdana' => 'Verdana',
                    'Tahoma' => 'Tahoma',
                    'Trebuchet MS' => 'Trebuchet MS',
                    'Times New Roman' => 'Times New Roman',
                    'Georgia' => 'Georgia',
                    'Garamond' => 'Garamond',
                    'Courier New' => 'Courier New',
                    'Brush Script MT' => 'Brush Script MT',
                ],
            ])
            ->add('size', IntegerType::class, [
                'label' => false,
                'constraints' => [
                    new Assert\PositiveOrZero()
                ],
            ]);
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults([
            'font' => 'Arial',
            'size'=> 12,
        ]);
    }
}