src/JuridicusBundle/Form/Type/BundeslandType.php line 16

Open in your IDE?
  1. <?php
  2. namespace JF\JuridicusBundle\Form\Type;
  3. use JMS\DiExtraBundle\Annotation as JMS;
  4. use Symfony\Component\Form\AbstractType;
  5. use Symfony\Component\Form\FormBuilderInterface;
  6. use Doctrine\ORM\EntityManagerInterface ;
  7. use JF\JuridicusBundle\Form\DataTransformer\BundeslandToIdTransformer;
  8. use Symfony\Component\Form\Extension\Core\Type\HiddenType;
  9. /**
  10. * @JMS\FormType
  11. */
  12. class BundeslandType extends AbstractType
  13. {
  14. /**
  15. *
  16. * @var \Doctrine\ORM\EntityManagerInterface
  17. */
  18. protected $em;
  19. /**
  20. * Konstruktor.
  21. *
  22. * @param \Doctrine\ORM\EntityManagerInterface $em
  23. * @JMS\InjectParams({
  24. * "em" = @JMS\Inject("doctrine.orm.entity_manager")
  25. * })
  26. */
  27. public function __construct(EntityManagerInterface $em)
  28. {
  29. $this->em = $em;
  30. }
  31. /**
  32. * {@inheritdoc}
  33. */
  34. public function buildForm(FormBuilderInterface $builder, array $options)
  35. {
  36. $builder->addModelTransformer(new BundeslandToIdTransformer($this->em));
  37. }
  38. /**
  39. * {@inheritdoc}
  40. */
  41. public function getParent()
  42. {
  43. return HiddenType::class;
  44. }
  45. /**
  46. * {@inheritdoc}
  47. */
  48. public function getBundeslandType()
  49. {
  50. return 'bundesland';
  51. }
  52. /**
  53. * {@inheritdoc}
  54. */
  55. public function getName()
  56. {
  57. return 'bundesland';
  58. }
  59. }