mirror of https://github.com/friendica/friendica
- Move settings, defaults and dbstructure to directory 'static' - Dynamic loading of config files (after the static loading) - Filter out '-sample.config.php' and '-sample.ini.php' files - Remove unnecessary ConfigFileManager - Move ConfigFileLoader to Utils - Add tests for multi-loading for INI, config and sample-filteringpull/7313/head
parent
966043712f
commit
92fb0a82ca
@ -1,90 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Friendica\Util\Config;
|
||||
|
||||
/**
|
||||
* An abstract class in case of handling with config files
|
||||
*/
|
||||
abstract class ConfigFileManager
|
||||
{
|
||||
/**
|
||||
* The Sub directory of the config-files
|
||||
* @var string
|
||||
*/
|
||||
const SUBDIRECTORY = 'config';
|
||||
|
||||
/**
|
||||
* The default name of the user defined config file
|
||||
* @var string
|
||||
*/
|
||||
const CONFIG_LOCAL = 'local';
|
||||
|
||||
/**
|
||||
* The default name of the user defined ini file
|
||||
* @var string
|
||||
*/
|
||||
const CONFIG_INI = 'local';
|
||||
|
||||
/**
|
||||
* The default name of the user defined legacy config file
|
||||
* @var string
|
||||
*/
|
||||
const CONFIG_HTCONFIG = 'htconfig';
|
||||
|
||||
protected $baseDir;
|
||||
protected $configDir;
|
||||
|
||||
/**
|
||||
* @param string $baseDir The base directory of Friendica
|
||||
*/
|
||||
public function __construct($baseDir)
|
||||
{
|
||||
$this->baseDir = $baseDir;
|
||||
$this->configDir = $baseDir . DIRECTORY_SEPARATOR . self::SUBDIRECTORY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the full name (including the path) for a *.config.php (default is local.config.php)
|
||||
*
|
||||
* @param string $name The config name (default is empty, which means local.config.php)
|
||||
*
|
||||
* @return string The full name or empty if not found
|
||||
*/
|
||||
protected function getConfigFullName($name = '')
|
||||
{
|
||||
$name = !empty($name) ? $name : self::CONFIG_LOCAL;
|
||||
|
||||
$fullName = $this->configDir . DIRECTORY_SEPARATOR . $name . '.config.php';
|
||||
return file_exists($fullName) ? $fullName : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the full name (including the path) for a *.ini.php (default is local.ini.php)
|
||||
*
|
||||
* @param string $name The config name (default is empty, which means local.ini.php)
|
||||
*
|
||||
* @return string The full name or empty if not found
|
||||
*/
|
||||
protected function getIniFullName($name = '')
|
||||
{
|
||||
$name = !empty($name) ? $name : self::CONFIG_INI;
|
||||
|
||||
$fullName = $this->configDir . DIRECTORY_SEPARATOR . $name . '.ini.php';
|
||||
return file_exists($fullName) ? $fullName : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the full name (including the path) for a .*.php (default is .htconfig.php)
|
||||
*
|
||||
* @param string $name The config name (default is empty, which means .htconfig.php)
|
||||
*
|
||||
* @return string The full name or empty if not found
|
||||
*/
|
||||
protected function getHtConfigFullName($name = '')
|
||||
{
|
||||
$name = !empty($name) ? $name : self::CONFIG_HTCONFIG;
|
||||
|
||||
$fullName = $this->baseDir . DIRECTORY_SEPARATOR . '.' . $name . '.php';
|
||||
return file_exists($fullName) ? $fullName : '';
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* A test file for local configuration
|
||||
*
|
||||
*/
|
||||
|
||||
return [
|
||||
'database' => [
|
||||
'hostname' => 'testhost',
|
||||
'username' => 'testuser',
|
||||
'password' => 'testpw',
|
||||
'database' => 'testdb',
|
||||
'charset' => 'utf8mb4',
|
||||
],
|
||||
|
||||
'config' => [
|
||||
'admin_email' => 'admin@overwritten.local',
|
||||
'sitename' => 'Friendica Social Network',
|
||||
'register_policy' => \Friendica\Module\Register::OPEN,
|
||||
'register_text' => '',
|
||||
],
|
||||
'system' => [
|
||||
'default_timezone' => 'UTC',
|
||||
'language' => 'en',
|
||||
'theme' => 'frio',
|
||||
'newKey' => 'newValue',
|
||||
],
|
||||
];
|
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
/**
|
||||
* A test local ini file
|
||||
*/
|
||||
|
||||
return <<<INI
|
||||
|
||||
[database]
|
||||
hostname = testhost
|
||||
username = testuser
|
||||
password = testpw
|
||||
database = testdb
|
||||
|
||||
[system]
|
||||
theme = changed
|
||||
newKey = newValue
|
||||
|
||||
[config]
|
||||
admin_email = admin@overwritten.local
|
||||
INI;
|
Loading…
Reference in new issue