42 lines
1.2KB

  1. <?php
  2. namespace Lc\SovBundle\Controller\Setting;
  3. use Lc\SovBundle\Container\Setting\SiteSettingContainer;
  4. use Lc\SovBundle\Controller\AbstractController;
  5. use Lc\SovBundle\Form\Setting\SiteSettingsFormType;
  6. use Symfony\Component\HttpFoundation\Request;
  7. use Symfony\Component\Routing\Annotation\Route;
  8. class SettingAdminController extends AbstractController
  9. {
  10. /**
  11. * @Route("/admin/setting/site", name="sov_admin_setting_site")
  12. */
  13. public function manageGlobal(Request $request)
  14. {
  15. $entityManager = $this->getEntityManager();
  16. $site = $this->getSiteContainer()->getStore()->getOneByDevAlias('default') ;
  17. $form = $this->createForm(SiteSettingsFormType::class, $site);
  18. $form->handleRequest($request);
  19. if ($form->isSubmitted() && $form->isValid()) {
  20. $entityManager->update($site);
  21. $entityManager->flush();
  22. $this->addFlashTranslator('success', 'updated');
  23. }
  24. return $this->render(
  25. '@LcSov/admin/setting/edit_site.html.twig' ,
  26. [
  27. 'setting_definition' => $this->get(SiteSettingContainer::class)->getDefinition(),
  28. 'form' => $form->createView()
  29. ]
  30. );
  31. }
  32. }