Unify "Capability"

This commit is contained in:
Philipp 2023-07-23 03:21:41 +02:00
parent 8ed94037d5
commit 9f18222a06
No known key found for this signature in database
GPG Key ID: 24A7501396EB5432
41 changed files with 72 additions and 72 deletions

View File

@ -58,7 +58,7 @@ if (php_sapi_name() !== 'cli') {
use Dice\Dice;
use Friendica\App\Mode;
use Friendica\Core\Logger\Capabilities\LogChannel;
use Friendica\Core\Logger\Capability\LogChannel;
use Friendica\Security\ExAuth;
use Psr\Log\LoggerInterface;
@ -79,8 +79,8 @@ chdir($directory);
require dirname(__DIR__) . '/vendor/autoload.php';
$dice = (new Dice())->addRules(include __DIR__ . '/../static/dependencies.config.php');
/** @var \Friendica\Core\Addon\Capabilities\ICanLoadAddons $addonLoader */
$addonLoader = $dice->create(\Friendica\Core\Addon\Capabilities\ICanLoadAddons::class);
/** @var \Friendica\Core\Addon\Capability\ICanLoadAddons $addonLoader */
$addonLoader = $dice->create(\Friendica\Core\Addon\Capability\ICanLoadAddons::class);
$dice = $dice->addRules($addonLoader->getActiveAddonConfig('dependencies'));
$dice = $dice->addRule(LoggerInterface::class,['constructParams' => [LogChannel::AUTH_JABBERED]]);

View File

@ -26,15 +26,15 @@ if (php_sapi_name() !== 'cli') {
}
use Dice\Dice;
use Friendica\Core\Logger\Capabilities\LogChannel;
use Friendica\Core\Logger\Capability\LogChannel;
use Friendica\DI;
use Psr\Log\LoggerInterface;
require dirname(__DIR__) . '/vendor/autoload.php';
$dice = (new Dice())->addRules(include __DIR__ . '/../static/dependencies.config.php');
/** @var \Friendica\Core\Addon\Capabilities\ICanLoadAddons $addonLoader */
$addonLoader = $dice->create(\Friendica\Core\Addon\Capabilities\ICanLoadAddons::class);
/** @var \Friendica\Core\Addon\Capability\ICanLoadAddons $addonLoader */
$addonLoader = $dice->create(\Friendica\Core\Addon\Capability\ICanLoadAddons::class);
$dice = $dice->addRules($addonLoader->getActiveAddonConfig('dependencies'));
$dice = $dice->addRule(LoggerInterface::class, ['constructParams' => [LogChannel::CONSOLE]]);

View File

@ -60,10 +60,10 @@ if (!file_exists('index.php') && (sizeof($_SERVER['argv']) != 0)) {
require dirname(__DIR__) . '/vendor/autoload.php';
$dice = (new Dice())->addRules(include __DIR__ . '/../static/dependencies.config.php');
/** @var \Friendica\Core\Addon\Capabilities\ICanLoadAddons $addonLoader */
$addonLoader = $dice->create(\Friendica\Core\Addon\Capabilities\ICanLoadAddons::class);
/** @var \Friendica\Core\Addon\Capability\ICanLoadAddons $addonLoader */
$addonLoader = $dice->create(\Friendica\Core\Addon\Capability\ICanLoadAddons::class);
$dice = $dice->addRules($addonLoader->getActiveAddonConfig('dependencies'));
$dice = $dice->addRule(LoggerInterface::class, ['constructParams' => [Logger\Capabilities\LogChannel::DAEMON]]);
$dice = $dice->addRule(LoggerInterface::class, ['constructParams' => [Logger\Capability\LogChannel::DAEMON]]);
DI::init($dice);
\Friendica\Core\Logger\Handler\ErrorHandler::register($dice->create(\Psr\Log\LoggerInterface::class));

View File

@ -29,7 +29,7 @@ if (php_sapi_name() !== 'cli') {
use Dice\Dice;
use Friendica\App;
use Friendica\App\Mode;
use Friendica\Core\Logger\Capabilities\LogChannel;
use Friendica\Core\Logger\Capability\LogChannel;
use Friendica\Core\Update;
use Friendica\Core\Worker;
use Friendica\DI;
@ -55,8 +55,8 @@ if (!file_exists("index.php") && (sizeof($_SERVER["argv"]) != 0)) {
require dirname(__DIR__) . '/vendor/autoload.php';
$dice = (new Dice())->addRules(include __DIR__ . '/../static/dependencies.config.php');
/** @var \Friendica\Core\Addon\Capabilities\ICanLoadAddons $addonLoader */
$addonLoader = $dice->create(\Friendica\Core\Addon\Capabilities\ICanLoadAddons::class);
/** @var \Friendica\Core\Addon\Capability\ICanLoadAddons $addonLoader */
$addonLoader = $dice->create(\Friendica\Core\Addon\Capability\ICanLoadAddons::class);
$dice = $dice->addRules($addonLoader->getActiveAddonConfig('dependencies'));
$dice = $dice->addRule(LoggerInterface::class, ['constructParams' => [LogChannel::WORKER]]);

View File

@ -10,9 +10,9 @@ This type of hook is based on the [Strategy Design Pattern](https://refactoring.
A strategy class defines a possible implementation of a given interface based on a unique name.
Every name is possible as long as it's unique and not `null`.
Using an empty name (`''`) is possible as well and should be used as the "default" implementation.
To register a strategy, use the [`ICanRegisterInstance`](../src/Core/Hooks/Capabilities/ICanRegisterInstances.php) interface.
To register a strategy, use the [`ICanRegisterInstance`](../src/Core/Hooks/Capability/ICanRegisterInstances.php) interface.
After registration, a caller can automatically create this instance with the [`ICanCreateInstances`](../src/Core/Hooks/Capabilities/ICanCreateInstances.php) interface and the chosen name.
After registration, a caller can automatically create this instance with the [`ICanCreateInstances`](../src/Core/Hooks/Capability/ICanCreateInstances.php) interface and the chosen name.
This is useful in case there are different, possible implementations for the same purpose, like for logging, locking, caching, ...
@ -43,11 +43,11 @@ public class ConcreteClassB implements ExampleInterface
}
}
/** @var \Friendica\Core\Hooks\Capabilities\ICanRegisterStrategies $instanceRegister */
/** @var \Friendica\Core\Hooks\Capability\ICanRegisterStrategies $instanceRegister */
$instanceRegister->registerStrategy(ExampleInterface::class, ConcreteClassA::class, 'A');
$instanceRegister->registerStrategy(ExampleInterface::class, ConcreteClassB::class, 'B');
/** @var \Friendica\Core\Hooks\Capabilities\ICanCreateInstances $instanceManager */
/** @var \Friendica\Core\Hooks\Capability\ICanCreateInstances $instanceManager */
/** @var ConcreteClassA $concreteClass */
$concreteClass = $instanceManager->create(ExampleInterface::class, 'A');
@ -62,14 +62,14 @@ To avoid registering all strategies manually inside the code, Friendica introduc
There, you can register all kind of strategies in one file.
### [`HookType::STRATEGY`](../src/Core/Hooks/Capabilities/HookType.php)
### [`HookType::STRATEGY`](../src/Core/Hooks/Capability/HookType.php)
For each given interface, a list of key-value pairs can be set, where the key is the concrete implementation class and the value is an array of unique names.
### Example
```php
use Friendica\Core\Hooks\Capabilities\BehavioralHookType as H;
use Friendica\Core\Hooks\Capability\BehavioralHookType as H;
return [
H::STRATEGY => [

View File

@ -30,8 +30,8 @@ if (!file_exists(__DIR__ . '/vendor/autoload.php')) {
require __DIR__ . '/vendor/autoload.php';
$dice = (new Dice())->addRules(include __DIR__ . '/static/dependencies.config.php');
/** @var \Friendica\Core\Addon\Capabilities\ICanLoadAddons $addonLoader */
$addonLoader = $dice->create(\Friendica\Core\Addon\Capabilities\ICanLoadAddons::class);
/** @var \Friendica\Core\Addon\Capability\ICanLoadAddons $addonLoader */
$addonLoader = $dice->create(\Friendica\Core\Addon\Capability\ICanLoadAddons::class);
$dice = $dice->addRules($addonLoader->getActiveAddonConfig('dependencies'));
$dice = $dice->addRule(Friendica\App\Mode::class, ['call' => [['determineRunMode', [false, $_SERVER], Dice::CHAIN_CALL]]]);

View File

@ -22,7 +22,7 @@
namespace Friendica\Console;
use Friendica\App;
use Friendica\Core\KeyValueStorage\Capabilities\IManageKeyValuePairs;
use Friendica\Core\KeyValueStorage\Capability\IManageKeyValuePairs;
use Friendica\Core\L10n;
use Friendica\Core\Update;

View File

@ -19,7 +19,7 @@
*
*/
namespace Friendica\Core\Addon\Capabilities;
namespace Friendica\Core\Addon\Capability;
/**
* Interface for loading Addons specific content

View File

@ -21,7 +21,7 @@
namespace Friendica\Core\Addon\Model;
use Friendica\Core\Addon\Capabilities\ICanLoadAddons;
use Friendica\Core\Addon\Capability\ICanLoadAddons;
use Friendica\Core\Addon\Exception\AddonInvalidConfigFileException;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Util\Strings;

View File

@ -27,7 +27,7 @@ use Friendica\Core\Cache\Exception\CachePersistenceException;
use Friendica\Core\Cache\Exception\InvalidCacheDriverException;
use Friendica\Core\Cache\Type;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\Hooks\Capabilities\ICanCreateInstances;
use Friendica\Core\Hooks\Capability\ICanCreateInstances;
use Friendica\Util\Profiler;
/**

View File

@ -19,7 +19,7 @@
*
*/
namespace Friendica\Core\Hooks\Capabilities;
namespace Friendica\Core\Hooks\Capability;
/**
* An enum of hook types, based on behavioral design patterns

View File

@ -19,7 +19,7 @@
*
*/
namespace Friendica\Core\Hooks\Capabilities;
namespace Friendica\Core\Hooks\Capability;
/**
* creates special instances for given classes

View File

@ -19,7 +19,7 @@
*
*/
namespace Friendica\Core\Hooks\Capabilities;
namespace Friendica\Core\Hooks\Capability;
use Friendica\Core\Hooks\Exceptions\HookRegisterArgumentException;

View File

@ -22,8 +22,8 @@
namespace Friendica\Core\Hooks\Model;
use Dice\Dice;
use Friendica\Core\Hooks\Capabilities\ICanCreateInstances;
use Friendica\Core\Hooks\Capabilities\ICanRegisterStrategies;
use Friendica\Core\Hooks\Capability\ICanCreateInstances;
use Friendica\Core\Hooks\Capability\ICanRegisterStrategies;
use Friendica\Core\Hooks\Exceptions\HookInstanceException;
use Friendica\Core\Hooks\Exceptions\HookRegisterArgumentException;
use Friendica\Core\Hooks\Util\StrategiesFileManager;

View File

@ -21,8 +21,8 @@
namespace Friendica\Core\Hooks\Util;
use Friendica\Core\Addon\Capabilities\ICanLoadAddons;
use Friendica\Core\Hooks\Capabilities\ICanRegisterStrategies;
use Friendica\Core\Addon\Capability\ICanLoadAddons;
use Friendica\Core\Hooks\Capability\ICanRegisterStrategies;
use Friendica\Core\Hooks\Exceptions\HookConfigException;
/**

View File

@ -19,7 +19,7 @@
*
*/
namespace Friendica\Core\KeyValueStorage\Capabilities;
namespace Friendica\Core\KeyValueStorage\Capability;
use Friendica\Core\KeyValueStorage\Exceptions\KeyValueStoragePersistenceException;

View File

@ -21,8 +21,8 @@
namespace Friendica\Core\KeyValueStorage\Factory;
use Friendica\Core\Hooks\Capabilities\ICanCreateInstances;
use Friendica\Core\KeyValueStorage\Capabilities\IManageKeyValuePairs;
use Friendica\Core\Hooks\Capability\ICanCreateInstances;
use Friendica\Core\KeyValueStorage\Capability\IManageKeyValuePairs;
class KeyValueStorage
{

View File

@ -21,7 +21,7 @@
namespace Friendica\Core\KeyValueStorage\Type;
use Friendica\Core\KeyValueStorage\Capabilities\IManageKeyValuePairs;
use Friendica\Core\KeyValueStorage\Capability\IManageKeyValuePairs;
/**
* An abstract helper class for Key-Value storage classes

View File

@ -19,7 +19,7 @@
*
*/
namespace Friendica\Core\Logger\Capabilities;
namespace Friendica\Core\Logger\Capability;
/**
* Whenever a logging specific check is necessary, use this interface to encapsulate and centralize this logic

View File

@ -19,7 +19,7 @@
*
*/
namespace Friendica\Core\Logger\Capabilities;
namespace Friendica\Core\Logger\Capability;
interface IHaveCallIntrospections
{

View File

@ -19,7 +19,7 @@
*
*/
namespace Friendica\Core\Logger\Capabilities;
namespace Friendica\Core\Logger\Capability;
/**
* An enum class for the Log channels

View File

@ -21,7 +21,7 @@
namespace Friendica\Core\Logger\Factory;
use Friendica\Core\Logger\Capabilities\IHaveCallIntrospections;
use Friendica\Core\Logger\Capability\IHaveCallIntrospections;
use Psr\Log\LogLevel;
/**

View File

@ -22,8 +22,8 @@
namespace Friendica\Core\Logger\Factory;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\Hooks\Capabilities\ICanCreateInstances;
use Friendica\Core\Logger\Capabilities\LogChannel;
use Friendica\Core\Hooks\Capability\ICanCreateInstances;
use Friendica\Core\Logger\Capability\LogChannel;
use Friendica\Core\Logger\Type\ProfilerLogger as ProfilerLoggerClass;
use Friendica\Util\Profiler;
use Psr\Log\LoggerInterface;

View File

@ -22,7 +22,7 @@
namespace Friendica\Core\Logger\Factory;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\Logger\Capabilities\LogChannel;
use Friendica\Core\Logger\Capability\LogChannel;
use Friendica\Core\Logger\Exception\LoggerArgumentException;
use Friendica\Core\Logger\Exception\LoggerException;
use Friendica\Core\Logger\Exception\LogLevelException;

View File

@ -21,7 +21,7 @@
namespace Friendica\Core\Logger\Type;
use Friendica\Core\Logger\Capabilities\IHaveCallIntrospections;
use Friendica\Core\Logger\Capability\IHaveCallIntrospections;
use Friendica\Core\Logger\Exception\LoggerException;
use Friendica\Util\Strings;
use Psr\Log\LoggerInterface;

View File

@ -21,7 +21,7 @@
namespace Friendica\Core\Logger\Type;
use Friendica\Core\Logger\Capabilities\IHaveCallIntrospections;
use Friendica\Core\Logger\Capability\IHaveCallIntrospections;
use Friendica\Core\Logger\Exception\LoggerException;
use Friendica\Core\Logger\Exception\LogLevelException;
use Friendica\Util\DateTimeFormat;

View File

@ -21,7 +21,7 @@
namespace Friendica\Core\Logger\Type;
use Friendica\Core\Logger\Capabilities\IHaveCallIntrospections;
use Friendica\Core\Logger\Capability\IHaveCallIntrospections;
use Friendica\Core\Logger\Exception\LoggerException;
use Friendica\Core\Logger\Exception\LogLevelException;
use Psr\Log\LogLevel;

View File

@ -22,7 +22,7 @@
namespace Friendica\Core\Logger\Util;
use Friendica\App\Request;
use Friendica\Core\Logger\Capabilities\IHaveCallIntrospections;
use Friendica\Core\Logger\Capability\IHaveCallIntrospections;
/**
* Get Introspection information about the current call

View File

@ -23,7 +23,7 @@ namespace Friendica\Core\Logger\Util;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\L10n;
use Friendica\Core\Logger\Capabilities\ICheckLoggerSettings;
use Friendica\Core\Logger\Capability\ICheckLoggerSettings;
use Friendica\Core\Logger\Exception\LoggerUnusableException;
/** {@inheritDoc} */

View File

@ -22,7 +22,7 @@
namespace Friendica\Core\PConfig\Factory;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\Hooks\Capabilities\ICanCreateInstances;
use Friendica\Core\Hooks\Capability\ICanCreateInstances;
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
class PConfig

View File

@ -22,7 +22,7 @@
namespace Friendica;
use Dice\Dice;
use Friendica\Core\Logger\Capabilities\ICheckLoggerSettings;
use Friendica\Core\Logger\Capability\ICheckLoggerSettings;
use Friendica\Core\Logger\Util\LoggerSettingsCheck;
use Friendica\Core\Session\Capability\IHandleSessions;
use Friendica\Core\Session\Capability\IHandleUserSessions;
@ -210,9 +210,9 @@ abstract class DI
return self::$dice->create(Core\Config\Util\ConfigFileManager::class);
}
public static function keyValue(): Core\KeyValueStorage\Capabilities\IManageKeyValuePairs
public static function keyValue(): Core\KeyValueStorage\Capability\IManageKeyValuePairs
{
return self::$dice->create(Core\KeyValueStorage\Capabilities\IManageKeyValuePairs::class);
return self::$dice->create(Core\KeyValueStorage\Capability\IManageKeyValuePairs::class);
}
/**

View File

@ -26,7 +26,7 @@ use Friendica\BaseModule;
use Friendica\Core\Addon;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\Hook;
use Friendica\Core\KeyValueStorage\Capabilities\IManageKeyValuePairs;
use Friendica\Core\KeyValueStorage\Capability\IManageKeyValuePairs;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\Core\Session\Capability\IHandleUserSessions;

View File

@ -25,7 +25,7 @@ use Friendica\App;
use Friendica\BaseModule;
use Friendica\Core\Addon;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\KeyValueStorage\Capabilities\IManageKeyValuePairs;
use Friendica\Core\KeyValueStorage\Capability\IManageKeyValuePairs;
use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Network\HTTPException\NotFoundException;

View File

@ -37,8 +37,8 @@ use Dice\Dice;
use Friendica\App;
use Friendica\Core\Cache;
use Friendica\Core\Config;
use Friendica\Core\Hooks\Capabilities\ICanCreateInstances;
use Friendica\Core\Hooks\Capabilities\ICanRegisterStrategies;
use Friendica\Core\Hooks\Capability\ICanCreateInstances;
use Friendica\Core\Hooks\Capability\ICanRegisterStrategies;
use Friendica\Core\Hooks\Model\DiceInstanceManager;
use Friendica\Core\PConfig;
use Friendica\Core\L10n;
@ -63,7 +63,7 @@ return [
// one instance for the whole execution
'shared' => true,
],
\Friendica\Core\Addon\Capabilities\ICanLoadAddons::class => [
\Friendica\Core\Addon\Capability\ICanLoadAddons::class => [
'instanceOf' => \Friendica\Core\Addon\Model\AddonLoader::class,
'constructParams' => [
[Dice::INSTANCE => '$basepath'],
@ -215,10 +215,10 @@ return [
['create', [], Dice::CHAIN_CALL],
],
],
\Friendica\Core\Logger\Capabilities\IHaveCallIntrospections::class => [
\Friendica\Core\Logger\Capability\IHaveCallIntrospections::class => [
'instanceOf' => \Friendica\Core\Logger\Util\Introspection::class,
'constructParams' => [
\Friendica\Core\Logger\Capabilities\IHaveCallIntrospections::IGNORE_CLASS_LIST,
\Friendica\Core\Logger\Capability\IHaveCallIntrospections::IGNORE_CLASS_LIST,
],
],
'$devLogger' => [
@ -290,7 +290,7 @@ return [
['getBackend', [], Dice::CHAIN_CALL],
],
],
\Friendica\Core\KeyValueStorage\Capabilities\IManageKeyValuePairs::class => [
\Friendica\Core\KeyValueStorage\Capability\IManageKeyValuePairs::class => [
'instanceOf' => \Friendica\Core\KeyValueStorage\Factory\KeyValueStorage::class,
'call' => [
['create', [], Dice::CHAIN_CALL],

View File

@ -38,7 +38,7 @@ return [
Cache\Type\MemcachedCache::class => ['memcached'],
Cache\Type\RedisCache::class => ['redis'],
],
KeyValueStorage\Capabilities\IManageKeyValuePairs::class => [
KeyValueStorage\Capability\IManageKeyValuePairs::class => [
KeyValueStorage\Type\DBKeyValueStorage::class => ['database', ''],
],
PConfig\Capability\IManagePersonalConfigValues::class => [

View File

@ -54,7 +54,7 @@ class AddonLoaderTest extends MockedTest
<?php
return [
\Friendica\Core\Hooks\Capabilities\BehavioralHookType::STRATEGY => [
\Friendica\Core\Hooks\Capability\BehavioralHookType::STRATEGY => [
\Psr\Log\LoggerInterface::class => [
\Psr\Log\NullLogger::class => [''],
],
@ -79,7 +79,7 @@ EOF;
'addon/testaddon1/static/hooks.config.php' => $this->content,
],
'assertion' => [
\Friendica\Core\Hooks\Capabilities\BehavioralHookType::STRATEGY => [
\Friendica\Core\Hooks\Capability\BehavioralHookType::STRATEGY => [
\Psr\Log\LoggerInterface::class => [
\Psr\Log\NullLogger::class => [''],
],
@ -94,7 +94,7 @@ EOF;
'addon/testaddon2/static/hooks.config.php' => $this->content,
],
'assertion' => [
\Friendica\Core\Hooks\Capabilities\BehavioralHookType::STRATEGY => [
\Friendica\Core\Hooks\Capability\BehavioralHookType::STRATEGY => [
\Psr\Log\LoggerInterface::class => [
\Psr\Log\NullLogger::class => ['', ''],
],
@ -118,7 +118,7 @@ EOF;
'addon/testaddon2/static/hooks.config.php' => $this->content,
],
'assertion' => [
\Friendica\Core\Hooks\Capabilities\BehavioralHookType::STRATEGY => [
\Friendica\Core\Hooks\Capability\BehavioralHookType::STRATEGY => [
\Psr\Log\LoggerInterface::class => [
\Psr\Log\NullLogger::class => [''],
],

View File

@ -21,8 +21,8 @@
namespace Friendica\Test\src\Core\Hooks\Util;
use Friendica\Core\Addon\Capabilities\ICanLoadAddons;
use Friendica\Core\Hooks\Capabilities\ICanRegisterStrategies;
use Friendica\Core\Addon\Capability\ICanLoadAddons;
use Friendica\Core\Hooks\Capability\ICanRegisterStrategies;
use Friendica\Core\Hooks\Exceptions\HookConfigException;
use Friendica\Core\Hooks\Util\StrategiesFileManager;
use Friendica\Test\MockedTest;

View File

@ -21,7 +21,7 @@
namespace Friendica\Test\src\Core\KeyValueStorage;
use Friendica\Core\KeyValueStorage\Capabilities\IManageKeyValuePairs;
use Friendica\Core\KeyValueStorage\Capability\IManageKeyValuePairs;
use Friendica\Core\KeyValueStorage\Type\DBKeyValueStorage;
use Friendica\Database\Database;
use Friendica\Test\Util\CreateDatabaseTrait;

View File

@ -21,7 +21,7 @@
namespace Friendica\Test\src\Core\KeyValueStorage;
use Friendica\Core\KeyValueStorage\Capabilities\IManageKeyValuePairs;
use Friendica\Core\KeyValueStorage\Capability\IManageKeyValuePairs;
use Friendica\Test\MockedTest;
abstract class KeyValueStorageTest extends MockedTest

View File

@ -21,7 +21,7 @@
namespace Friendica\Test\src\Core\Logger;
use Friendica\Core\Logger\Capabilities\IHaveCallIntrospections;
use Friendica\Core\Logger\Capability\IHaveCallIntrospections;
use Friendica\Core\Logger\Type\SyslogLogger;
/**