|
- <?php
-
- namespace Lc\SovBundle\Controller\Setting;
-
- use Doctrine\ORM\EntityManagerInterface;
- use Lc\SovBundle\Definition\SiteSettingDefinitionInterface;
- use Lc\SovBundle\Form\Setting\SiteSettingsFormType;
- use Lc\SovBundle\Repository\Setting\SiteSettingRepository;
- use Lc\SovBundle\Repository\Site\SiteRepository;
- use Lc\SovBundle\Translation\TranslatorAdmin;
- use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
- use Symfony\Component\HttpFoundation\Request;
-
- class SettingAdminController extends AbstractController
- {
- protected $em;
- protected $translatorAdmin;
- protected $siteSettingRepository;
- protected $siteSettingDefinition;
- protected $siteRepository;
-
- public function __construct(
- EntityManagerInterface $em,
- TranslatorAdmin $translatorAdmin,
- SiteSettingRepository $siteSettingRepository,
- SiteSettingDefinitionInterface $siteSettingDefinition,
- SiteRepository $siteRepository
- ) {
- $this->em = $em;
- $this->translatorAdmin = $translatorAdmin;
- $this->siteSettingRepository = $siteSettingRepository;
- $this->siteSettingDefinition = $siteSettingDefinition;
- $this->siteRepository = $siteRepository;
- }
-
- public function manageGlobal(Request $request)
- {
- $site = $this->siteRepository->findOneByDevAlias('default') ;
- $form = $this->createForm(SiteSettingsFormType::class, $site);
-
- $form->handleRequest($request);
-
- if ($form->isSubmitted() && $form->isValid()) {
-
- $this->em->update($site);
- $this->em->flush();
-
- $this->addFlash('success', $this->translatorAdmin->transFlashMessage('settings_saved'));
- }
-
- return $this->render(
- '@LcSov/admin/setting/global.html.twig' ,
- [
- 'setting_definition' => $this->siteSettingDefinition,
- 'form' => $form->createView()
- ]
- );
- }
-
- }
|