|
- <?php
-
- namespace Lc\SovBundle\Controller\Setting;
-
- use Doctrine\ORM\EntityManagerInterface;
- use Lc\SovBundle\Container\Setting\SiteSettingContainer;
- use Lc\SovBundle\Container\Site\SiteContainer;
- 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;
- use Symfony\Component\Routing\Annotation\Route;
-
- class SettingAdminController extends AbstractController
- {
- protected EntityManagerInterface $entityManager;
- protected TranslatorAdmin $translatorAdmin;
- protected SiteSettingContainer $siteSettingContainer;
- protected SiteContainer $siteContainer;
-
- public function __construct(
- EntityManagerInterface $entityManager,
- TranslatorAdmin $translatorAdmin,
- SiteSettingContainer $siteSettingContainer,
- SiteContainer $siteContainer
- ) {
- $this->entityManager = $entityManager;
- $this->translatorAdmin = $translatorAdmin;
- $this->siteSettingContainer = $siteSettingContainer;
- $this->siteContainer = $siteContainer;
- }
-
- /**
- * @Route("/admin/setting/site", name="sov_admin_setting_site")
- */
- public function manageGlobal(Request $request)
- {
- $site = $this->siteContainer->getRepositoryQuery()->getRepository()->findOneByDevAlias('default') ;
- $form = $this->createForm(SiteSettingsFormType::class, $site);
-
- $form->handleRequest($request);
-
- if ($form->isSubmitted() && $form->isValid()) {
-
- $this->entityManager->update($site);
- $this->entityManager->flush();
-
- $this->addFlash('success', $this->translatorAdmin->transFlashMessage('settings_saved'));
- }
-
- return $this->render(
- '@LcSov/admin/setting/edit_site.html.twig' ,
- [
- 'setting_definition' => $this->siteSettingContainer->getDefinition(),
- 'form' => $form->createView()
- ]
- );
- }
-
- }
|