manage($request, 'merchant'); } /** * @Route("/admin/setting/section", name="carac_admin_setting_section") */ public function manageSection( Request $request ) { return $this->manage($request, 'section'); } public function manage( Request $request, $type ) { $entity = null; $entityManager = $this->get(EntityManagerInterface::class); if ($type == 'merchant') { $resolver = $this->get(MerchantContainer::class)->getResolver(); $formClass = MerchantSettingsFormType::class; $settingDefinition = $this->get(MerchantSettingContainer::class)->getDefinition(); } elseif ($type == 'section') { $resolver = $this->get(SectionContainer::class)->getResolver(); $formClass = SectionSettingsFormType::class; $settingDefinition = $this->get(SectionSettingContainer::class)->getDefinition(); } $entity = $resolver->getCurrent(); if ($entity) { $form = $this->createForm($formClass, $entity); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $entityManager->update($entity); $entityManager->flush(); $this->addFlash('success', $this->get(TranslatorAdmin::class)->transFlashMessage('settings_saved')); } return $this->render( '@LcCaracole/admin/setting/edit_' . $type . '.html.twig', [ 'display_switch_section' => ($type == 'section') ? true : false, 'resolver' => $resolver, 'setting_definition' => $settingDefinition, 'form' => $form->createView() ] ); } } /** * @Route("/admin/setting/site2", name="carac_admin_setting_site") */ public function manageGlobal(Request $request, EntityManagerInterface $entityManager) { $site = $this->get(SiteContainer::class)->getStore()->getOneByDevAlias('default'); $form = $this->createForm(SiteSettingsFormType::class, $site); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $entityManager->update($site); $entityManager->flush(); $this->addFlash('success', $this->get(TranslatorAdmin::class)->transFlashMessage('settings_saved')); } return $this->render( '@LcCaracole/admin/setting/edit_site.html.twig', [ 'setting_definition' => $this->siteSettingDefinition, 'form' => $form->createView() ] ); } }