Add the possibility to use a different configuration directory

This commit is contained in:
Philipp 2021-09-11 14:33:26 +02:00
parent c40b3411a7
commit 5702944116
No known key found for this signature in database
GPG key ID: 24A7501396EB5432
12 changed files with 75 additions and 19 deletions

View file

@ -35,6 +35,13 @@ use Friendica\Core\Config\Cache;
*/
class ConfigFileLoader
{
/**
* 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
*
@ -83,10 +90,14 @@ class ConfigFileLoader
*/
private $staticDir;
public function __construct(string $basePath)
public function __construct(string $basePath, array $server)
{
$this->baseDir = $basePath;
$this->configDir = $this->baseDir . DIRECTORY_SEPARATOR . self::CONFIG_DIR;
$this->baseDir = $basePath;
if (!empty($server[self::CONFIG_DIR_ENV]) && is_dir($server[self::CONFIG_DIR_ENV])) {
$this->configDir = $server[self::CONFIG_DIR_ENV];
} else {
$this->configDir = $this->baseDir . DIRECTORY_SEPARATOR . self::CONFIG_DIR;
}
$this->staticDir = $this->baseDir . DIRECTORY_SEPARATOR . self::STATIC_DIR;
}