Browse Source

Add function "updateEnvFile" to save settings in .env file

jmontoyaa 7 năm trước cách đây
mục cha
commit
23fc23e63d
2 tập tin đã thay đổi với 13 bổ sung7 xóa
  1. 2 7
      main/install/index.php
  2. 11 0
      main/install/install.lib.php

+ 2 - 7
main/install/index.php

@@ -782,8 +782,6 @@ if (@$_POST['step2']) {
             $manager->getConnection()->executeQuery($sql);
 
             $envFile = api_get_path(SYS_PATH).'.env';
-            $contents = file_get_contents($envFile);
-
             $params = [
                 '{{DATABASE_HOST}}' => $dbHostForm,
                 '{{DATABASE_PORT}}' => $dbPortForm,
@@ -793,10 +791,8 @@ if (@$_POST['step2']) {
                 '{{APP_INSTALLED}}' => 1,
                 '{{APP_ENCRYPT_METHOD}}' => $encryptPassForm
             ];
-            $contents = str_replace(array_keys($params), array_values($params), $contents);
-            file_put_contents($envFile, $contents);
-
-            (new Dotenv())->load(api_get_path(SYS_PATH).'.env');
+            updateEnvFile($params);
+            (new Dotenv())->load($envFile);
 
             $kernel = new Kernel('dev', true);
             $application = new Application($kernel);
@@ -810,7 +806,6 @@ if (@$_POST['step2']) {
                 $kernel->boot();
                 $doctrine = $kernel->getContainer()->get('doctrine');
                 $manager = $doctrine->getManager();
-
                 $sysPath = api_get_path(SYS_PATH);
                 finishInstallation(
                     $manager,

+ 11 - 0
main/install/install.lib.php

@@ -2722,6 +2722,17 @@ function fixIds(EntityManager $em)
     }
 }
 
+/**
+ * @param array $params
+ */
+function updateEnvFile($params)
+{
+    $envFile = api_get_path(SYS_PATH).'.env';
+    $contents = file_get_contents($envFile);
+    $contents = str_replace(array_keys($params), array_values($params), $contents);
+    file_put_contents($envFile, $contents);
+}
+
 /**
  *
  * After the schema was created (table creation), the function adds