You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.1KB

  1. <?php
  2. namespace Lc\CaracoleBundle\Form\Merchant;
  3. use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
  4. use Lc\CaracoleBundle\Resolver\MerchantResolver;
  5. use Lc\SovBundle\Doctrine\EntityManager;
  6. use Lc\SovBundle\Model\User\UserInterface;
  7. use Lc\SovBundle\Translation\TranslatorAdmin;
  8. use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  9. use Symfony\Component\Form\AbstractType;
  10. use Symfony\Component\Form\Extension\Core\Type\HiddenType;
  11. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  12. use Symfony\Component\Form\FormBuilderInterface;
  13. use Symfony\Component\OptionsResolver\OptionsResolver;
  14. class DuplicateToOtherMerchantFormType extends AbstractType
  15. {
  16. protected $em;
  17. protected $translatorAdmin;
  18. protected $merchantResolver;
  19. public function __construct(EntityManager $em, TranslatorAdmin $translatorAdmin, MerchantResolver $merchantResolver)
  20. {
  21. $this->em = $em;
  22. $this->translatorAdmin = $translatorAdmin;
  23. $this->merchantResolver = $merchantResolver;
  24. }
  25. public function buildForm(FormBuilderInterface $builder, array $options)
  26. {
  27. //TODO tester si l'utilisateur à les droits sur ce merchant
  28. $builder->add(
  29. 'merchants',
  30. EntityType::class,
  31. [
  32. 'class' => $this->em->getEntityName(MerchantInterface::class),
  33. 'choice_label' => 'title'
  34. ]
  35. );
  36. $builder->add(
  37. 'EntityId',
  38. HiddenType::class,
  39. [
  40. 'data' => $options['entityId']
  41. ]
  42. );
  43. $builder->add(
  44. 'EntityClass',
  45. HiddenType::class,
  46. [
  47. 'data' => $options['entityClass']
  48. ]
  49. );
  50. }
  51. /**
  52. * {@inheritdoc}
  53. */
  54. public function configureOptions(OptionsResolver $resolver)
  55. {
  56. $resolver->setDefaults(
  57. [
  58. 'entityId' => null,
  59. 'entityClass' => null,
  60. ]
  61. );
  62. }
  63. }