<?php

namespace Lc\SovBundle\Form\Ticket;

use Doctrine\ORM\EntityManagerInterface;
use Lc\SovBundle\Solver\Ticket\TicketSolver;
use Lc\SovBundle\Translation\TranslatorAdmin;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Lc\SovBundle\Model\Ticket\TicketInterface;
use Lc\SovBundle\Model\Ticket\TicketModel;

class TicketStatusType extends AbstractType
{
    protected $em;
    protected $translatorAdmin;


    public function __construct(EntityManagerInterface $em, TranslatorAdmin $translatorAdmin)
    {
        $this->em = $em;
        $this->translatorAdmin = $translatorAdmin;
    }

    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add(
            'status',
            ChoiceType::class,
            [
                'choices' => $this->translatorAdmin->transChoices(TicketSolver::getStatusChoices(),'Ticket', 'status'),
                'required' => true,
                'expanded' => true,
                'label' => false,
            ]
        );
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults(
            [
                'data_class' => $this->em->getEntityName(TicketInterface::class),
            ]
        );
    }
}
