formFactory = $formFactory; $this->urlGenerator = $urlGenerator; } public function getFunctions() { return array( new TwigFunction('carac_form_switch_merchant', [$this, 'getFormSwitchMerchant']), new TwigFunction('carac_form_switch_section', [$this, 'getFormSwitchSection']), ); } public function getFormSwitchMerchant($context = 'front', $actionRoute = 'carac_merchant_switch') { $form = $this->formFactory->create( SwitchMerchantFormType::class, null, [ 'action' => $this->urlGenerator->generate($actionRoute), 'attr' => ['class' => 'switch-merchant'], 'context' => $context ] ); return $form->createView(); } public function getFormSwitchSection($section) { $form = $this->formFactory->create( SwitchSectionFormType::class, null, [ 'action' => $this->urlGenerator->generate('carac_section_switch'), 'attr' => ['class' => 'switch-section'], 'section' => $section, ] ); return $form->createView(); } }