選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

54 行
1.8KB

  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. }