Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

62 lines
2.1KB

  1. <?php
  2. namespace Lc\SovBundle\Controller\Setting;
  3. use Doctrine\ORM\EntityManagerInterface;
  4. use Lc\CaracoleBundle\Form\Setting\MerchantSettingsFormType;
  5. use Lc\CaracoleBundle\Form\Setting\SectionSettingsFormType;
  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. class SettingAdminController extends AbstractController
  14. {
  15. protected $em;
  16. protected $translatorAdmin;
  17. protected $siteSettingRepository;
  18. protected $siteSettingDefinition;
  19. protected $siteRepository;
  20. public function __construct(
  21. EntityManagerInterface $em,
  22. TranslatorAdmin $translatorAdmin,
  23. SiteSettingRepository $siteSettingRepository,
  24. SiteSettingDefinitionInterface $siteSettingDefinition,
  25. SiteRepository $siteRepository
  26. ) {
  27. $this->em = $em;
  28. $this->translatorAdmin = $translatorAdmin;
  29. $this->siteSettingRepository = $siteSettingRepository;
  30. $this->siteSettingDefinition = $siteSettingDefinition;
  31. $this->siteRepository = $siteRepository;
  32. }
  33. public function manageGlobal(Request $request)
  34. {
  35. $site = $this->siteRepository->findOneByDevAlias('default') ;
  36. $form = $this->createForm(SiteSettingsFormType::class, $site);
  37. $form->handleRequest($request);
  38. if ($form->isSubmitted() && $form->isValid()) {
  39. $this->em->update($site);
  40. $this->em->flush();
  41. $this->addFlash('success', $this->translatorAdmin->transFlashMessage('settings_saved'));
  42. }
  43. return $this->render(
  44. '@LcSov/admin/setting/global.html.twig' ,
  45. [
  46. 'setting_definition' => $this->siteSettingDefinition,
  47. 'form' => $form->createView()
  48. ]
  49. );
  50. }
  51. }