1 | <?php |
||
12 | class BusinessEntityHiddenType extends AbstractType |
||
|
|||
13 | { |
||
14 | protected $entityManager; |
||
15 | |||
16 | public function __construct(EntityManager $entityManager) |
||
1 ignored issue
–
show
|
|||
17 | { |
||
18 | $this->entityManager = $entityManager; |
||
19 | } |
||
20 | |||
21 | public function getParent() |
||
22 | { |
||
23 | return HiddenType::class; |
||
24 | } |
||
25 | |||
26 | public function buildForm(FormBuilderInterface $builder, array $options) |
||
27 | { |
||
28 | $entityManager = $this->entityManager; |
||
29 | parent::buildForm($builder, $options); |
||
30 | |||
31 | $builder->addModelTransformer( |
||
32 | new CallbackTransformer( |
||
33 | function ($businessEntity) { |
||
34 | return $businessEntity; |
||
35 | }, |
||
36 | function ($nameToBusinessEntity) use ($entityManager) { |
||
37 | return $entityManager->getRepository( |
||
38 | 'VictoireBusinessEntityBundle:BusinessEntity' |
||
39 | )->findOneByName( |
||
40 | $nameToBusinessEntity |
||
41 | ); |
||
42 | } |
||
43 | ) |
||
44 | ); |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * bind form to WidgetRedactor entity. |
||
49 | * |
||
50 | * @param OptionsResolver $resolver |
||
51 | */ |
||
52 | public function configureOptions(OptionsResolver $resolver) |
||
58 | } |
||
59 |