*/
namespace Friendica\Core;
-use Friendica\Core\Config\IConfigAdapter;
-use Friendica\Core\Config\IConfigCache;
-
/**
* @brief Arbitrary system configuration storage
*
class Config
{
/**
- * @var IConfigAdapter
+ * @var Config\IConfigAdapter
*/
private static $adapter;
/**
- * @var IConfigCache
+ * @var Config\IConfigCache
*/
private static $config;
/**
* Initialize the config with only the cache
*
- * @param IConfigCache $config The configuration cache
+ * @param Config\IConfigCache $config The configuration cache
*/
public static function init($config)
{
/**
* Add the adapter for DB-backend
*
- * @param $adapter
+ * @param Config\IConfigAdapter $adapter
*/
public static function setAdapter($adapter)
{
namespace Friendica\Core\Config;
+/**
+ * The Friendica config cache for the application
+ * Initial, all *.config.php files are loaded into this cache with the
+ * ConfigCacheLoader ( @see ConfigCacheLoader )
+ *
+ * Is used for further caching operations too (depending on the ConfigAdapter )
+ */
class ConfigCache implements IConfigCache, IPConfigCache
{
/**
*/
public $config;
- public function __construct($config = [], $overwrite = false)
+ /**
+ * @param array $config A initial config array
+ */
+ public function __construct($config = [])
{
$this->config = [];
if (isset($config)) {
- $this->loadConfigArray($config, $overwrite);
+ $this->loadConfigArray($config, true);
}
}
namespace Friendica\Core\Config;
+/**
+ * The ConfigCacheLoader loads config-files and stores them in a ConfigCache ( @see ConfigCache )
+ *
+ * It is capable of loading the following config files:
+ * - *.config.php (current)
+ * - *.ini.php (deprecated)
+ * - *.htconfig.php (deprecated)
+ */
class ConfigCacheLoader
{
+ /**
+ * The Sub directory of the config-files
+ * @var string
+ */
+ const SUBDIRECTORY = '/config/';
+
private $baseDir;
private $configDir;
public function __construct($baseDir)
{
$this->baseDir = $baseDir;
- $this->configDir = $baseDir . '/config/';
+ $this->configDir = $baseDir . self::SUBDIRECTORY;
}
/**
namespace Friendica\Core\Config;
+/**
+ * The interface for a system-wide ConfigCache
+ */
interface IConfigCache
{
/**
namespace Friendica\Core\Config;
+/**
+ * The interface for a user-specific config cache
+ */
interface IPConfigCache
{
/**
*/
namespace Friendica\Core;
-use Friendica\Core\Config\IPConfigCache;
-
/**
* @brief Management of user configuration storage
* Note:
class PConfig
{
/**
- * @var \Friendica\Core\Config\IPConfigAdapter
+ * @var Config\IPConfigAdapter
*/
private static $adapter;
/**
- * @var IPConfigCache
+ * @var Config\IPConfigCache
*/
private static $config;
/**
* Initialize the config with only the cache
*
- * @param IPConfigCache $config The configuration cache
+ * @param Config\IPConfigCache $config The configuration cache
*/
public static function init($config)
{
/**
* Add the adapter for DB-backend
*
- * @param $adapter
+ * @param Config\IPConfigAdapter $adapter
*/
public static function setAdapter($adapter)
{
* @param string $family The category of the configuration value
*
* @return void
- * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function load($uid, $family)
{
* @param string $key The configuration key to delete
*
* @return mixed
- * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/
public static function delete($uid, $family, $key)
{