您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

SettingAdminController.php 1.8KB

3 年前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. protected EntityManagerInterface $entityManager;
  17. public function __construct(EntityManagerInterface $entityManager)
  18. {
  19. $this->entityManager = $entityManager;
  20. }
  21. /**
  22. * @Route("/admin/setting/site", name="sov_admin_setting_site")
  23. */
  24. public function manageGlobal(Request $request, EntityManagerInterface $entityManager)
  25. {
  26. $site = $this->get(SiteContainer::class)->getStore()->getOneByDevAlias('default') ;
  27. $form = $this->createForm(SiteSettingsFormType::class, $site);
  28. $form->handleRequest($request);
  29. if ($form->isSubmitted() && $form->isValid()) {
  30. $entityManager->update($site);
  31. $entityManager->flush();
  32. $this->addFlash('success', $this->get(TranslatorAdmin::class)->transFlashMessage('settings_saved'));
  33. }
  34. return $this->render(
  35. '@LcSov/admin/setting/edit_site.html.twig' ,
  36. [
  37. 'setting_definition' => $this->get(SiteSettingContainer::class)->getDefinition(),
  38. 'form' => $form->createView()
  39. ]
  40. );
  41. }
  42. }