From 7b132cdc1774cb557b353897b1e9d3beccb2bffe Mon Sep 17 00:00:00 2001 From: babak alizadeh Date: Fri, 5 Jan 2024 21:20:16 +0000 Subject: [PATCH] add some settings to core and delete from static pages --- .../src/Controller/AdminController.php | 18 +++++++++++++---- hesabixCore/src/Entity/Settings.php | 15 ++++++++++++++ hesabixCore/templates/base.html.twig | 20 +------------------ 3 files changed, 30 insertions(+), 23 deletions(-) diff --git a/hesabixCore/src/Controller/AdminController.php b/hesabixCore/src/Controller/AdminController.php index 15f0144..2c839a3 100644 --- a/hesabixCore/src/Controller/AdminController.php +++ b/hesabixCore/src/Controller/AdminController.php @@ -186,9 +186,13 @@ class AdminController extends AbstractController $resp['description'] = $item->getDiscription(); $resp['scripts'] = $item->getScripts(); $resp['zarinpal'] = $item->getZarinpalMerchant(); + $resp['footerScripts'] = $item->getFooterScripts(); + $resp['appSite'] = $item->getAppSite(); + $resp['footer'] = $item->getFooter(); return $this->json($resp); } + #[Route('/api/admin/settings/system/info/save', name: 'admin_settings_system_info_save')] public function admin_settings_system_info_save(EntityManagerInterface $entityManager,Request $request): Response { @@ -202,6 +206,9 @@ class AdminController extends AbstractController $item->setDiscription($params['description']); $item->setScripts($params['scripts']); $item->setZarinpalMerchant($params['zarinpal']); + $item->setFooterScripts($params['footerScripts']); + $item->setAppSite($params['appSite']); + $item->setFooter($params['footer']); $entityManager->persist($item); $entityManager->flush(); return $this->json(['result' => 1]); @@ -364,7 +371,7 @@ class AdminController extends AbstractController /** * @throws Exception */ - #[Route('/test', name: 'app_admin_database_backup_create')] + #[Route('/api/admin/database/backup/create', name: 'app_admin_database_backup_create')] public function app_admin_database_backup_create(KernelInterface $kernel):JsonResponse { $application = new Application($kernel); @@ -374,8 +381,6 @@ class AdminController extends AbstractController 'command' => 'doctrine:schema:create', // (optional) define the value of command arguments '--dump-sql' => true, - '../../hesabixBackup/databaseFiles/file.sql'=>true, - ]); // You can use NullOutput() if you don't need the output @@ -383,8 +388,13 @@ class AdminController extends AbstractController $application->run($input, $output); // return the output, don't use if you used NullOutput() $content = $output->fetch(); + $time = time(); + $file = fopen(dirname(__DIR__, 3) . '/hesabixBackup/versions/Hesabix-'. $time . '.sql' ,'w'); + fwrite($file,$content); + fclose($file); return $this->json([ - 'message' => $content, + 'result' => 0, + 'filename'=>'Hesabix-' . $time . '.sql', ]); } } diff --git a/hesabixCore/src/Entity/Settings.php b/hesabixCore/src/Entity/Settings.php index 1233d0a..e5e9e9f 100644 --- a/hesabixCore/src/Entity/Settings.php +++ b/hesabixCore/src/Entity/Settings.php @@ -47,6 +47,9 @@ class Settings #[ORM\Column(type: Types::TEXT, nullable: true)] private ?string $footerScripts = null; + #[ORM\Column(type: Types::TEXT, nullable: true)] + private ?string $footer = null; + public function getId(): ?int { return $this->id; @@ -183,4 +186,16 @@ class Settings return $this; } + + public function getFooter(): ?string + { + return $this->footer; + } + + public function setFooter(?string $footer): static + { + $this->footer = $footer; + + return $this; + } } diff --git a/hesabixCore/templates/base.html.twig b/hesabixCore/templates/base.html.twig index 15ea8b3..b404b1b 100644 --- a/hesabixCore/templates/base.html.twig +++ b/hesabixCore/templates/base.html.twig @@ -244,25 +244,7 @@ - + {{settings.footer | raw}}