|
- <?php
-
- namespace Lc\CaracoleBundle\Form\Merchant;
-
- use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
- use Lc\CaracoleBundle\Resolver\MerchantResolver;
- use Lc\SovBundle\Doctrine\EntityManager;
- use Lc\SovBundle\Model\User\UserInterface;
- use Lc\SovBundle\Translation\TranslatorAdmin;
- use Symfony\Bridge\Doctrine\Form\Type\EntityType;
- use Symfony\Component\Form\AbstractType;
- use Symfony\Component\Form\Extension\Core\Type\HiddenType;
- use Symfony\Component\Form\Extension\Core\Type\SubmitType;
- use Symfony\Component\Form\FormBuilderInterface;
- use Symfony\Component\OptionsResolver\OptionsResolver;
-
- class DuplicateToOtherMerchantFormType extends AbstractType
- {
- protected $em;
- protected $translatorAdmin;
- protected $merchantResolver;
-
- public function __construct(EntityManager $em, TranslatorAdmin $translatorAdmin, MerchantResolver $merchantResolver)
- {
- $this->em = $em;
- $this->translatorAdmin = $translatorAdmin;
- $this->merchantResolver = $merchantResolver;
- }
-
- public function buildForm(FormBuilderInterface $builder, array $options)
- {
- //TODO tester si l'utilisateur à les droits sur ce merchant
- $builder->add(
- 'merchants',
- EntityType::class,
- [
- 'class' => $this->em->getEntityName(MerchantInterface::class),
- 'choice_label' => 'title'
- ]
- );
-
- $builder->add(
- 'EntityId',
- HiddenType::class,
- [
- 'data' => $options['entityId']
- ]
- );
-
- $builder->add(
- 'EntityClass',
- HiddenType::class,
- [
- 'data' => $options['entityClass']
- ]
- );
- }
-
- /**
- * {@inheritdoc}
- */
- public function configureOptions(OptionsResolver $resolver)
- {
- $resolver->setDefaults(
- [
- 'entityId' => null,
- 'entityClass' => null,
- ]
- );
- }
-
- }
|