$a->runFrontend(
$dice->create(\Friendica\App\Module::class),
$dice->create(\Friendica\App\Router::class),
- $dice->create(\Friendica\Core\Config\PConfiguration::class),
+ $dice->create(\Friendica\Core\Config\IPConfiguration::class),
$dice->create(\Friendica\App\Authentication::class)
);
use Friendica\App\Page;
use Friendica\App\Authentication;
use Friendica\Core\Config\Cache\ConfigCache;
-use Friendica\Core\Config\Configuration;
-use Friendica\Core\Config\PConfiguration;
+use Friendica\Core\Config\IConfiguration;
+use Friendica\Core\Config\IPConfiguration;
use Friendica\Core\L10n\L10n;
use Friendica\Core\System;
use Friendica\Core\Theme;
private $currentMobileTheme;
/**
- * @var Configuration The config
+ * @var IConfiguration The config
*/
private $config;
/**
* @param Database $database The Friendica Database
- * @param Configuration $config The Configuration
+ * @param IConfiguration $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 App\Arguments $args The Friendica Arguments of the call
* @param Core\Process $process The process methods
*/
- public function __construct(Database $database, Configuration $config, App\Mode $mode, BaseURL $baseURL, LoggerInterface $logger, Profiler $profiler, L10n $l10n, Arguments $args, App\Page $page, Core\Process $process)
+ public function __construct(Database $database, IConfiguration $config, App\Mode $mode, BaseURL $baseURL, LoggerInterface $logger, Profiler $profiler, L10n $l10n, Arguments $args, App\Page $page, Core\Process $process)
{
$this->database = $database;
$this->config = $config;
*
* @param App\Module $module The determined module
* @param App\Router $router
- * @param PConfiguration $pconfig
+ * @param IPConfiguration $pconfig
* @param Authentication $auth The Authentication backend of the node
* @throws HTTPException\InternalServerErrorException
* @throws \ImagickException
*/
- public function runFrontend(App\Module $module, App\Router $router, PConfiguration $pconfig, Authentication $auth)
+ public function runFrontend(App\Module $module, App\Router $router, IPConfiguration $pconfig, Authentication $auth)
{
$moduleName = $module->getName();
use Exception;
use Friendica\App;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
use Friendica\Core\Hook;
use Friendica\Core\PConfig;
use Friendica\Core\Session;
*/
class Authentication
{
- /** @var Configuration */
+ /** @var IConfiguration */
private $config;
/** @var App\Mode */
private $mode;
/**
* Authentication constructor.
*
- * @param Configuration $config
+ * @param IConfiguration $config
* @param App\Mode $mode
* @param App\BaseURL $baseUrl
* @param L10n $l10n
* @param User\Cookie $cookie
* @param Session\ISession $session
*/
- public function __construct(Configuration $config, App\Mode $mode, App\BaseURL $baseUrl, L10n $l10n, Database $dba, LoggerInterface $logger, User\Cookie $cookie, Session\ISession $session)
+ public function __construct(IConfiguration $config, App\Mode $mode, App\BaseURL $baseUrl, L10n $l10n, Database $dba, LoggerInterface $logger, User\Cookie $cookie, Session\ISession $session)
{
$this->config = $config;
$this->mode = $mode;
namespace Friendica\App;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
use Friendica\Core\System;
use Friendica\Util\Network;
use Friendica\Util\Strings;
/**
* The Friendica Config
*
- * @var Configuration
+ * @var IConfiguration
*/
private $config;
}
/**
- * @param Configuration $config The Friendica configuration
+ * @param IConfiguration $config The Friendica IConfiguration
* @param array $server The $_SERVER array
*/
- public function __construct(Configuration $config, array $server)
+ public function __construct(IConfiguration $config, array $server)
{
$this->config = $config;
$this->server = $server;
*
* @param Arguments $args The Friendica execution arguments
* @param Router $router The Friendica routing instance
- * @param Core\Config\Configuration $config The Friendica Configuration
+ * @param Core\Config\IConfiguration $config The Friendica Configuration
*
* @return Module The determined module of this call
*
* @throws \Exception
*/
- public function determineClass(Arguments $args, Router $router, Core\Config\Configuration $config)
+ public function determineClass(Arguments $args, Router $router, Core\Config\IConfiguration $config)
{
$printNotAllowedAddon = false;
use DOMXPath;
use Friendica\App;
use Friendica\Content\Nav;
-use Friendica\Core\Config\Configuration;
-use Friendica\Core\Config\PConfiguration;
+use Friendica\Core\Config\IConfiguration;
+use Friendica\Core\Config\IPConfiguration;
use Friendica\Core\Hook;
use Friendica\Core\L10n\L10n;
use Friendica\Core\Renderer;
* @param App $app The Friendica App instance
* @param Module $module The loaded Friendica module
* @param L10n $l10n The l10n language instance
- * @param Configuration $config The Friendica configuration
- * @param PConfiguration $pConfig The Friendica personal configuration (for user)
+ * @param IConfiguration $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, Configuration $config, PConfiguration $pConfig)
+ private function initHead(App $app, Module $module, L10n $l10n, IConfiguration $config, IPConfiguration $pConfig)
{
$interval = ((local_user()) ? $pConfig->get(local_user(), 'system', 'update_interval') : 40000);
* @param Mode $mode The current node mode
* @param Module $module The loaded Friendica module
* @param L10n $l10n The l10n language class
- * @param Configuration $config The Configuration of this node
- * @param PConfiguration $pconfig The personal/user configuration
+ * @param IConfiguration $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, Configuration $config, PConfiguration $pconfig)
+ public function run(App $app, BaseURL $baseURL, Mode $mode, Module $module, L10n $l10n, IConfiguration $config, IPConfiguration $pconfig)
{
$moduleName = $module->getName();
private $configCache;
/**
- * @var Config\Configuration
+ * @var Config\IConfiguration
*/
private $config;
HELP;
}
- public function __construct(App\Mode $appMode, Config\Cache\ConfigCache $configCache, Config\Configuration $config, Database $dba, array $argv = null)
+ public function __construct(App\Mode $appMode, Config\Cache\ConfigCache $configCache, Config\IConfiguration $config, Database $dba, array $argv = null)
{
parent::__construct($argv);
use Asika\SimpleConsole\CommandArgsException;
use Friendica\App;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
use RuntimeException;
/**
*/
private $appMode;
/**
- * @var Configuration
+ * @var IConfiguration
*/
private $config;
return $help;
}
- public function __construct(App\Mode $appMode, Configuration $config, array $argv = null)
+ public function __construct(App\Mode $appMode, IConfiguration $config, array $argv = null)
{
parent::__construct($argv);
namespace Friendica\Console;
use Friendica\App;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
/**
* @brief Sets maintenance mode for this node
*/
private $appMode;
/**
- * @var Configuration
+ * @var IConfiguration
*/
private $config;
return $help;
}
- public function __construct(App\Mode $appMode, Configuration $config, $argv = null)
+ public function __construct(App\Mode $appMode, IConfiguration $config, $argv = null)
{
parent::__construct($argv);
namespace Friendica\Console;
use Friendica\App;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
use Friendica\Core\L10n\L10n;
use Friendica\Core\Update;
*/
private $appMode;
/**
- * @var Configuration
+ * @var IConfiguration
*/
private $config;
/**
return $help;
}
- public function __construct(App\Mode $appMode, Configuration $config, L10n $l10n, array $argv = null)
+ public function __construct(App\Mode $appMode, IConfiguration $config, L10n $l10n, array $argv = null)
{
parent::__construct($argv);
use Asika\SimpleConsole\CommandArgsException;
use Asika\SimpleConsole\Console;
use Console_Table;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
/**
* @brief Manage blocked servers
protected $helpOptions = ['h', 'help', '?'];
/**
- * @var Configuration
+ * @var IConfiguration
*/
private $config;
return $help;
}
- public function __construct(Configuration $config, $argv = null)
+ public function __construct(IConfiguration $config, $argv = null)
{
parent::__construct($argv);
/**
* Prints the whole list of blocked domains including the reason
*
- * @param Configuration $config
+ * @param IConfiguration $config
*/
- private function printBlockedServers(Configuration $config)
+ private function printBlockedServers(IConfiguration $config)
{
$table = new Console_Table();
$table->setHeaders(['Domain', 'Reason']);
/**
* Adds a server to the blocked list
*
- * @param Configuration $config
+ * @param IConfiguration $config
*
* @return int The return code (0 = success, 1 = failed)
*/
- private function addBlockedServer(Configuration $config)
+ private function addBlockedServer(IConfiguration $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 Configuration $config
+ * @param IConfiguration $config
*
* @return int The return code (0 = success, 1 = failed)
*/
- private function removeBlockedServer(Configuration $config)
+ private function removeBlockedServer(IConfiguration $config)
{
if (count($this->args) !== 2) {
throw new CommandArgsException('Remove needs a second parameter.');
namespace Friendica\Console;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
/**
* Tired of chasing typos and finding them after a commit.
protected $helpOptions = ['h', 'help', '?'];
/**
- * @var Configuration
+ * @var IConfiguration
*/
private $config;
return $help;
}
- public function __construct(Configuration $config, array $argv = null)
+ public function __construct(IConfiguration $config, array $argv = null)
{
parent::__construct($argv);
namespace Friendica\Core\Cache;
use Exception;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
use Memcache;
/**
/**
* @throws Exception
*/
- public function __construct(string $hostname, Configuration $config)
+ public function __construct(string $hostname, IConfiguration $config)
{
if (!class_exists('Memcache', false)) {
throw new Exception('Memcache class isn\'t available');
namespace Friendica\Core\Cache;
use Exception;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
use Memcached;
use Psr\Log\LoggerInterface;
*
* @throws \Exception
*/
- public function __construct(string $hostname, Configuration $config, LoggerInterface $logger)
+ public function __construct(string $hostname, IConfiguration $config, LoggerInterface $logger)
{
if (!class_exists('Memcached', false)) {
throw new Exception('Memcached class isn\'t available');
namespace Friendica\Core\Cache;
use Exception;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
use Redis;
/**
/**
* @throws Exception
*/
- public function __construct(string $hostname, Configuration $config)
+ public function __construct(string $hostname, IConfiguration $config)
{
if (!class_exists('Redis', false)) {
throw new Exception('Redis class isn\'t available');
* - 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
+abstract class Configuration implements IConfiguration
{
/**
* @var Cache\ConfigCache
}
/**
- * Returns the Config Cache
- *
- * @return Cache\ConfigCache
+ * {@inheritDoc}
*/
public function getCache()
{
return $this->configCache;
}
-
- /**
- * @brief 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
- */
- abstract public function load(string $cat = 'config');
-
- /**
- * @brief 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
- */
- abstract public function get(string $cat, string $key, $default_value = null, bool $refresh = false);
-
- /**
- * @brief 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
- */
- abstract public function set(string $cat, string $key, $value);
-
- /**
- * @brief 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
- */
- abstract public function delete(string $cat, string $key);
}
--- /dev/null
+<?php
+
+namespace Friendica\Core\Config;
+
+/**
+ * Interface for accessing system wide configurations
+ */
+interface IConfiguration
+{
+
+ /**
+ * @brief 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');
+
+ /**
+ * @brief 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);
+
+ /**
+ * @brief 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);
+
+ /**
+ * @brief 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 user specific configurations
+ */
+interface IPConfiguration
+{
+
+ /**
+ * 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
+ *
+ * @param int $uid The user_id
+ * @param string $cat The category of the configuration value
+ *
+ * @return void
+ * @see PConfigCache
+ *
+ */
+ function load(int $uid, string $cat = 'config');
+
+ /**
+ * Get a particular user's config variable given the category name
+ * ($cat) and a key.
+ *
+ * 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 PConfigCache).
+ *
+ * @param int $uid The user_id
+ * @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(int $uid, string $cat, string $key, $default_value = null, bool $refresh = false);
+
+ /**
+ * Sets a configuration value for a user
+ *
+ * Stores a config value ($value) in the category ($family) under the key ($key)
+ * for the user_id $uid.
+ *
+ * @note Please do not store booleans - convert to 0/1 integer values!
+ *
+ * @param int $uid The user_id
+ * @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(int $uid, string $cat, string $key, $value);
+
+ /**
+ * Deletes the given key from the users's configuration.
+ *
+ * Removes the configured value from the stored cache in $this->configCache
+ * (@see ConfigCache) and removes it from the database (@see IConfigAdapter)
+ * with the given $uid.
+ *
+ * @param int $uid The user_id
+ * @param string $cat The category of the configuration value
+ * @param string $key The configuration key to delete
+ *
+ * @return bool
+ */
+ function delete(int $uid, string $cat, string $key);
+
+
+ /**
+ * Returns the Config Cache
+ *
+ * @return Cache\PConfigCache
+ */
+ function getCache();
+}
* The configuration cache (@see Cache\PConfigCache) is used for temporary caching of database calls. This will
* increase the performance.
*/
-abstract class PConfiguration
+abstract class PConfiguration implements IPConfiguration
{
/**
* @var Cache\PConfigCache
{
return $this->configCache;
}
-
- /**
- * 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
- *
- * @param int $uid The user_id
- * @param string $cat The category of the configuration value
- *
- * @return void
- * @see PConfigCache
- *
- */
- abstract public function load(int $uid, string $cat = 'config');
-
- /**
- * Get a particular user's config variable given the category name
- * ($cat) and a key.
- *
- * 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 PConfigCache).
- *
- * @param int $uid The user_id
- * @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
- */
- abstract public function get(int $uid, string $cat, string $key, $default_value = null, bool $refresh = false);
-
- /**
- * Sets a configuration value for a user
- *
- * Stores a config value ($value) in the category ($family) under the key ($key)
- * for the user_id $uid.
- *
- * @note Please do not store booleans - convert to 0/1 integer values!
- *
- * @param int $uid The user_id
- * @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
- */
- abstract public function set(int $uid, string $cat, string $key, $value);
-
- /**
- * Deletes the given key from the users's configuration.
- *
- * Removes the configured value from the stored cache in $this->configCache
- * (@see ConfigCache) and removes it from the database (@see IConfigAdapter)
- * with the given $uid.
- *
- * @param int $uid The user_id
- * @param string $cat The category of the configuration value
- * @param string $key The configuration key to delete
- *
- * @return bool
- */
- abstract public function delete(int $uid, string $cat, string $key);
}
namespace Friendica\Core\L10n;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
use Friendica\Core\Hook;
use Friendica\Core\Session\ISession;
use Friendica\Database\Database;
*/
private $logger;
- public function __construct(Configuration $config, Database $dba, LoggerInterface $logger, ISession $session, array $server, array $get)
+ public function __construct(IConfiguration $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\Configuration;
+use Friendica\Core\Config\IConfiguration;
use Psr\Log\LoggerInterface;
/**
private $mode;
/**
- * @var Configuration
+ * @var IConfiguration
*/
private $config;
*/
private $basePath;
- public function __construct(LoggerInterface $logger, App\Mode $mode, Configuration $config, string $basepath)
+ public function __construct(LoggerInterface $logger, App\Mode $mode, IConfiguration $config, string $basepath)
{
$this->logger = $logger;
$this->mode = $mode;
use Dice\Dice;
use Friendica\Core\Cache\ICache;
-use Friendica\Core\Config\Configuration;
-use Friendica\Core\Config\PConfiguration;
+use Friendica\Core\Config\IConfiguration;
+use Friendica\Core\Config\IPConfiguration;
use Friendica\Core\L10n\L10n;
use Friendica\Core\Lock\ILock;
use Friendica\Core\Process;
* @method static Content\Text\BBCode\Video bbCodeVideo()
* @method static DateTimeFormat dtFormat()
* @method static ICache cache()
- * @method static Configuration config()
- * @method static PConfiguration pConfig()
+ * @method static IConfiguration config()
+ * @method static IPConfiguration pConfig()
* @method static ILock lock()
* @method static L10n l10n()
* @method static LoggerInterface logger()
'bbCodeVideo' => Content\Text\BBCode\Video::class,
'dtFormat' => DateTimeFormat::class,
'cache' => ICache::class,
- 'config' => Configuration::class,
- 'pConfig' => PConfiguration::class,
+ 'config' => IConfiguration::class,
+ 'pConfig' => IPConfiguration::class,
'l10n' => L10n::class,
'lock' => ILock::class,
'logger' => LoggerInterface::class,
use Friendica\App\BaseURL;
use Friendica\Core\Cache;
use Friendica\Core\Cache\ICache;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
use Friendica\Database\Database;
use Friendica\Util\Profiler;
use Psr\Log\LoggerInterface;
const DEFAULT_TYPE = Cache\Cache::TYPE_DATABASE;
/**
- * @var Configuration The configuration to read parameters out of the config
+ * @var IConfiguration The IConfiguration to read parameters out of the config
*/
private $config;
*/
private $logger;
- public function __construct(BaseURL $baseURL, Configuration $config, Database $dba, Profiler $profiler, LoggerInterface $logger)
+ public function __construct(BaseURL $baseURL, IConfiguration $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\Configuration
+ * @return Config\IConfiguration
*/
public function createConfig(Cache\ConfigCache $configCache, ConfigModel $configModel)
{
* @param Cache\PConfigCache $pConfigCache The personal config cache
* @param PConfigModel $configModel The configuration model
*
- * @return Config\PConfiguration
+ * @return Config\IPConfiguration
*/
public function createPConfig(Cache\ConfigCache $configCache, Cache\PConfigCache $pConfigCache, PConfigModel $configModel)
{
use Friendica\Core\Cache\Cache;
use Friendica\Core\Cache\IMemoryCache;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
use Friendica\Core\Lock;
use Friendica\Database\Database;
use Psr\Log\LoggerInterface;
const DEFAULT_DRIVER = 'default';
/**
- * @var Configuration The configuration to read parameters out of the config
+ * @var IConfiguration The configuration to read parameters out of the config
*/
private $config;
*/
private $logger;
- public function __construct(CacheFactory $cacheFactory, Configuration $config, Database $dba, LoggerInterface $logger)
+ public function __construct(CacheFactory $cacheFactory, IConfiguration $config, Database $dba, LoggerInterface $logger)
{
$this->cacheFactory = $cacheFactory;
$this->config = $config;
namespace Friendica\Factory;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
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 Configuration $config The config
+ * @param IConfiguration $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, Configuration $config, Profiler $profiler, FileSystem $fileSystem)
+ public function create(Database $database, IConfiguration $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 Configuration $config The config
+ * @param IConfiguration $config The config
* @param Profiler $profiler The profiler of the app
* @param FileSystem $fileSystem FileSystem utils
*
* @throws InternalServerErrorException
* @throws \Exception
*/
- public static function createDev(Configuration $config, Profiler $profiler, FileSystem $fileSystem)
+ public static function createDev(IConfiguration $config, Profiler $profiler, FileSystem $fileSystem)
{
$debugging = $config->get('system', 'debugging');
$stream = $config->get('system', 'dlogfile');
use Friendica\App;
use Friendica\Core\Cache\Cache;
use Friendica\Core\Cache\ICache;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\Database;
/**
* @param App\Mode $mode
* @param App\BaseURL $baseURL
- * @param Configuration $config
+ * @param IConfiguration $config
+ * @param Cookie $cookie
* @param Database $dba
* @param ICache $cache
* @param LoggerInterface $logger
*
* @return Session\ISession
*/
- public function createSession(App\Mode $mode, App\BaseURL $baseURL, Configuration $config, Database $dba, ICache $cache, LoggerInterface $logger, Profiler $profiler, array $server = [])
+ public function createSession(App\Mode $mode, App\BaseURL $baseURL, IConfiguration $config, Database $dba, ICache $cache, LoggerInterface $logger, Profiler $profiler, array $server = [])
{
$stamp1 = microtime(true);
$session = null;
use Friendica\App;
use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML;
-use Friendica\Core\Config\PConfiguration;
+use Friendica\Core\Config\IPConfiguration;
use Friendica\Core\L10n\L10n;
use Friendica\Core\Protocol;
use Friendica\Core\System;
private $args;
/** @var App\BaseURL */
private $baseUrl;
- /** @var PConfiguration */
+ /** @var IPConfiguration */
private $pConfig;
/** @var LoggerInterface */
private $logger;
public function __construct(Database $dba, L10n $l10n, App\Arguments $args, App\BaseURL $baseUrl,
- PConfiguration $pConfig, LoggerInterface $logger)
+ IPConfiguration $pConfig, LoggerInterface $logger)
{
$this->dba = $dba;
$this->l10n = $l10n;
namespace Friendica\Model\User;
use Friendica\App;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
/**
* Interacting with the Friendica Cookie of a user
/** @var array The $_COOKIE array */
private $cookie;
- public function __construct(Configuration $config, App\BaseURL $baseURL, array $server = [], array $cookie = [])
+ public function __construct(IConfiguration $config, App\BaseURL $baseURL, array $server = [], array $cookie = [])
{
if (!empty($server['REMOTE_ADDR'])) {
$this->remoteAddr = $server['REMOTE_ADDR'];
namespace Friendica\Module\Diaspora;
-use Friendica\App;
use Friendica\BaseModule;
-use Friendica\Core\Config\Configuration;
-use Friendica\Core\L10n\L10n;
use Friendica\DI;
use Friendica\Model\User;
use Friendica\Network\HTTPException;
namespace Friendica\Util;
use Friendica\Core\Config\Cache\ConfigCache;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\ContainerInterface;
use Psr\Container\NotFoundExceptionInterface;
/**
* Updates the enabling of the current profiler
*
- * @param Configuration $config
+ * @param IConfiguration $config
*/
- public function update(Configuration $config)
+ public function update(IConfiguration $config)
{
$this->enabled = $config->get('system', 'profiler');
$this->rendertime = $config->get('rendertime', 'callstack');
['determine', [], Dice::CHAIN_CALL],
],
],
- Config\Configuration::class => [
+ Config\IConfiguration::class => [
'instanceOf' => Factory\ConfigFactory::class,
'call' => [
['createConfig', [], Dice::CHAIN_CALL],
],
],
- Config\PConfiguration::class => [
+ Config\IPConfiguration::class => [
'instanceOf' => Factory\ConfigFactory::class,
'call' => [
['createPConfig', [], Dice::CHAIN_CALL],
protected $app;
/**
- * @var MockInterface|Config\Configuration The mocked Config Cache
+ * @var MockInterface|Config\IConfiguration The mocked Config Cache
*/
protected $configMock;
$this->configMock = \Mockery::mock(Config\Cache\ConfigCache::class);
$this->dice->shouldReceive('create')
- ->with(Config\Cache\ConfigCache::class)
+ ->with(Config\Cache\ConfigCache::class, [])
->andReturn($this->configMock);
$this->mode = \Mockery::mock(App\Mode::class);
$this->dice->shouldReceive('create')
- ->with(App\Mode::class)
+ ->with(App\Mode::class, [])
->andReturn($this->mode);
$configModel= \Mockery::mock(\Friendica\Model\Config\Config::class);
// Disable the adapter
$config = new Config\JitConfiguration($this->configMock, $configModel);
$this->dice->shouldReceive('create')
- ->with(Config\Configuration::class)
+ ->with(Config\IConfiguration::class, [])
->andReturn($config);
// Mocking App and most used functions
$this->app = \Mockery::mock(App::class);
$this->dice->shouldReceive('create')
- ->with(App::class)
+ ->with(App::class, [])
->andReturn($this->app);
$this->app
->shouldReceive('getBasePath')
$this->profilerMock = \Mockery::mock(Profiler::class);
$this->profilerMock->shouldReceive('saveTimestamp');
$this->dice->shouldReceive('create')
- ->with(Profiler::class)
+ ->with(Profiler::class, [])
->andReturn($this->profilerMock);
$this->app
* This file is loaded by PHPUnit before any test.
*/
+use Dice\Dice;
+use Friendica\DI;
use PHPUnit\Framework\TestCase;
// Backward compatibility
if (!class_exists(TestCase::class)) {
class_alias(PHPUnit_Framework_TestCase::class, TestCase::class);
}
+
+$dice = new Dice();
+$dice = $dice->addRules(include __DIR__ . '/../static/dependencies.config.php');
+
+DI::init($dice);
use Friendica\Core\Cache\ICache;
use Friendica\Core\Cache\IMemoryCache;
use Friendica\Core\Config\Cache\ConfigCache;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
use Friendica\Core\Lock\ILock;
use Friendica\Database\Database;
use Friendica\Test\Util\VFSTrait;
public function testConfiguration()
{
- /** @var Configuration $config */
- $config = $this->dice->create(Configuration::class);
+ /** @var IConfiguration $config */
+ $config = $this->dice->create(IConfiguration::class);
- $this->assertInstanceOf(Configuration::class, $config);
+ $this->assertInstanceOf(IConfiguration::class, $config);
$this->assertNotEmpty($config->get('database', 'username'));
}
public function testDevLogger()
{
- /** @var Configuration $config */
- $config = $this->dice->create(Configuration::class);
+ /** @var IConfiguration $config */
+ $config = $this->dice->create(IConfiguration::class);
$config->set('system', 'dlogfile', $this->root->url() . '/friendica.log');
/** @var LoggerInterface $logger */
use Dice\Dice;
use Friendica\App;
-use Friendica\Core\Config\Configuration;
-use Friendica\Core\Config\PConfiguration;
+use Friendica\Core\Config\IConfiguration;
+use Friendica\Core\Config\IPConfiguration;
use Friendica\Core\Protocol;
use Friendica\Core\Session;
use Friendica\Core\Session\ISession;
/** @var App */
protected $app;
- /** @var Configuration */
+ /** @var IConfiguration */
protected $config;
/** @var Dice */
/** @var Database $dba */
$dba = $this->dice->create(Database::class);
- /** @var Configuration $config */
- $this->config = $this->dice->create(Configuration::class);
+ /** @var IConfiguration $config */
+ $this->config = $this->dice->create(IConfiguration::class);
$this->config->set('system', 'url', 'http://localhost');
$this->config->set('system', 'hostname', 'localhost');
*/
public function testApiGetUserWithFrioSchema()
{
- $pConfig = $this->dice->create(PConfiguration::class);
+ $pConfig = $this->dice->create(IPConfiguration::class);
$pConfig->set($this->selfUser['id'], 'frio', 'schema', 'red');
$user = api_get_user($this->app);
$this->assertSelfUser($user);
*/
public function testApiGetUserWithCustomFrioSchema()
{
- $pConfig = $this->dice->create(PConfiguration::class);
+ $pConfig = $this->dice->create(IPConfiguration::class);
$pConfig->set($this->selfUser['id'], 'frio', 'schema', '---');
$pConfig->set($this->selfUser['id'], 'frio', 'nav_bg', '#123456');
$pConfig->set($this->selfUser['id'], 'frio', 'link_color', '#123456');
*/
public function testApiGetUserWithEmptyFrioSchema()
{
- $pConfig = $this->dice->create(PConfiguration::class);
+ $pConfig = $this->dice->create(IPConfiguration::class);
$pConfig->set($this->selfUser['id'], 'frio', 'schema', '---');
$user = api_get_user($this->app);
$this->assertSelfUser($user);
--- /dev/null
+<?xml version="1.0" encoding="utf-8" ?>
+<phpunit
+ bootstrap="bootstrap.php"
+ verbose="true">
+ <testsuite name='friendica'>
+ <directory suffix='.php'>functional/</directory>
+ <directory suffix='.php'>include/</directory>
+ <directory suffix='.php'>src/</directory>
+ <directory suffix='.php'>./</directory>
+ </testsuite>
+ <!-- Filters for Code Coverage -->
+ <filter>
+ <whitelist>
+ <directory suffix=".php">..</directory>
+ <exclude>
+ <directory suffix=".php">config/</directory>
+ <directory suffix=".php">doc/</directory>
+ <directory suffix=".php">images/</directory>
+ <directory suffix=".php">library/</directory>
+ <directory suffix=".php">spec/</directory>
+ <directory suffix=".php">tests/</directory>
+ <directory suffix=".php">view/</directory>
+ </exclude>
+ </whitelist>
+ </filter>
+</phpunit>
namespace Friendica\Test\src\App;
use Friendica\App;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
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(Configuration::class);
+ $config = \Mockery::mock(IConfiguration::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\Configuration;
+use Friendica\Core\Config\IConfiguration;
use Mockery\MockInterface;
class ConfigConsoleTest extends ConsoleTest
$this->appMode->shouldReceive('has')
->andReturn(true);
- $this->configMock = \Mockery::mock(Configuration::class);
+ $this->configMock = \Mockery::mock(IConfiguration::class);
}
function testSetGetKeyValue()
namespace Friendica\Test\src\Console;
use Friendica\Console\ServerBlock;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
class ServerBlockConsoleTest extends ConsoleTest
{
{
parent::setUp();
- $this->configMock = \Mockery::mock(Configuration::class);
+ $this->configMock = \Mockery::mock(IConfiguration::class);
}
/**
$l10nMock = \Mockery::mock(L10n::class);
$l10nMock->shouldReceive('t')->withAnyArgs()->andReturnUsing(function ($args) { return $args; });
$this->dice->shouldReceive('create')
- ->with(L10n::class)
+ ->with(L10n::class, [])
->andReturn($l10nMock);
$baseUrlMock = \Mockery::mock(BaseURL::class);
$baseUrlMock->shouldReceive('get')->withAnyArgs()->andReturn('friendica.local');
$this->dice->shouldReceive('create')
- ->with(BaseURL::class)
+ ->with(BaseURL::class, [])
->andReturn($baseUrlMock);
}
namespace Friendica\Test\src\Core\Cache;
use Friendica\Core\Cache\MemcacheCache;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
/**
* @requires extension memcache
{
protected function getInstance()
{
- $configMock = \Mockery::mock(Configuration::class);
+ $configMock = \Mockery::mock(IConfiguration::class);
$host = $_SERVER['MEMCACHE_HOST'] ?? 'localhost';
namespace Friendica\Test\src\Core\Cache;
use Friendica\Core\Cache\MemcachedCache;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
use Psr\Log\NullLogger;
/**
{
protected function getInstance()
{
- $configMock = \Mockery::mock(Configuration::class);
+ $configMock = \Mockery::mock(IConfiguration::class);
$host = $_SERVER['MEMCACHED_HOST'] ?? 'localhost';
namespace Friendica\Test\src\Core\Cache;
use Friendica\Core\Cache\RedisCache;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
/**
* @requires extension redis
{
protected function getInstance()
{
- $configMock = \Mockery::mock(Configuration::class);
+ $configMock = \Mockery::mock(IConfiguration::class);
$host = $_SERVER['REDIS_HOST'] ?? 'localhost';
namespace Friendica\Test\src\Core\Config;
use Friendica\Core\Config\Cache\ConfigCache;
-use Friendica\Core\Config\Configuration;
-use Friendica\Core\Config\JitConfiguration;
+use Friendica\Core\Config\IConfiguration;
use Friendica\Model\Config\Config as ConfigModel;
use Friendica\Test\MockedTest;
use Mockery\MockInterface;
/** @var ConfigCache */
protected $configCache;
- /** @var Configuration */
+ /** @var IConfiguration */
protected $testedConfig;
/**
}
/**
- * @return Configuration
+ * @return IConfiguration
*/
public abstract function getInstance();
$dice = $dice->addRules(include __DIR__ . '/../../../static/dependencies.config.php');
$dice->shouldReceive('create')
- ->with(\Friendica\Core\L10n\L10n::class)
+ ->with(\Friendica\Core\L10n\L10n::class, [])
->andReturn($this->l10nMock);
DI::init($dice);
$this->assertTrue($install->checkImagick());
$this->assertCheckExist(1,
- L10n::t('ImageMagick supports GIF'),
+ $this->l10nMock->t('ImageMagick supports GIF'),
'',
true,
false,
// even there is no supported type, Imagick should return true (because it is not required)
$this->assertTrue($install->checkImagick());
$this->assertCheckExist(1,
- L10n::t('ImageMagick supports GIF'),
+ $this->l10nMock->t('ImageMagick supports GIF'),
'',
- false,
+ true,
false,
$install->getChecks());
}
namespace Friendica\Test\src\Core\Lock;
use Friendica\Core\Cache\MemcacheCache;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
use Friendica\Core\Lock\CacheLock;
/**
{
protected function getInstance()
{
- $configMock = \Mockery::mock(Configuration::class);
+ $configMock = \Mockery::mock(IConfiguration::class);
$host = $_SERVER['MEMCACHE_HOST'] ?? 'localhost';
namespace Friendica\Test\src\Core\Lock;
use Friendica\Core\Cache\MemcachedCache;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
use Friendica\Core\Lock\CacheLock;
use Psr\Log\NullLogger;
{
protected function getInstance()
{
- $configMock = \Mockery::mock(Configuration::class);
+ $configMock = \Mockery::mock(IConfiguration::class);
$host = $_SERVER['MEMCACHED_HOST'] ?? 'localhost';
namespace Friendica\Test\src\Core\Lock;
use Friendica\Core\Cache\RedisCache;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
use Friendica\Core\Lock\CacheLock;
/**
{
protected function getInstance()
{
- $configMock = \Mockery::mock(Configuration::class);
+ $configMock = \Mockery::mock(IConfiguration::class);
$host = $_SERVER['REDIS_HOST'] ?? 'localhost';
use Dice\Dice;
use Friendica\App;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
use Friendica\Core\Config\JitConfiguration;
use Friendica\Core\Lock\SemaphoreLock;
use Friendica\DI;
+use Mockery\MockInterface;
class SemaphoreLockTest extends LockTest
{
public function setUp()
{
+ /** @var MockInterface|Dice $dice */
$dice = \Mockery::mock(Dice::class)->makePartial();
$app = \Mockery::mock(App::class);
$app->shouldReceive('getHostname')->andReturn('friendica.local');
- $dice->shouldReceive('create')->with(App::class)->andReturn($app);
+ $dice->shouldReceive('create')->with(App::class, [])->andReturn($app);
$configMock = \Mockery::mock(JitConfiguration::class);
$configMock
->shouldReceive('get')
->with('system', 'temppath', NULL, false)
->andReturn('/tmp/');
- $dice->shouldReceive('create')->with(Configuration::class)->andReturn($configMock);
+ $dice->shouldReceive('create')->with(IConfiguration::class, [])->andReturn($configMock);
// @todo Because "get_temppath()" is using static methods, we have to initialize the BaseObject
DI::init($dice);
namespace Friendica\Testsrc\Model\User;
use Friendica\App\BaseURL;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
use Friendica\Model\User\Cookie;
use Friendica\Test\DatabaseTest;
use Friendica\Test\Util\StaticCookie;
class CookieTest extends DatabaseTest
{
- /** @var MockInterface|Configuration */
+ /** @var MockInterface|IConfiguration */
private $config;
/** @var MockInterface|BaseURL */
private $baseUrl;
parent::setUp();
- $this->config = \Mockery::mock(Configuration::class);
+ $this->config = \Mockery::mock(IConfiguration::class);
$this->baseUrl = \Mockery::mock(BaseURL::class);
}
{
parent::setUp();
-
/** @var Dice|MockInterface $dice */
$dice = \Mockery::mock(Dice::class)->makePartial();
$dice = $dice->addRules(include __DIR__ . '/../../../static/dependencies.config.php');
$logger = new NullLogger();
$dice->shouldReceive('create')
- ->with(LoggerInterface::class)
+ ->with(LoggerInterface::class, [])
->andReturn($logger);
DI::init($dice);
namespace Friendica\Test\src\Util;
use Friendica\App\BaseURL;
-use Friendica\Core\Config\Configuration;
+use Friendica\Core\Config\IConfiguration;
use Friendica\Test\MockedTest;
class BaseURLTest extends MockedTest
*/
public function testCheck($server, $input, $assert)
{
- $configMock = \Mockery::mock(Configuration::class);
+ $configMock = \Mockery::mock(IConfiguration::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(Configuration::class);
+ $configMock = \Mockery::mock(IConfiguration::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(Configuration::class);
+ $configMock = \Mockery::mock(IConfiguration::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(Configuration::class);
+ $configMock = \Mockery::mock(IConfiguration::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(Configuration::class);
+ $configMock = \Mockery::mock(IConfiguration::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(Configuration::class);
+ $configMock = \Mockery::mock(IConfiguration::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\Configuration;
+use Friendica\Core\Config\IConfiguration;
use Friendica\Test\MockedTest;
use Friendica\Util\Profiler;
use Mockery\MockInterface;
$profiler->saveTimestamp(time(), 'network', 'test1');
- $config = \Mockery::mock(Configuration::class);
+ $config = \Mockery::mock(IConfiguration::class);
$config->shouldReceive('get')
->with('system', 'profiler')
->andReturn(false)