X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FFactory%2FConfigFactory.php;h=cf55640960f0c02f19191f8be52257c14329a048;hb=b5d994394e2c67d37d9a9360731d08d7112d18fe;hp=9a20100b2fe6da880d4877171c88c1c18a25b38a;hpb=054c301ef0345c4ff9f35cfd08717757eab17b9d;p=friendica.git diff --git a/src/Factory/ConfigFactory.php b/src/Factory/ConfigFactory.php index 9a20100b2f..cf55640960 100644 --- a/src/Factory/ConfigFactory.php +++ b/src/Factory/ConfigFactory.php @@ -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) *