use Friendica\Model\Storage\IStorage;
-use Friendica\Core\Config\IConfiguration;
+use Friendica\Core\Config\IConfig;
use Friendica\Core\L10n;
class SampleStorageBackend implements IStorage
{
const NAME = 'Sample Storage';
- /** @var IConfiguration */
+ /** @var IConfig */
private $config;
/** @var L10n */
private $l10n;
/**
* SampleStorageBackend constructor.
- * @param IConfiguration $config The configuration of Friendica
+ * @param IConfig $config The configuration of Friendica
*
* You can add here every dynamic class as dependency you like and add them to a private field
* Friendica automatically creates these classes and passes them as argument to the constructor
*/
- public function __construct(IConfiguration $config, L10n $l10n)
+ public function __construct(IConfig $config, L10n $l10n)
{
$this->config = $config;
$this->l10n = $l10n;
use Friendica\App\BaseURL;
use Friendica\App\Authentication;
use Friendica\Core\Config\Cache\ConfigCache;
-use Friendica\Core\Config\IConfiguration;
+use Friendica\Core\Config\IConfig;
use Friendica\Core\Config\IPConfiguration;
use Friendica\Core\L10n;
use Friendica\Core\System;
private $currentMobileTheme;
/**
- * @var IConfiguration The config
+ * @var IConfig The config
*/
private $config;
/**
* @param Database $database The Friendica Database
- * @param IConfiguration $config The Configuration
+ * @param IConfig $config The Configuration
* @param App\Mode $mode The mode of this Friendica app
* @param BaseURL $baseURL The full base URL of this Friendica app
* @param LoggerInterface $logger The current app logger
* @param Core\Process $process The process methods
* @param IPConfiguration $pConfig Personal configuration
*/
- public function __construct(Database $database, IConfiguration $config, App\Mode $mode, BaseURL $baseURL, LoggerInterface $logger, Profiler $profiler, L10n $l10n, Arguments $args, Core\Process $process, IPConfiguration $pConfig)
+ public function __construct(Database $database, IConfig $config, App\Mode $mode, BaseURL $baseURL, LoggerInterface $logger, Profiler $profiler, L10n $l10n, Arguments $args, Core\Process $process, IPConfiguration $pConfig)
{
$this->database = $database;
$this->config = $config;
use Exception;
use Friendica\App;
-use Friendica\Core\Config\IConfiguration;
+use Friendica\Core\Config\IConfig;
use Friendica\Core\Config\IPConfiguration;
use Friendica\Core\Hook;
use Friendica\Core\Session;
*/
class Authentication
{
- /** @var IConfiguration */
+ /** @var IConfig */
private $config;
/** @var App\Mode */
private $mode;
/**
* Authentication constructor.
*
- * @param IConfiguration $config
- * @param App\Mode $mode
- * @param App\BaseURL $baseUrl
- * @param L10n $l10n
- * @param Database $dba
- * @param LoggerInterface $logger
- * @param User\Cookie $cookie
+ * @param IConfig $config
+ * @param App\Mode $mode
+ * @param App\BaseURL $baseUrl
+ * @param L10n $l10n
+ * @param Database $dba
+ * @param LoggerInterface $logger
+ * @param User\Cookie $cookie
* @param Session\ISession $session
* @param IPConfiguration $pConfig
*/
- public function __construct(IConfiguration $config, App\Mode $mode, App\BaseURL $baseUrl, L10n $l10n, Database $dba, LoggerInterface $logger, User\Cookie $cookie, Session\ISession $session, IPConfiguration $pConfig)
+ public function __construct(IConfig $config, App\Mode $mode, App\BaseURL $baseUrl, L10n $l10n, Database $dba, LoggerInterface $logger, User\Cookie $cookie, Session\ISession $session, IPConfiguration $pConfig)
{
$this->config = $config;
$this->mode = $mode;
namespace Friendica\App;
-use Friendica\Core\Config\IConfiguration;
+use Friendica\Core\Config\IConfig;
use Friendica\Core\System;
use Friendica\Util\Network;
use Friendica\Util\Strings;
/**
* The Friendica Config
*
- * @var IConfiguration
+ * @var IConfig
*/
private $config;
}
/**
- * @param IConfiguration $config The Friendica IConfiguration
- * @param array $server The $_SERVER array
+ * @param IConfig $config The Friendica IConfiguration
+ * @param array $server The $_SERVER array
*/
- public function __construct(IConfiguration $config, array $server)
+ public function __construct(IConfig $config, array $server)
{
$this->config = $config;
$this->server = $server;
/**
* Determine the class of the current module
*
- * @param Arguments $args The Friendica execution arguments
- * @param Router $router The Friendica routing instance
- * @param Core\Config\IConfiguration $config The Friendica Configuration
+ * @param Arguments $args The Friendica execution arguments
+ * @param Router $router The Friendica routing instance
+ * @param Core\Config\IConfig $config The Friendica Configuration
*
* @return Module The determined module of this call
*
* @throws \Exception
*/
- public function determineClass(Arguments $args, Router $router, Core\Config\IConfiguration $config)
+ public function determineClass(Arguments $args, Router $router, Core\Config\IConfig $config)
{
$printNotAllowedAddon = false;
use DOMXPath;
use Friendica\App;
use Friendica\Content\Nav;
-use Friendica\Core\Config\IConfiguration;
+use Friendica\Core\Config\IConfig;
use Friendica\Core\Config\IPConfiguration;
use Friendica\Core\Hook;
use Friendica\Core\L10n;
* - Infinite scroll data
* - head.tpl template
*
- * @param App $app The Friendica App instance
- * @param Module $module The loaded Friendica module
- * @param L10n $l10n The l10n language instance
- * @param IConfiguration $config The Friendica configuration
+ * @param App $app The Friendica App instance
+ * @param Module $module The loaded Friendica module
+ * @param L10n $l10n The l10n language instance
+ * @param IConfig $config The Friendica configuration
* @param IPConfiguration $pConfig The Friendica personal configuration (for user)
*
* @throws HTTPException\InternalServerErrorException
*/
- private function initHead(App $app, Module $module, L10n $l10n, IConfiguration $config, IPConfiguration $pConfig)
+ private function initHead(App $app, Module $module, L10n $l10n, IConfig $config, IPConfiguration $pConfig)
{
$interval = ((local_user()) ? $pConfig->get(local_user(), 'system', 'update_interval') : 40000);
/**
* Executes the creation of the current page and prints it to the screen
*
- * @param App $app The Friendica App
- * @param BaseURL $baseURL The Friendica Base URL
- * @param Mode $mode The current node mode
- * @param Module $module The loaded Friendica module
- * @param L10n $l10n The l10n language class
- * @param IConfiguration $config The Configuration of this node
+ * @param App $app The Friendica App
+ * @param BaseURL $baseURL The Friendica Base URL
+ * @param Mode $mode The current node mode
+ * @param Module $module The loaded Friendica module
+ * @param L10n $l10n The l10n language class
+ * @param IConfig $config The Configuration of this node
* @param IPConfiguration $pconfig The personal/user configuration
*
* @throws HTTPException\InternalServerErrorException
*/
- public function run(App $app, BaseURL $baseURL, Mode $mode, Module $module, L10n $l10n, IConfiguration $config, IPConfiguration $pconfig)
+ public function run(App $app, BaseURL $baseURL, Mode $mode, Module $module, L10n $l10n, IConfig $config, IPConfiguration $pconfig)
{
$moduleName = $module->getName();
private $configCache;
/**
- * @var Config\IConfiguration
+ * @var Config\IConfig
*/
private $config;
HELP;
}
- public function __construct(App\Mode $appMode, Config\Cache\ConfigCache $configCache, Config\IConfiguration $config, Database $dba, array $argv = null)
+ public function __construct(App\Mode $appMode, Config\Cache\ConfigCache $configCache, Config\IConfig $config, Database $dba, array $argv = null)
{
parent::__construct($argv);
use Asika\SimpleConsole\CommandArgsException;
use Friendica\App;
-use Friendica\Core\Config\IConfiguration;
+use Friendica\Core\Config\IConfig;
use RuntimeException;
/**
*/
private $appMode;
/**
- * @var IConfiguration
+ * @var IConfig
*/
private $config;
return $help;
}
- public function __construct(App\Mode $appMode, IConfiguration $config, array $argv = null)
+ public function __construct(App\Mode $appMode, IConfig $config, array $argv = null)
{
parent::__construct($argv);
namespace Friendica\Console;
use Friendica\App;
-use Friendica\Core\Config\IConfiguration;
+use Friendica\Core\Config\IConfig;
/**
* Sets maintenance mode for this node
*/
private $appMode;
/**
- * @var IConfiguration
+ * @var IConfig
*/
private $config;
return $help;
}
- public function __construct(App\Mode $appMode, IConfiguration $config, $argv = null)
+ public function __construct(App\Mode $appMode, IConfig $config, $argv = null)
{
parent::__construct($argv);
namespace Friendica\Console;
use Friendica\App;
-use Friendica\Core\Config\IConfiguration;
+use Friendica\Core\Config\IConfig;
use Friendica\Core\L10n;
use Friendica\Core\Update;
*/
private $appMode;
/**
- * @var IConfiguration
+ * @var IConfig
*/
private $config;
/**
return $help;
}
- public function __construct(App\Mode $appMode, IConfiguration $config, L10n $l10n, array $argv = null)
+ public function __construct(App\Mode $appMode, IConfig $config, L10n $l10n, array $argv = null)
{
parent::__construct($argv);
use Asika\SimpleConsole\CommandArgsException;
use Asika\SimpleConsole\Console;
use Console_Table;
-use Friendica\Core\Config\IConfiguration;
+use Friendica\Core\Config\IConfig;
/**
* Manage blocked servers
protected $helpOptions = ['h', 'help', '?'];
/**
- * @var IConfiguration
+ * @var IConfig
*/
private $config;
return $help;
}
- public function __construct(IConfiguration $config, $argv = null)
+ public function __construct(IConfig $config, $argv = null)
{
parent::__construct($argv);
/**
* Prints the whole list of blocked domains including the reason
*
- * @param IConfiguration $config
+ * @param IConfig $config
*/
- private function printBlockedServers(IConfiguration $config)
+ private function printBlockedServers(IConfig $config)
{
$table = new Console_Table();
$table->setHeaders(['Domain', 'Reason']);
/**
* Adds a server to the blocked list
*
- * @param IConfiguration $config
+ * @param IConfig $config
*
* @return int The return code (0 = success, 1 = failed)
*/
- private function addBlockedServer(IConfiguration $config)
+ private function addBlockedServer(IConfig $config)
{
if (count($this->args) < 2 || count($this->args) > 3) {
throw new CommandArgsException('Add needs a domain and optional a reason.');
/**
* Removes a server from the blocked list
*
- * @param IConfiguration $config
+ * @param IConfig $config
*
* @return int The return code (0 = success, 1 = failed)
*/
- private function removeBlockedServer(IConfiguration $config)
+ private function removeBlockedServer(IConfig $config)
{
if (count($this->args) !== 2) {
throw new CommandArgsException('Remove needs a second parameter.');
namespace Friendica\Console;
-use Friendica\Core\Config\IConfiguration;
+use Friendica\Core\Config\IConfig;
/**
* Tired of chasing typos and finding them after a commit.
protected $helpOptions = ['h', 'help', '?'];
/**
- * @var IConfiguration
+ * @var IConfig
*/
private $config;
return $help;
}
- public function __construct(IConfiguration $config, array $argv = null)
+ public function __construct(IConfig $config, array $argv = null)
{
parent::__construct($argv);
--- /dev/null
+<?php
+
+namespace Friendica\Core;
+
+use Friendica\Core\Config\Cache;
+use Friendica\Core\Config\IConfig;
+use Friendica\Model;
+
+/**
+ * This class is responsible for all system-wide configuration values in Friendica
+ * There are two types of storage
+ * - The Config-Files (loaded into the FileCache @see Cache\ConfigCache)
+ * - The Config-DB-Table (per Config-DB-model @see Model\Config\Config)
+ */
+abstract class BaseConfig implements IConfig
+{
+ /**
+ * @var Cache\ConfigCache
+ */
+ protected $configCache;
+
+ /**
+ * @var Model\Config\Config
+ */
+ protected $configModel;
+
+ /**
+ * @param Cache\ConfigCache $configCache The configuration cache (based on the config-files)
+ * @param Model\Config\Config $configModel The configuration model
+ */
+ public function __construct(Cache\ConfigCache $configCache, Model\Config\Config $configModel)
+ {
+ $this->configCache = $configCache;
+ $this->configModel = $configModel;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getCache()
+ {
+ return $this->configCache;
+ }
+}
use Exception;
use Friendica\Core\BaseCache;
-use Friendica\Core\Config\IConfiguration;
+use Friendica\Core\Config\IConfig;
use Memcache;
/**
/**
* @throws Exception
*/
- public function __construct(string $hostname, IConfiguration $config)
+ public function __construct(string $hostname, IConfig $config)
{
if (!class_exists('Memcache', false)) {
throw new Exception('Memcache class isn\'t available');
use Exception;
use Friendica\Core\BaseCache;
-use Friendica\Core\Config\IConfiguration;
+use Friendica\Core\Config\IConfig;
use Memcached;
use Psr\Log\LoggerInterface;
*
* @throws \Exception
*/
- public function __construct(string $hostname, IConfiguration $config, LoggerInterface $logger)
+ public function __construct(string $hostname, IConfig $config, LoggerInterface $logger)
{
if (!class_exists('Memcached', false)) {
throw new Exception('Memcached class isn\'t available');
use Exception;
use Friendica\Core\BaseCache;
-use Friendica\Core\Config\IConfiguration;
+use Friendica\Core\Config\IConfig;
use Redis;
/**
/**
* @throws Exception
*/
- public function __construct(string $hostname, IConfiguration $config)
+ public function __construct(string $hostname, IConfig $config)
{
if (!class_exists('Redis', false)) {
throw new Exception('Redis class isn\'t available');
+++ /dev/null
-<?php
-
-namespace Friendica\Core\Config;
-
-use Friendica\Model;
-
-/**
- * This class is responsible for all system-wide configuration values in Friendica
- * There are two types of storage
- * - The Config-Files (loaded into the FileCache @see Cache\ConfigCache)
- * - The Config-DB-Table (per Config-DB-model @see Model\Config\Config)
- */
-abstract class Configuration implements IConfiguration
-{
- /**
- * @var Cache\ConfigCache
- */
- protected $configCache;
-
- /**
- * @var Model\Config\Config
- */
- protected $configModel;
-
- /**
- * @param Cache\ConfigCache $configCache The configuration cache (based on the config-files)
- * @param Model\Config\Config $configModel The configuration model
- */
- public function __construct(Cache\ConfigCache $configCache, Model\Config\Config $configModel)
- {
- $this->configCache = $configCache;
- $this->configModel = $configModel;
- }
-
- /**
- * {@inheritDoc}
- */
- public function getCache()
- {
- return $this->configCache;
- }
-}
--- /dev/null
+<?php
+
+namespace Friendica\Core\Config;
+
+/**
+ * Interface for accessing system wide configurations
+ */
+interface IConfig
+{
+
+ /**
+ * Loads all configuration values of family into a cached storage.
+ *
+ * All configuration values of the system are stored in the cache ( @see ConfigCache )
+ *
+ * @param string $cat The category of the configuration value
+ *
+ * @return void
+ */
+ function load(string $cat = 'config');
+
+ /**
+ * Get a particular user's config variable given the category name
+ * ($cat) and a $key.
+ *
+ * Get a particular config value from the given category ($cat)
+ * and the $key from a cached storage either from the $this->configAdapter
+ * (@see IConfigAdapter) or from the $this->configCache (@see ConfigCache).
+ *
+ * @param string $cat The category of the configuration value
+ * @param string $key The configuration key to query
+ * @param mixed $default_value optional, The value to return if key is not set (default: null)
+ * @param boolean $refresh optional, If true the config is loaded from the db and not from the cache (default: false)
+ *
+ * @return mixed Stored value or null if it does not exist
+ */
+ function get(string $cat, string $key, $default_value = null, bool $refresh = false);
+
+ /**
+ * Sets a configuration value for system config
+ *
+ * Stores a config value ($value) in the category ($cat) under the key ($key)
+ *
+ * Note: Please do not store booleans - convert to 0/1 integer values!
+ *
+ * @param string $cat The category of the configuration value
+ * @param string $key The configuration key to set
+ * @param mixed $value The value to store
+ *
+ * @return bool Operation success
+ */
+ function set(string $cat, string $key, $value);
+
+ /**
+ * Deletes the given key from the system configuration.
+ *
+ * Removes the configured value from the stored cache in $this->configCache
+ * (@see ConfigCache) and removes it from the database (@see IConfigAdapter).
+ *
+ * @param string $cat The category of the configuration value
+ * @param string $key The configuration key to delete
+ *
+ * @return bool
+ */
+ function delete(string $cat, string $key);
+
+ /**
+ * Returns the Config Cache
+ *
+ * @return Cache\ConfigCache
+ */
+ function getCache();
+}
+++ /dev/null
-<?php
-
-namespace Friendica\Core\Config;
-
-/**
- * Interface for accessing system wide configurations
- */
-interface IConfiguration
-{
-
- /**
- * Loads all configuration values of family into a cached storage.
- *
- * All configuration values of the system are stored in the cache ( @see ConfigCache )
- *
- * @param string $cat The category of the configuration value
- *
- * @return void
- */
- function load(string $cat = 'config');
-
- /**
- * Get a particular user's config variable given the category name
- * ($cat) and a $key.
- *
- * Get a particular config value from the given category ($cat)
- * and the $key from a cached storage either from the $this->configAdapter
- * (@see IConfigAdapter) or from the $this->configCache (@see ConfigCache).
- *
- * @param string $cat The category of the configuration value
- * @param string $key The configuration key to query
- * @param mixed $default_value optional, The value to return if key is not set (default: null)
- * @param boolean $refresh optional, If true the config is loaded from the db and not from the cache (default: false)
- *
- * @return mixed Stored value or null if it does not exist
- */
- function get(string $cat, string $key, $default_value = null, bool $refresh = false);
-
- /**
- * Sets a configuration value for system config
- *
- * Stores a config value ($value) in the category ($cat) under the key ($key)
- *
- * Note: Please do not store booleans - convert to 0/1 integer values!
- *
- * @param string $cat The category of the configuration value
- * @param string $key The configuration key to set
- * @param mixed $value The value to store
- *
- * @return bool Operation success
- */
- function set(string $cat, string $key, $value);
-
- /**
- * Deletes the given key from the system configuration.
- *
- * Removes the configured value from the stored cache in $this->configCache
- * (@see ConfigCache) and removes it from the database (@see IConfigAdapter).
- *
- * @param string $cat The category of the configuration value
- * @param string $key The configuration key to delete
- *
- * @return bool
- */
- function delete(string $cat, string $key);
-
- /**
- * Returns the Config Cache
- *
- * @return Cache\ConfigCache
- */
- function getCache();
-}
--- /dev/null
+<?php
+
+namespace Friendica\Core\Config;
+
+use Friendica\Core\BaseConfig;
+use Friendica\Model;
+
+/**
+ * This class implements the Just-In-Time configuration, which will cache
+ * config values in a cache, once they are retrieved.
+ *
+ * Default Configuration type.
+ * Provides the best performance for pages loading few configuration variables.
+ */
+class JitConfig extends BaseConfig
+{
+ /**
+ * @var array Array of already loaded db values (even if there was no value)
+ */
+ private $db_loaded;
+
+ /**
+ * @param Cache\ConfigCache $configCache The configuration cache (based on the config-files)
+ * @param Model\Config\Config $configModel The configuration model
+ */
+ public function __construct(Cache\ConfigCache $configCache, Model\Config\Config $configModel)
+ {
+ parent::__construct($configCache, $configModel);
+ $this->db_loaded = [];
+
+ $this->load();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ */
+ public function load(string $cat = 'config')
+ {
+ // If not connected, do nothing
+ if (!$this->configModel->isConnected()) {
+ return;
+ }
+
+ $config = $this->configModel->load($cat);
+
+ if (!empty($config[$cat])) {
+ foreach ($config[$cat] as $key => $value) {
+ $this->db_loaded[$cat][$key] = true;
+ }
+ }
+
+ // load the whole category out of the DB into the cache
+ $this->configCache->load($config, true);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function get(string $cat, string $key, $default_value = null, bool $refresh = false)
+ {
+ // if the value isn't loaded or refresh is needed, load it to the cache
+ if ($this->configModel->isConnected() &&
+ (empty($this->db_loaded[$cat][$key]) ||
+ $refresh)) {
+
+ $dbvalue = $this->configModel->get($cat, $key);
+
+ if (isset($dbvalue)) {
+ $this->configCache->set($cat, $key, $dbvalue);
+ unset($dbvalue);
+ }
+
+ $this->db_loaded[$cat][$key] = true;
+ }
+
+ // use the config cache for return
+ $result = $this->configCache->get($cat, $key);
+
+ return (isset($result)) ? $result : $default_value;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function set(string $cat, string $key, $value)
+ {
+ // set the cache first
+ $cached = $this->configCache->set($cat, $key, $value);
+
+ // If there is no connected adapter, we're finished
+ if (!$this->configModel->isConnected()) {
+ return $cached;
+ }
+
+ $stored = $this->configModel->set($cat, $key, $value);
+
+ $this->db_loaded[$cat][$key] = $stored;
+
+ return $cached && $stored;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function delete(string $cat, string $key)
+ {
+ $cacheRemoved = $this->configCache->delete($cat, $key);
+
+ if (isset($this->db_loaded[$cat][$key])) {
+ unset($this->db_loaded[$cat][$key]);
+ }
+
+ if (!$this->configModel->isConnected()) {
+ return $cacheRemoved;
+ }
+
+ $storeRemoved = $this->configModel->delete($cat, $key);
+
+ return $cacheRemoved || $storeRemoved;
+ }
+}
+++ /dev/null
-<?php
-
-namespace Friendica\Core\Config;
-
-use Friendica\Model;
-
-/**
- * This class implements the Just-In-Time configuration, which will cache
- * config values in a cache, once they are retrieved.
- *
- * Default Configuration type.
- * Provides the best performance for pages loading few configuration variables.
- */
-class JitConfiguration extends Configuration
-{
- /**
- * @var array Array of already loaded db values (even if there was no value)
- */
- private $db_loaded;
-
- /**
- * @param Cache\ConfigCache $configCache The configuration cache (based on the config-files)
- * @param Model\Config\Config $configModel The configuration model
- */
- public function __construct(Cache\ConfigCache $configCache, Model\Config\Config $configModel)
- {
- parent::__construct($configCache, $configModel);
- $this->db_loaded = [];
-
- $this->load();
- }
-
- /**
- * {@inheritDoc}
- *
- */
- public function load(string $cat = 'config')
- {
- // If not connected, do nothing
- if (!$this->configModel->isConnected()) {
- return;
- }
-
- $config = $this->configModel->load($cat);
-
- if (!empty($config[$cat])) {
- foreach ($config[$cat] as $key => $value) {
- $this->db_loaded[$cat][$key] = true;
- }
- }
-
- // load the whole category out of the DB into the cache
- $this->configCache->load($config, true);
- }
-
- /**
- * {@inheritDoc}
- */
- public function get(string $cat, string $key, $default_value = null, bool $refresh = false)
- {
- // if the value isn't loaded or refresh is needed, load it to the cache
- if ($this->configModel->isConnected() &&
- (empty($this->db_loaded[$cat][$key]) ||
- $refresh)) {
-
- $dbvalue = $this->configModel->get($cat, $key);
-
- if (isset($dbvalue)) {
- $this->configCache->set($cat, $key, $dbvalue);
- unset($dbvalue);
- }
-
- $this->db_loaded[$cat][$key] = true;
- }
-
- // use the config cache for return
- $result = $this->configCache->get($cat, $key);
-
- return (isset($result)) ? $result : $default_value;
- }
-
- /**
- * {@inheritDoc}
- */
- public function set(string $cat, string $key, $value)
- {
- // set the cache first
- $cached = $this->configCache->set($cat, $key, $value);
-
- // If there is no connected adapter, we're finished
- if (!$this->configModel->isConnected()) {
- return $cached;
- }
-
- $stored = $this->configModel->set($cat, $key, $value);
-
- $this->db_loaded[$cat][$key] = $stored;
-
- return $cached && $stored;
- }
-
- /**
- * {@inheritDoc}
- */
- public function delete(string $cat, string $key)
- {
- $cacheRemoved = $this->configCache->delete($cat, $key);
-
- if (isset($this->db_loaded[$cat][$key])) {
- unset($this->db_loaded[$cat][$key]);
- }
-
- if (!$this->configModel->isConnected()) {
- return $cacheRemoved;
- }
-
- $storeRemoved = $this->configModel->delete($cat, $key);
-
- return $cacheRemoved || $storeRemoved;
- }
-}
--- /dev/null
+<?php
+
+namespace Friendica\Core\Config;
+
+use Friendica\Core\BaseConfig;
+use Friendica\Model;
+
+/**
+ * This class implements the preload configuration, which will cache
+ * all config values per call in a cache.
+ *
+ * Minimizes the number of database queries to retrieve configuration values at the cost of memory.
+ */
+class PreloadConfig extends BaseConfig
+{
+ /** @var bool */
+ private $config_loaded;
+
+ /**
+ * @param Cache\ConfigCache $configCache The configuration cache (based on the config-files)
+ * @param Model\Config\Config $configModel The configuration model
+ */
+ public function __construct(Cache\ConfigCache $configCache, Model\Config\Config $configModel)
+ {
+ parent::__construct($configCache, $configModel);
+ $this->config_loaded = false;
+
+ $this->load();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * This loads all config values everytime load is called
+ *
+ */
+ public function load(string $cat = 'config')
+ {
+ // Don't load the whole configuration twice
+ if ($this->config_loaded) {
+ return;
+ }
+
+ // If not connected, do nothing
+ if (!$this->configModel->isConnected()) {
+ return;
+ }
+
+ $config = $this->configModel->load();
+ $this->config_loaded = true;
+
+ // load the whole category out of the DB into the cache
+ $this->configCache->load($config, true);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function get(string $cat, string $key, $default_value = null, bool $refresh = false)
+ {
+ if ($refresh) {
+ if ($this->configModel->isConnected()) {
+ $config = $this->configModel->get($cat, $key);
+ if (isset($config)) {
+ $this->configCache->set($cat, $key, $config);
+ }
+ }
+ }
+
+ // use the config cache for return
+ $result = $this->configCache->get($cat, $key);
+
+ return (isset($result)) ? $result : $default_value;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function set(string $cat, string $key, $value)
+ {
+ if (!$this->config_loaded) {
+ $this->load();
+ }
+
+ // set the cache first
+ $cached = $this->configCache->set($cat, $key, $value);
+
+ // If there is no connected adapter, we're finished
+ if (!$this->configModel->isConnected()) {
+ return $cached;
+ }
+
+ $stored = $this->configModel->set($cat, $key, $value);
+
+ return $cached && $stored;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function delete(string $cat, string $key)
+ {
+ if ($this->config_loaded) {
+ $this->load();
+ }
+
+ $cacheRemoved = $this->configCache->delete($cat, $key);
+
+ if (!$this->configModel->isConnected()) {
+ return $cacheRemoved;
+ }
+
+ $storeRemoved = $this->configModel->delete($cat, $key);
+
+ return $cacheRemoved || $storeRemoved;
+ }
+}
+++ /dev/null
-<?php
-
-namespace Friendica\Core\Config;
-
-use Friendica\Model;
-
-/**
- * This class implements the preload configuration, which will cache
- * all config values per call in a cache.
- *
- * Minimizes the number of database queries to retrieve configuration values at the cost of memory.
- */
-class PreloadConfiguration extends Configuration
-{
- /** @var bool */
- private $config_loaded;
-
- /**
- * @param Cache\ConfigCache $configCache The configuration cache (based on the config-files)
- * @param Model\Config\Config $configModel The configuration model
- */
- public function __construct(Cache\ConfigCache $configCache, Model\Config\Config $configModel)
- {
- parent::__construct($configCache, $configModel);
- $this->config_loaded = false;
-
- $this->load();
- }
-
- /**
- * {@inheritDoc}
- *
- * This loads all config values everytime load is called
- *
- */
- public function load(string $cat = 'config')
- {
- // Don't load the whole configuration twice
- if ($this->config_loaded) {
- return;
- }
-
- // If not connected, do nothing
- if (!$this->configModel->isConnected()) {
- return;
- }
-
- $config = $this->configModel->load();
- $this->config_loaded = true;
-
- // load the whole category out of the DB into the cache
- $this->configCache->load($config, true);
- }
-
- /**
- * {@inheritDoc}
- */
- public function get(string $cat, string $key, $default_value = null, bool $refresh = false)
- {
- if ($refresh) {
- if ($this->configModel->isConnected()) {
- $config = $this->configModel->get($cat, $key);
- if (isset($config)) {
- $this->configCache->set($cat, $key, $config);
- }
- }
- }
-
- // use the config cache for return
- $result = $this->configCache->get($cat, $key);
-
- return (isset($result)) ? $result : $default_value;
- }
-
- /**
- * {@inheritDoc}
- */
- public function set(string $cat, string $key, $value)
- {
- if (!$this->config_loaded) {
- $this->load();
- }
-
- // set the cache first
- $cached = $this->configCache->set($cat, $key, $value);
-
- // If there is no connected adapter, we're finished
- if (!$this->configModel->isConnected()) {
- return $cached;
- }
-
- $stored = $this->configModel->set($cat, $key, $value);
-
- return $cached && $stored;
- }
-
- /**
- * {@inheritDoc}
- */
- public function delete(string $cat, string $key)
- {
- if ($this->config_loaded) {
- $this->load();
- }
-
- $cacheRemoved = $this->configCache->delete($cat, $key);
-
- if (!$this->configModel->isConnected()) {
- return $cacheRemoved;
- }
-
- $storeRemoved = $this->configModel->delete($cat, $key);
-
- return $cacheRemoved || $storeRemoved;
- }
-}
namespace Friendica\Core;
-use Friendica\Core\Config\IConfiguration;
+use Friendica\Core\Config\IConfig;
use Friendica\Core\Session\ISession;
use Friendica\Database\Database;
use Friendica\Util\Strings;
*/
private $logger;
- public function __construct(IConfiguration $config, Database $dba, LoggerInterface $logger, ISession $session, array $server, array $get)
+ public function __construct(IConfig $config, Database $dba, LoggerInterface $logger, ISession $session, array $server, array $get)
{
$this->dba = $dba;
$this->logger = $logger;
namespace Friendica\Core;
use Friendica\App;
-use Friendica\Core\Config\IConfiguration;
+use Friendica\Core\Config\IConfig;
use Psr\Log\LoggerInterface;
/**
private $mode;
/**
- * @var IConfiguration
+ * @var IConfig
*/
private $config;
*/
private $basePath;
- public function __construct(LoggerInterface $logger, App\Mode $mode, IConfiguration $config, string $basepath)
+ public function __construct(LoggerInterface $logger, App\Mode $mode, IConfig $config, string $basepath)
{
$this->logger = $logger;
$this->mode = $mode;
namespace Friendica\Core;
use Exception;
-use Friendica\Core\Config\IConfiguration;
+use Friendica\Core\Config\IConfig;
use Friendica\Database\Database;
use Friendica\Model\Storage;
use Psr\Log\LoggerInterface;
/** @var Database */
private $dba;
- /** @var IConfiguration */
+ /** @var IConfig */
private $config;
/** @var LoggerInterface */
private $logger;
/**
* @param Database $dba
- * @param IConfiguration $config
+ * @param IConfig $config
* @param LoggerInterface $logger
* @param L10n $l10n
*/
- public function __construct(Database $dba, IConfiguration $config, LoggerInterface $logger, L10n $l10n)
+ public function __construct(Database $dba, IConfig $config, LoggerInterface $logger, L10n $l10n)
{
$this->dba = $dba;
$this->config = $config;
}
/**
- * @return Core\Config\IConfiguration
+ * @return Core\Config\IConfig
*/
public static function config()
{
- return self::$dice->create(Core\Config\IConfiguration::class);
+ return self::$dice->create(Core\Config\IConfig::class);
}
/**
use Friendica\App\BaseURL;
use Friendica\Core\Cache;
use Friendica\Core\Cache\ICache;
-use Friendica\Core\Config\IConfiguration;
+use Friendica\Core\Config\IConfig;
use Friendica\Database\Database;
use Friendica\Util\Profiler;
use Psr\Log\LoggerInterface;
const DEFAULT_TYPE = Cache\Type::DATABASE;
/**
- * @var IConfiguration The IConfiguration to read parameters out of the config
+ * @var IConfig The IConfiguration to read parameters out of the config
*/
private $config;
*/
private $logger;
- public function __construct(BaseURL $baseURL, IConfiguration $config, Database $dba, Profiler $profiler, LoggerInterface $logger)
+ public function __construct(BaseURL $baseURL, IConfig $config, Database $dba, Profiler $profiler, LoggerInterface $logger)
{
$this->hostname = $baseURL->getHostname();
$this->config = $config;
* @param Cache\ConfigCache $configCache The config cache of this adapter
* @param ConfigModel $configModel The configuration model
*
- * @return Config\IConfiguration
+ * @return Config\IConfig
*/
public function createConfig(Cache\ConfigCache $configCache, ConfigModel $configModel)
{
if ($configCache->get('system', 'config_adapter') === 'preload') {
- $configuration = new Config\PreloadConfiguration($configCache, $configModel);
+ $configuration = new Config\PreloadConfig($configCache, $configModel);
} else {
- $configuration = new Config\JitConfiguration($configCache, $configModel);
+ $configuration = new Config\JitConfig($configCache, $configModel);
}
use Friendica\Core\Cache\IMemoryCache;
use Friendica\Core\Cache\Type;
-use Friendica\Core\Config\IConfiguration;
+use Friendica\Core\Config\IConfig;
use Friendica\Core\Lock;
use Friendica\Database\Database;
use Psr\Log\LoggerInterface;
const DEFAULT_DRIVER = 'default';
/**
- * @var IConfiguration The configuration to read parameters out of the config
+ * @var IConfig The configuration to read parameters out of the config
*/
private $config;
*/
private $logger;
- public function __construct(CacheFactory $cacheFactory, IConfiguration $config, Database $dba, LoggerInterface $logger)
+ public function __construct(CacheFactory $cacheFactory, IConfig $config, Database $dba, LoggerInterface $logger)
{
$this->cacheFactory = $cacheFactory;
$this->config = $config;
namespace Friendica\Factory;
-use Friendica\Core\Config\IConfiguration;
+use Friendica\Core\Config\IConfig;
use Friendica\Core\Logger;
use Friendica\Database\Database;
use Friendica\Network\HTTPException\InternalServerErrorException;
/**
* Creates a new PSR-3 compliant logger instances
*
- * @param Database $database The Friendica Database instance
- * @param IConfiguration $config The config
- * @param Profiler $profiler The profiler of the app
- * @param FileSystem $fileSystem FileSystem utils
+ * @param Database $database The Friendica Database instance
+ * @param IConfig $config The config
+ * @param Profiler $profiler The profiler of the app
+ * @param FileSystem $fileSystem FileSystem utils
*
* @return LoggerInterface The PSR-3 compliant logger instance
*/
- public function create(Database $database, IConfiguration $config, Profiler $profiler, FileSystem $fileSystem)
+ public function create(Database $database, IConfig $config, Profiler $profiler, FileSystem $fileSystem)
{
if (empty($config->get('system', 'debugging', false))) {
$logger = new VoidLogger();
*
* It should never get filled during normal usage of Friendica
*
- * @param IConfiguration $config The config
- * @param Profiler $profiler The profiler of the app
- * @param FileSystem $fileSystem FileSystem utils
+ * @param IConfig $config The config
+ * @param Profiler $profiler The profiler of the app
+ * @param FileSystem $fileSystem FileSystem utils
*
* @return LoggerInterface The PSR-3 compliant logger instance
*
* @throws InternalServerErrorException
* @throws \Exception
*/
- public static function createDev(IConfiguration $config, Profiler $profiler, FileSystem $fileSystem)
+ public static function createDev(IConfig $config, Profiler $profiler, FileSystem $fileSystem)
{
$debugging = $config->get('system', 'debugging');
$stream = $config->get('system', 'dlogfile');
use Friendica\App;
use Friendica\Core\Cache\ICache;
use Friendica\Core\Cache\Type;
-use Friendica\Core\Config\IConfiguration;
+use Friendica\Core\Config\IConfig;
use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\Database;
/**
* @param App\Mode $mode
* @param App\BaseURL $baseURL
- * @param IConfiguration $config
+ * @param IConfig $config
* @param Database $dba
* @param ICache $cache
* @param LoggerInterface $logger
*
* @return Session\ISession
*/
- public function createSession(App\Mode $mode, App\BaseURL $baseURL, IConfiguration $config, Database $dba, ICache $cache, LoggerInterface $logger, Profiler $profiler, array $server = [])
+ public function createSession(App\Mode $mode, App\BaseURL $baseURL, IConfig $config, Database $dba, ICache $cache, LoggerInterface $logger, Profiler $profiler, array $server = [])
{
$stamp1 = microtime(true);
$session = null;
namespace Friendica\Model\Storage;
-use Friendica\Core\Config\IConfiguration;
+use Friendica\Core\Config\IConfig;
use Friendica\Core\L10n;
use Friendica\Util\Strings;
use Psr\Log\LoggerInterface;
// Default base folder
const DEFAULT_BASE_FOLDER = 'storage';
- /** @var IConfiguration */
+ /** @var IConfig */
private $config;
/** @var string */
/**
* Filesystem constructor.
*
- * @param IConfiguration $config
+ * @param IConfig $config
* @param LoggerInterface $logger
* @param L10n $l10n
*/
- public function __construct(IConfiguration $config, LoggerInterface $logger, L10n $l10n)
+ public function __construct(IConfig $config, LoggerInterface $logger, L10n $l10n)
{
parent::__construct($l10n, $logger);
namespace Friendica\Model\User;
use Friendica\App;
-use Friendica\Core\Config\IConfiguration;
+use Friendica\Core\Config\IConfig;
/**
* Interacting with the Friendica Cookie of a user
/** @var array The $_COOKIE array */
private $cookie;
- public function __construct(IConfiguration $config, App\BaseURL $baseURL, array $server = [], array $cookie = [])
+ public function __construct(IConfig $config, App\BaseURL $baseURL, array $server = [], array $cookie = [])
{
if (!empty($server['REMOTE_ADDR'])) {
$this->remoteAddr = $server['REMOTE_ADDR'];
namespace Friendica\Util;
use Friendica\Core\Config\Cache\ConfigCache;
-use Friendica\Core\Config\IConfiguration;
+use Friendica\Core\Config\IConfig;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\ContainerInterface;
use Psr\Container\NotFoundExceptionInterface;
/**
* Updates the enabling of the current profiler
*
- * @param IConfiguration $config
+ * @param IConfig $config
*/
- public function update(IConfiguration $config)
+ public function update(IConfig $config)
{
$this->enabled = $config->get('system', 'profiler');
$this->rendertime = $config->get('rendertime', 'callstack');
['determine', [], Dice::CHAIN_CALL],
],
],
- Config\IConfiguration::class => [
+ Config\IConfig::class => [
'instanceOf' => Factory\ConfigFactory::class,
'call' => [
['createConfig', [], Dice::CHAIN_CALL],
],
],
- Config\IPConfiguration::class => [
+ Config\IPConfiguration::class => [
'instanceOf' => Factory\ConfigFactory::class,
'call' => [
['createPConfig', [], Dice::CHAIN_CALL],
protected $app;
/**
- * @var MockInterface|Config\IConfiguration The mocked Config Cache
+ * @var MockInterface|Config\IConfig The mocked Config Cache
*/
protected $configMock;
// Disable the adapter
$configModel->shouldReceive('isConnected')->andReturn(false);
- $config = new Config\JitConfiguration($this->configMock, $configModel);
+ $config = new Config\JitConfig($this->configMock, $configModel);
$this->dice->shouldReceive('create')
- ->with(Config\IConfiguration::class)
+ ->with(Config\IConfig::class)
->andReturn($config);
// Mocking App and most used functions
use Friendica\Core\Cache\ICache;
use Friendica\Core\Cache\IMemoryCache;
use Friendica\Core\Config\Cache\ConfigCache;
-use Friendica\Core\Config\IConfiguration;
+use Friendica\Core\Config\IConfig;
use Friendica\Core\Lock\ILock;
use Friendica\Database\Database;
use Friendica\Test\Util\VFSTrait;
public function testConfiguration()
{
- /** @var IConfiguration $config */
- $config = $this->dice->create(IConfiguration::class);
+ /** @var IConfig $config */
+ $config = $this->dice->create(IConfig::class);
- $this->assertInstanceOf(IConfiguration::class, $config);
+ $this->assertInstanceOf(IConfig::class, $config);
$this->assertNotEmpty($config->get('database', 'username'));
}
public function testDevLogger()
{
- /** @var IConfiguration $config */
- $config = $this->dice->create(IConfiguration::class);
+ /** @var IConfig $config */
+ $config = $this->dice->create(IConfig::class);
$config->set('system', 'dlogfile', $this->root->url() . '/friendica.log');
/** @var LoggerInterface $logger */
use Dice\Dice;
use Friendica\App;
-use Friendica\Core\Config\IConfiguration;
+use Friendica\Core\Config\IConfig;
use Friendica\Core\Config\IPConfiguration;
use Friendica\Core\Protocol;
use Friendica\Core\Session;
/** @var App */
protected $app;
- /** @var IConfiguration */
+ /** @var IConfig */
protected $config;
/** @var Dice */
/** @var Database $dba */
$dba = $this->dice->create(Database::class);
- /** @var IConfiguration $config */
- $this->config = $this->dice->create(IConfiguration::class);
+ /** @var IConfig $config */
+ $this->config = $this->dice->create(IConfig::class);
$this->config->set('system', 'url', 'http://localhost');
$this->config->set('system', 'hostname', 'localhost');
namespace Friendica\Test\src\App;
use Friendica\App;
-use Friendica\Core\Config\IConfiguration;
+use Friendica\Core\Config\IConfig;
use Friendica\LegacyModule;
use Friendica\Module\HTTPException\PageNotFound;
use Friendica\Module\WellKnown\HostMeta;
*/
public function testModuleClass($assert, string $name, string $command, bool $privAdd)
{
- $config = \Mockery::mock(IConfiguration::class);
+ $config = \Mockery::mock(IConfig::class);
$config->shouldReceive('get')->with('config', 'private_addons', false)->andReturn($privAdd)->atMost()->once();
$router = (new App\Router([]))->loadRoutes(include __DIR__ . '/../../../static/routes.config.php');
use Friendica\App;
use Friendica\App\Mode;
use Friendica\Console\Config;
-use Friendica\Core\Config\IConfiguration;
+use Friendica\Core\Config\IConfig;
use Mockery\MockInterface;
class ConfigConsoleTest extends ConsoleTest
$this->appMode->shouldReceive('has')
->andReturn(true);
- $this->configMock = \Mockery::mock(IConfiguration::class);
+ $this->configMock = \Mockery::mock(IConfig::class);
}
function testSetGetKeyValue()
namespace Friendica\Test\src\Console;
use Friendica\Console\ServerBlock;
-use Friendica\Core\Config\IConfiguration;
+use Friendica\Core\Config\IConfig;
class ServerBlockConsoleTest extends ConsoleTest
{
{
parent::setUp();
- $this->configMock = \Mockery::mock(IConfiguration::class);
+ $this->configMock = \Mockery::mock(IConfig::class);
}
/**
namespace Friendica\Test\src\Core\Cache;
use Friendica\Core\Cache\MemcacheCache;
-use Friendica\Core\Config\IConfiguration;
+use Friendica\Core\Config\IConfig;
/**
* @requires extension memcache
{
protected function getInstance()
{
- $configMock = \Mockery::mock(IConfiguration::class);
+ $configMock = \Mockery::mock(IConfig::class);
$host = $_SERVER['MEMCACHE_HOST'] ?? 'localhost';
namespace Friendica\Test\src\Core\Cache;
use Friendica\Core\Cache\MemcachedCache;
-use Friendica\Core\Config\IConfiguration;
+use Friendica\Core\Config\IConfig;
use Psr\Log\NullLogger;
/**
{
protected function getInstance()
{
- $configMock = \Mockery::mock(IConfiguration::class);
+ $configMock = \Mockery::mock(IConfig::class);
$host = $_SERVER['MEMCACHED_HOST'] ?? 'localhost';
namespace Friendica\Test\src\Core\Cache;
use Friendica\Core\Cache\RedisCache;
-use Friendica\Core\Config\IConfiguration;
+use Friendica\Core\Config\IConfig;
/**
* @requires extension redis
{
protected function getInstance()
{
- $configMock = \Mockery::mock(IConfiguration::class);
+ $configMock = \Mockery::mock(IConfig::class);
$host = $_SERVER['REDIS_HOST'] ?? 'localhost';
namespace Friendica\Test\src\Core\Config;
use Friendica\Core\Config\Cache\ConfigCache;
-use Friendica\Core\Config\IConfiguration;
+use Friendica\Core\Config\IConfig;
use Friendica\Model\Config\Config as ConfigModel;
use Friendica\Test\MockedTest;
use Mockery\MockInterface;
/** @var ConfigCache */
protected $configCache;
- /** @var IConfiguration */
+ /** @var IConfig */
protected $testedConfig;
/**
}
/**
- * @return IConfiguration
+ * @return IConfig
*/
public abstract function getInstance();
namespace Friendica\Test\src\Core\Config;
-use Friendica\Core\Config\JitConfiguration;
+use Friendica\Core\Config\JitConfig;
class JitConfigurationTest extends ConfigurationTest
{
public function getInstance()
{
- return new JitConfiguration($this->configCache, $this->configModel);
+ return new JitConfig($this->configCache, $this->configModel);
}
/**
namespace Friendica\Test\src\Core\Config;
-use Friendica\Core\Config\PreloadConfiguration;
+use Friendica\Core\Config\PreloadConfig;
class PreloadConfigurationTest extends ConfigurationTest
{
public function getInstance()
{
- return new PreloadConfiguration($this->configCache, $this->configModel);
+ return new PreloadConfig($this->configCache, $this->configModel);
}
/**
namespace Friendica\Test\src\Core\Lock;
use Friendica\Core\Cache\MemcacheCache;
-use Friendica\Core\Config\IConfiguration;
+use Friendica\Core\Config\IConfig;
use Friendica\Core\Lock\CacheLock;
/**
{
protected function getInstance()
{
- $configMock = \Mockery::mock(IConfiguration::class);
+ $configMock = \Mockery::mock(IConfig::class);
$host = $_SERVER['MEMCACHE_HOST'] ?? 'localhost';
namespace Friendica\Test\src\Core\Lock;
use Friendica\Core\Cache\MemcachedCache;
-use Friendica\Core\Config\IConfiguration;
+use Friendica\Core\Config\IConfig;
use Friendica\Core\Lock\CacheLock;
use Psr\Log\NullLogger;
{
protected function getInstance()
{
- $configMock = \Mockery::mock(IConfiguration::class);
+ $configMock = \Mockery::mock(IConfig::class);
$host = $_SERVER['MEMCACHED_HOST'] ?? 'localhost';
namespace Friendica\Test\src\Core\Lock;
use Friendica\Core\Cache\RedisCache;
-use Friendica\Core\Config\IConfiguration;
+use Friendica\Core\Config\IConfig;
use Friendica\Core\Lock\CacheLock;
/**
{
protected function getInstance()
{
- $configMock = \Mockery::mock(IConfiguration::class);
+ $configMock = \Mockery::mock(IConfig::class);
$host = $_SERVER['REDIS_HOST'] ?? 'localhost';
use Dice\Dice;
use Friendica\App;
-use Friendica\Core\Config\IConfiguration;
-use Friendica\Core\Config\JitConfiguration;
+use Friendica\Core\Config\IConfig;
+use Friendica\Core\Config\JitConfig;
use Friendica\Core\Lock\SemaphoreLock;
use Friendica\DI;
use Mockery\MockInterface;
$app->shouldReceive('getHostname')->andReturn('friendica.local');
$dice->shouldReceive('create')->with(App::class)->andReturn($app);
- $configMock = \Mockery::mock(JitConfiguration::class);
+ $configMock = \Mockery::mock(JitConfig::class);
$configMock
->shouldReceive('get')
->with('system', 'temppath', NULL, false)
->andReturn('/tmp/');
- $dice->shouldReceive('create')->with(IConfiguration::class)->andReturn($configMock);
+ $dice->shouldReceive('create')->with(IConfig::class)->andReturn($configMock);
// @todo Because "get_temppath()" is using static methods, we have to initialize the BaseObject
DI::init($dice);
namespace Friendica\Test\src\Core;
use Dice\Dice;
-use Friendica\Core\Config\IConfiguration;
-use Friendica\Core\Config\PreloadConfiguration;
+use Friendica\Core\Config\IConfig;
+use Friendica\Core\Config\PreloadConfig;
use Friendica\Core\Hook;
use Friendica\Core\L10n;
use Friendica\Core\Session\ISession;
{
/** @var Database */
private $dba;
- /** @var IConfiguration */
+ /** @var IConfig */
private $config;
/** @var LoggerInterface */
private $logger;
$this->dba = new StaticDatabase($configCache, $profiler, $this->logger);
$configModel = new Config($this->dba);
- $this->config = new PreloadConfiguration($configCache, $configModel);
+ $this->config = new PreloadConfig($configCache, $configModel);
$this->l10n = \Mockery::mock(L10n::class);
}
namespace Friendica\Test\src\Model\Storage;
-use Friendica\Core\Config\IConfiguration;
+use Friendica\Core\Config\IConfig;
use Friendica\Core\L10n;
use Friendica\Model\Storage\Filesystem;
use Friendica\Model\Storage\IStorage;
{
use VFSTrait;
- /** @var MockInterface|IConfiguration */
+ /** @var MockInterface|IConfig */
protected $config;
protected function setUp()
/** @var MockInterface|L10n $l10n */
$l10n = \Mockery::mock(L10n::class)->makePartial();
- $this->config = \Mockery::mock(IConfiguration::class);
+ $this->config = \Mockery::mock(IConfig::class);
$this->config->shouldReceive('get')
->with('storage', 'filesystem_path', Filesystem::DEFAULT_BASE_FOLDER)
->andReturn($this->root->getChild('storage')->url());
namespace Friendica\Testsrc\Model\User;
use Friendica\App\BaseURL;
-use Friendica\Core\Config\IConfiguration;
+use Friendica\Core\Config\IConfig;
use Friendica\Model\User\Cookie;
use Friendica\Test\DatabaseTest;
use Friendica\Test\Util\StaticCookie;
class CookieTest extends DatabaseTest
{
- /** @var MockInterface|IConfiguration */
+ /** @var MockInterface|IConfig */
private $config;
/** @var MockInterface|BaseURL */
private $baseUrl;
parent::setUp();
- $this->config = \Mockery::mock(IConfiguration::class);
+ $this->config = \Mockery::mock(IConfig::class);
$this->baseUrl = \Mockery::mock(BaseURL::class);
}
namespace Friendica\Test\src\Util;
use Friendica\App\BaseURL;
-use Friendica\Core\Config\IConfiguration;
+use Friendica\Core\Config\IConfig;
use Friendica\Test\MockedTest;
class BaseURLTest extends MockedTest
*/
public function testCheck($server, $input, $assert)
{
- $configMock = \Mockery::mock(IConfiguration::class);
+ $configMock = \Mockery::mock(IConfig::class);
$configMock->shouldReceive('get')->with('config', 'hostname')->andReturn($input['hostname']);
$configMock->shouldReceive('get')->with('system', 'urlpath')->andReturn($input['urlPath']);
$configMock->shouldReceive('get')->with('system', 'ssl_policy')->andReturn($input['sslPolicy']);
*/
public function testSave($input, $save, $url)
{
- $configMock = \Mockery::mock(IConfiguration::class);
+ $configMock = \Mockery::mock(IConfig::class);
$configMock->shouldReceive('get')->with('config', 'hostname')->andReturn($input['hostname']);
$configMock->shouldReceive('get')->with('system', 'urlpath')->andReturn($input['urlPath']);
$configMock->shouldReceive('get')->with('system', 'ssl_policy')->andReturn($input['sslPolicy']);
*/
public function testSaveByUrl($input, $save, $url)
{
- $configMock = \Mockery::mock(IConfiguration::class);
+ $configMock = \Mockery::mock(IConfig::class);
$configMock->shouldReceive('get')->with('config', 'hostname')->andReturn($input['hostname']);
$configMock->shouldReceive('get')->with('system', 'urlpath')->andReturn($input['urlPath']);
$configMock->shouldReceive('get')->with('system', 'ssl_policy')->andReturn($input['sslPolicy']);
*/
public function testGetURL($sslPolicy, $ssl, $url, $assert)
{
- $configMock = \Mockery::mock(IConfiguration::class);
+ $configMock = \Mockery::mock(IConfig::class);
$configMock->shouldReceive('get')->with('config', 'hostname')->andReturn('friendica.local');
$configMock->shouldReceive('get')->with('system', 'urlpath')->andReturn('new/test');
$configMock->shouldReceive('get')->with('system', 'ssl_policy')->andReturn($sslPolicy);
*/
public function testCheckRedirectHTTPS($server, $forceSSL, $sslPolicy, $url, $redirect)
{
- $configMock = \Mockery::mock(IConfiguration::class);
+ $configMock = \Mockery::mock(IConfig::class);
$configMock->shouldReceive('get')->with('config', 'hostname')->andReturn('friendica.local');
$configMock->shouldReceive('get')->with('system', 'urlpath')->andReturn('new/test');
$configMock->shouldReceive('get')->with('system', 'ssl_policy')->andReturn($sslPolicy);
*/
public function testWrongSave($fail)
{
- $configMock = \Mockery::mock(IConfiguration::class);
+ $configMock = \Mockery::mock(IConfig::class);
$configMock->shouldReceive('get')->with('config', 'hostname')->andReturn('friendica.local');
$configMock->shouldReceive('get')->with('system', 'urlpath')->andReturn('new/test');
$configMock->shouldReceive('get')->with('system', 'ssl_policy')->andReturn(BaseURL::DEFAULT_SSL_SCHEME);
namespace Friendica\Test\src\Util;
use Friendica\Core\Config\Cache\ConfigCache;
-use Friendica\Core\Config\IConfiguration;
+use Friendica\Core\Config\IConfig;
use Friendica\Test\MockedTest;
use Friendica\Util\Profiler;
use Mockery\MockInterface;
$profiler->saveTimestamp(time(), 'network', 'test1');
- $config = \Mockery::mock(IConfiguration::class);
+ $config = \Mockery::mock(IConfig::class);
$config->shouldReceive('get')
->with('system', 'profiler')
->andReturn(false)