merchantRepository = $merchantRepository; $this->sectionRepository = $sectionRepository; $this->formFactory = $formFactory; $this->urlGenerator = $urlGenerator; } public function getFunctions() { return array( new TwigFunction('carac_get_sections', [$this, 'getSections']), new TwigFunction('carac_get_form_switch_merchant', [$this, 'getFormSwitchMerchant']), new TwigFunction('carac_get_form_switch_merchant_button', [$this, 'getFormSwitchMerchantButton']), new TwigFunction('carac_get_form_switch_section', [$this, 'getFormSwitchSection']), ); } public function getSections() { return $this->sectionRepository->findAll(); } public function getMerchants() { return $this->merchantRepository->findAll(); } public function getFormSwitchMerchant($context = 'front') { $form = $this->formFactory->create( SwitchMerchantFormType::class, null, [ 'action' => $this->urlGenerator->generate('carac_switch_merchant'), 'attr' => ['class' => 'switch-merchant'], 'context' => $context ] ); return $form->createView(); } public function getFormSwitchMerchantButton() { $form = $this->formFactory->create( SwitchMerchantButtonAdminFormType::class, null, [ 'action' => $this->urlGenerator->generate('carac_switch_merchant'), ] ); return $form->createView(); } public function getFormSwitchSection($section) { $form = $this->formFactory->create( SwitchSectionFormType::class, null, [ 'action' => $this->urlGenerator->generate('carac_switch_section'), 'attr' => ['class' => 'switch-section'], 'section' => $section, ] ); return $form->createView(); } }