* This class is responsible for the user-specific configuration values in Friendica
* The values are set through the Config-DB-Table (per Config-DB-adapter @see Adapter\IPConfigAdapter )
*
- * The configuration cache (@see Cache\IPConfigCache ) is used for temporary caching of database calls. This will
+ * The configuration cache (@see Cache\PConfigCache ) is used for temporary caching of database calls. This will
* increase the performance.
*/
class PConfiguration
* @brief Loads all configuration values of a user's config family into a cached storage.
*
* All configuration values of the given user are stored with the $uid in
- * the cache ( @see IPConfigCache )
+ * the cache ( @see PConfigCache )
*
* @param string $uid The user_id
* @param string $cat The category of the configuration value
*
* Get a particular user's config value from the given category ($cat)
* and the $key with the $uid from a cached storage either from the $this->configAdapter
- * (@see IConfigAdapter ) or from the $this->configCache (@see IConfigCache ).
+ * (@see IConfigAdapter ) or from the $this->configCache (@see PConfigCache ).
*
* @param string $uid The user_id
* @param string $cat The category of the configuration value
$this->logger = $logger;
}
+ /**
+ * Sets the profiler for DBA
+ *
+ * @param Profiler $profiler
+ */
+ public function setProfiler(Profiler $profiler)
+ {
+ $this->profiler = $profiler;
+ }
/**
* Disconnects the current database connection
*/
}
}
+ public function isConnected()
+ {
+ return $this->connected;
+ }
+
public function connected()
{
$connected = false;
use Friendica\Core\Config;
use Friendica\Core\Config\Adapter;
use Friendica\Core\Config\Cache;
+use Friendica\Model\Config\Config as ConfigModel;
use Friendica\Util\Config\ConfigFileLoader;
class ConfigFactory
}
/**
+ * @param Cache\ConfigCache $configCache The config cache of this adapter
+ * @param ConfigModel $configModel The configuration model
* @param Cache\ConfigCache $configCache The config cache
*
* @return Config\Configuration
*/
- public static function createConfig(Cache\ConfigCache $configCache)
+ public static function createConfig(Cache\ConfigCache $configCache, ConfigModel $configModel)
{
if ($configCache->get('system', 'config_adapter') === 'preload') {
- $configAdapter = new Adapter\PreloadConfigAdapter();
+ $configuration = new Config\PreloadConfiguration($configCache, $configModel);
} else {
- $configAdapter = new Adapter\JITConfigAdapter();
+ $configuration = new Config\JitConfiguration($configCache, $configModel);
}
- $configuration = new Config\Configuration($configCache, $configAdapter);
// Set the config in the static container for legacy usage
Core\Config::init($configuration);
use Friendica\Util\BasePath;
use Friendica\Util\BaseURL;
use Friendica\Util\Config;
+use Psr\Log\NullLogger;
class DependencyFactory
{
$configCache = Factory\ConfigFactory::createCache($configLoader);
$profiler = Factory\ProfilerFactory::create($configCache);
$database = Factory\DBFactory::init($configCache, $profiler, $_SERVER);
- $config = Factory\ConfigFactory::createConfig($configCache);
+ $configModel = new \Friendica\Model\Config\Config($database);
+ $config = Factory\ConfigFactory::createConfig($configCache, $configModel);
// needed to call PConfig::init()
Factory\ConfigFactory::createPConfig($configCache, new PConfigCache());
$logger = Factory\LoggerFactory::create($channel, $database, $config, $profiler);
public function mockApp(vfsStreamDirectory $root, $raw = false)
{
$this->configMock = \Mockery::mock(Config\Cache\ConfigCache::class);
+ $this->configMock->shouldReceive('getAll')->andReturn([])->once();
$this->mode = \Mockery::mock(App\Mode::class);
- $configAdapterMock = \Mockery::mock(Config\Adapter\IConfigAdapter::class);
+ $configModel= \Mockery::mock(\Friendica\Model\Config\Config::class);
// Disable the adapter
- $configAdapterMock->shouldReceive('isConnected')->andReturn(false);
+ $configModel->shouldReceive('isConnected')->andReturn(false);
- $config = new Config\Configuration($this->configMock, $configAdapterMock);
+ $config = new Config\JitConfiguration($this->configMock, $configModel);
// Initialize empty Config
Config::init($config);