Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

SettingAdminController.php 1.6KB

3 lat temu
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace Lc\SovBundle\Controller\Setting;
  3. use Doctrine\ORM\EntityManagerInterface;
  4. use Lc\SovBundle\Container\Setting\SiteSettingContainer;
  5. use Lc\SovBundle\Container\Site\SiteContainer;
  6. use Lc\SovBundle\Definition\SiteSettingDefinitionInterface;
  7. use Lc\SovBundle\Form\Setting\SiteSettingsFormType;
  8. use Lc\SovBundle\Repository\Setting\SiteSettingRepository;
  9. use Lc\SovBundle\Repository\Site\SiteRepository;
  10. use Lc\SovBundle\Translation\TranslatorAdmin;
  11. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  12. use Symfony\Component\HttpFoundation\Request;
  13. use Symfony\Component\Routing\Annotation\Route;
  14. class SettingAdminController extends AbstractController
  15. {
  16. /**
  17. * @Route("/admin/setting/site", name="sov_admin_setting_site")
  18. */
  19. public function manageGlobal(Request $request, EntityManagerInterface $entityManager)
  20. {
  21. $site = $this->get(SiteContainer::class)->getStore()->getOneByDevAlias('default') ;
  22. $form = $this->createForm(SiteSettingsFormType::class, $site);
  23. $form->handleRequest($request);
  24. if ($form->isSubmitted() && $form->isValid()) {
  25. $entityManager->update($site);
  26. $entityManager->flush();
  27. $this->addFlash('success', $this->get(TranslatorAdmin::class)->transFlashMessage('settings_saved'));
  28. }
  29. return $this->render(
  30. '@LcSov/admin/setting/edit_site.html.twig' ,
  31. [
  32. 'setting_definition' => $this->get(SiteSettingContainer::class)->getDefinition(),
  33. 'form' => $form->createView()
  34. ]
  35. );
  36. }
  37. }