<?php
namespace JF\JuridicusBundle\Form\Type;
use JMS\DiExtraBundle\Annotation as JMS;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Doctrine\ORM\EntityManagerInterface ;
use JF\JuridicusBundle\Form\DataTransformer\BundeslandToIdTransformer;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
/**
* @JMS\FormType
*/
class BundeslandType extends AbstractType
{
/**
*
* @var \Doctrine\ORM\EntityManagerInterface
*/
protected $em;
/**
* Konstruktor.
*
* @param \Doctrine\ORM\EntityManagerInterface $em
* @JMS\InjectParams({
* "em" = @JMS\Inject("doctrine.orm.entity_manager")
* })
*/
public function __construct(EntityManagerInterface $em)
{
$this->em = $em;
}
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->addModelTransformer(new BundeslandToIdTransformer($this->em));
}
/**
* {@inheritdoc}
*/
public function getParent()
{
return HiddenType::class;
}
/**
* {@inheritdoc}
*/
public function getBundeslandType()
{
return 'bundesland';
}
/**
* {@inheritdoc}
*/
public function getName()
{
return 'bundesland';
}
}