]> git.mxchange.org Git - friendica.git/blobdiff - src/Factory/ConfigFactory.php
Fixing PUBLIC usage, Fixing DB-View, Creating tests
[friendica.git] / src / Factory / ConfigFactory.php
index 3110490fd3280749592da3fc28adf41bbb4288ca..cf55640960f0c02f19191f8be52257c14329a048 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2021, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -30,6 +30,45 @@ use Friendica\Util\ConfigFileLoader;
 
 class ConfigFactory
 {
+       /**
+        * The key of the $_SERVER variable to override the config directory
+        *
+        * @var string
+        */
+       const CONFIG_DIR_ENV = 'FRIENDICA_CONFIG_DIR';
+
+       /**
+        * The Sub directory of the config-files
+        *
+        * @var string
+        */
+       const CONFIG_DIR = 'config';
+
+       /**
+        * The Sub directory of the static config-files
+        *
+        * @var string
+        */
+       const STATIC_DIR = 'static';
+
+       /**
+        * @param string $basePath The basepath of FRIENDICA
+        * @param array $serer the $_SERVER array
+        *
+        * @return ConfigFileLoader
+        */
+       public function createConfigFileLoader(string $basePath, array $server = [])
+       {
+               if (!empty($server[self::CONFIG_DIR_ENV]) && is_dir($server[self::CONFIG_DIR_ENV])) {
+                       $configDir = $server[self::CONFIG_DIR_ENV];
+               } else {
+                       $configDir = $basePath . DIRECTORY_SEPARATOR . self::CONFIG_DIR;
+               }
+               $staticDir = $basePath . DIRECTORY_SEPARATOR . self::STATIC_DIR;
+
+               return new ConfigFileLoader($basePath, $configDir, $staticDir);
+       }
+
        /**
         * @param ConfigFileLoader $loader The Config Cache loader (INI/config/.htconfig)
         *