3 namespace Friendica\Util\Config;
6 * An abstract class in case of handling with config files
8 abstract class ConfigFileManager
11 * The Sub directory of the config-files
14 const SUBDIRECTORY = 'config';
17 * The default name of the user defined config file
20 const CONFIG_LOCAL = 'local';
23 * The default name of the user defined ini file
26 const CONFIG_INI = 'local';
29 * The default name of the user defined legacy config file
32 const CONFIG_HTCONFIG = 'htconfig';
38 * @param string $baseDir The base directory of Friendica
40 public function __construct($baseDir)
42 $this->baseDir = $baseDir;
43 $this->configDir = $baseDir . DIRECTORY_SEPARATOR . self::SUBDIRECTORY;
47 * Gets the full name (including the path) for a *.config.php (default is local.config.php)
49 * @param string $name The config name (default is empty, which means local.config.php)
51 * @return string The full name or empty if not found
53 protected function getConfigFullName($name = '')
55 $name = !empty($name) ? $name : self::CONFIG_LOCAL;
57 $fullName = $this->configDir . DIRECTORY_SEPARATOR . $name . '.config.php';
58 return file_exists($fullName) ? $fullName : '';
62 * Gets the full name (including the path) for a *.ini.php (default is local.ini.php)
64 * @param string $name The config name (default is empty, which means local.ini.php)
66 * @return string The full name or empty if not found
68 protected function getIniFullName($name = '')
70 $name = !empty($name) ? $name : self::CONFIG_INI;
72 $fullName = $this->configDir . DIRECTORY_SEPARATOR . $name . '.ini.php';
73 return file_exists($fullName) ? $fullName : '';
77 * Gets the full name (including the path) for a .*.php (default is .htconfig.php)
79 * @param string $name The config name (default is empty, which means .htconfig.php)
81 * @return string The full name or empty if not found
83 protected function getHtConfigFullName($name = '')
85 $name = !empty($name) ? $name : self::CONFIG_HTCONFIG;
87 $fullName = $this->baseDir . DIRECTORY_SEPARATOR . '.' . $name . '.php';
88 return file_exists($fullName) ? $fullName : '';