<?php

namespace Lc\ShopBundle\Form\Backend\User;

use App\Entity\Supplier;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Lc\ShopBundle\Model\Ticket;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;

class TicketTypesNotificationType extends AbstractType
{
        protected $em;

        public function __construct(EntityManagerInterface $entityManager)
        {
                $this->em = $entityManager;
        }

        public function buildForm(FormBuilderInterface $builder, array $options)
        {

                $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event)  {
                        $builder = $event->getForm()->getParent();

                        $builder->add('ticketTypesNotification', ChoiceType::class, [
                                'choices'=> array(
                                        'field.Ticket.typeOptions.'.Ticket::TYPE_GENERAL_QUESTION => Ticket::TYPE_GENERAL_QUESTION,
                                        'field.Ticket.typeOptions.'.Ticket::TYPE_PRODUCT_ERROR=> Ticket::TYPE_PRODUCT_ERROR ,
                                        'field.Ticket.typeOptions.'.Ticket::TYPE_PRODUCT_UNAVAILABLE => Ticket::TYPE_PRODUCT_UNAVAILABLE,
                                        'field.Ticket.typeOptions.'.Ticket::TYPE_TECHNICAL_PROBLEM => Ticket::TYPE_TECHNICAL_PROBLEM,
                                        'field.Ticket.typeOptions.'.Ticket::TYPE_POULTRY_BOOKING => Ticket::TYPE_POULTRY_BOOKING
                                ),
                                'required' => false,
                                'expanded' => false,
                                'multiple' => true,
                                'translation_domain'=>'lcshop',
                        ]);
                });
        }

        public function configureOptions(OptionsResolver $resolver)
        {
                $resolver->setDefaults([
                //        'translation_domain' => 'lcshop',
                ]);
        }
}
