Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

SettingAdminController.php 2.1KB

vor 3 Jahren
vor 3 Jahren
vor 3 Jahren
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace Lc\SovBundle\Controller\Setting;
  3. use Doctrine\ORM\EntityManagerInterface;
  4. use Lc\SovBundle\Definition\SiteSettingDefinitionInterface;
  5. use Lc\SovBundle\Form\Setting\SiteSettingsFormType;
  6. use Lc\SovBundle\Repository\Setting\SiteSettingRepository;
  7. use Lc\SovBundle\Repository\Site\SiteRepository;
  8. use Lc\SovBundle\Translation\TranslatorAdmin;
  9. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  10. use Symfony\Component\HttpFoundation\Request;
  11. use Symfony\Component\Routing\Annotation\Route;
  12. class SettingAdminController extends AbstractController
  13. {
  14. protected $em;
  15. protected $translatorAdmin;
  16. protected $siteSettingRepository;
  17. protected $siteSettingDefinition;
  18. protected $siteRepository;
  19. public function __construct(
  20. EntityManagerInterface $em,
  21. TranslatorAdmin $translatorAdmin,
  22. SiteSettingRepository $siteSettingRepository,
  23. SiteSettingDefinitionInterface $siteSettingDefinition,
  24. SiteRepository $siteRepository
  25. ) {
  26. $this->em = $em;
  27. $this->translatorAdmin = $translatorAdmin;
  28. $this->siteSettingRepository = $siteSettingRepository;
  29. $this->siteSettingDefinition = $siteSettingDefinition;
  30. $this->siteRepository = $siteRepository;
  31. }
  32. /**
  33. * @Route("/admin/setting/site", name="sov_admin_setting_site")
  34. */
  35. public function manageGlobal(Request $request)
  36. {
  37. $site = $this->siteRepository->findOneByDevAlias('default') ;
  38. $form = $this->createForm(SiteSettingsFormType::class, $site);
  39. $form->handleRequest($request);
  40. if ($form->isSubmitted() && $form->isValid()) {
  41. $this->em->update($site);
  42. $this->em->flush();
  43. $this->addFlash('success', $this->translatorAdmin->transFlashMessage('settings_saved'));
  44. }
  45. return $this->render(
  46. '@LcSov/admin/setting/edit_site.html.twig' ,
  47. [
  48. 'setting_definition' => $this->siteSettingDefinition,
  49. 'form' => $form->createView()
  50. ]
  51. );
  52. }
  53. }