From: Philipp Date: Sun, 23 Jul 2023 01:21:41 +0000 (+0200) Subject: Unify "Capability" X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=9f18222a061342e3587ee6f38c4543d00948c0b8;p=friendica.git Unify "Capability" --- diff --git a/bin/auth_ejabberd.php b/bin/auth_ejabberd.php index b923009e64..3a95532464 100755 --- a/bin/auth_ejabberd.php +++ b/bin/auth_ejabberd.php @@ -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]]); diff --git a/bin/console.php b/bin/console.php index b2cde10823..b797e6ba99 100755 --- a/bin/console.php +++ b/bin/console.php @@ -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]]); diff --git a/bin/daemon.php b/bin/daemon.php index 11bad2b11a..cd774fe25e 100755 --- a/bin/daemon.php +++ b/bin/daemon.php @@ -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)); diff --git a/bin/worker.php b/bin/worker.php index 42a8f533d3..c855f9bc55 100755 --- a/bin/worker.php +++ b/bin/worker.php @@ -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]]); diff --git a/doc/StrategyHooks.md b/doc/StrategyHooks.md index 39fc1bd8df..2960ceeaad 100644 --- a/doc/StrategyHooks.md +++ b/doc/StrategyHooks.md @@ -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 => [ diff --git a/index.php b/index.php index ce82470b64..87778308a5 100644 --- a/index.php +++ b/index.php @@ -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]]]); diff --git a/src/Console/PostUpdate.php b/src/Console/PostUpdate.php index 742197e732..42cc63e109 100644 --- a/src/Console/PostUpdate.php +++ b/src/Console/PostUpdate.php @@ -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; diff --git a/src/Content/Item.php b/src/Content/Item.php index f7dda6c65f..c25e5296f0 100644 --- a/src/Content/Item.php +++ b/src/Content/Item.php @@ -544,7 +544,7 @@ class Item unset($item['owner-name']); unset($item['owner-avatar']); } - + $item['postopts'] = ''; } diff --git a/src/Core/Addon/Capabilities/ICanLoadAddons.php b/src/Core/Addon/Capabilities/ICanLoadAddons.php deleted file mode 100644 index 9c9d1e841c..0000000000 --- a/src/Core/Addon/Capabilities/ICanLoadAddons.php +++ /dev/null @@ -1,37 +0,0 @@ -. - * - */ - -namespace Friendica\Core\Addon\Capabilities; - -/** - * Interface for loading Addons specific content - */ -interface ICanLoadAddons -{ - /** - * Returns a merged config array of all active addons for a given config-name - * - * @param string $configName The config-name (config-file at the static directory, like 'hooks' => '{addon}/static/hooks.config.php) - * - * @return array the merged array - */ - public function getActiveAddonConfig(string $configName): array; -} diff --git a/src/Core/Addon/Capability/ICanLoadAddons.php b/src/Core/Addon/Capability/ICanLoadAddons.php new file mode 100644 index 0000000000..42af1a7b37 --- /dev/null +++ b/src/Core/Addon/Capability/ICanLoadAddons.php @@ -0,0 +1,37 @@ +. + * + */ + +namespace Friendica\Core\Addon\Capability; + +/** + * Interface for loading Addons specific content + */ +interface ICanLoadAddons +{ + /** + * Returns a merged config array of all active addons for a given config-name + * + * @param string $configName The config-name (config-file at the static directory, like 'hooks' => '{addon}/static/hooks.config.php) + * + * @return array the merged array + */ + public function getActiveAddonConfig(string $configName): array; +} diff --git a/src/Core/Addon/Model/AddonLoader.php b/src/Core/Addon/Model/AddonLoader.php index 952246af0a..e808f21777 100644 --- a/src/Core/Addon/Model/AddonLoader.php +++ b/src/Core/Addon/Model/AddonLoader.php @@ -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; diff --git a/src/Core/Cache/Factory/Cache.php b/src/Core/Cache/Factory/Cache.php index b6124c156d..02cdb1a79e 100644 --- a/src/Core/Cache/Factory/Cache.php +++ b/src/Core/Cache/Factory/Cache.php @@ -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; /** diff --git a/src/Core/Hooks/Capabilities/BehavioralHookType.php b/src/Core/Hooks/Capabilities/BehavioralHookType.php deleted file mode 100644 index 6336406e63..0000000000 --- a/src/Core/Hooks/Capabilities/BehavioralHookType.php +++ /dev/null @@ -1,37 +0,0 @@ -. - * - */ - -namespace Friendica\Core\Hooks\Capabilities; - -/** - * An enum of hook types, based on behavioral design patterns - * @see https://refactoring.guru/design-patterns/behavioral-patterns - */ -interface BehavioralHookType -{ - /** - * Defines the key for the list of strategy-hooks. - * - * @see https://refactoring.guru/design-patterns/strategy - */ - const STRATEGY = 'strategy'; - const EVENT = 'event'; -} diff --git a/src/Core/Hooks/Capabilities/ICanCreateInstances.php b/src/Core/Hooks/Capabilities/ICanCreateInstances.php deleted file mode 100644 index 77d4c4b366..0000000000 --- a/src/Core/Hooks/Capabilities/ICanCreateInstances.php +++ /dev/null @@ -1,41 +0,0 @@ -. - * - */ - -namespace Friendica\Core\Hooks\Capabilities; - -/** - * creates special instances for given classes - */ -interface ICanCreateInstances -{ - /** - * Returns a new instance of a given class for the corresponding name - * - * The instance will be build based on the registered strategy and the (unique) name - * - * @param string $class The fully-qualified name of the given class or interface which will get returned - * @param string $strategy An arbitrary identifier to find a concrete instance strategy. - * @param array $arguments Additional arguments, which can be passed to the constructor of "$class" at runtime - * - * @return object The concrete instance of the type "$class" - */ - public function create(string $class, string $strategy, array $arguments = []): object; -} diff --git a/src/Core/Hooks/Capabilities/ICanRegisterStrategies.php b/src/Core/Hooks/Capabilities/ICanRegisterStrategies.php deleted file mode 100644 index 911eb3499f..0000000000 --- a/src/Core/Hooks/Capabilities/ICanRegisterStrategies.php +++ /dev/null @@ -1,46 +0,0 @@ -. - * - */ - -namespace Friendica\Core\Hooks\Capabilities; - -use Friendica\Core\Hooks\Exceptions\HookRegisterArgumentException; - -/** - * Register strategies for given classes - */ -interface ICanRegisterStrategies -{ - /** - * Register a class(strategy) for a given interface with a unique name. - * - * @see https://refactoring.guru/design-patterns/strategy - * - * @param string $interface The interface, which the given class implements - * @param string $class The fully-qualified given class name - * A placeholder for dependencies is possible as well - * @param ?string $name An arbitrary identifier for the given strategy, which will be used for factories, dependency injections etc. - * - * @return $this This interface for chain-calls - * - * @throws HookRegisterArgumentException in case the given class for the interface isn't valid or already set - */ - public function registerStrategy(string $interface, string $class, ?string $name = null): self; -} diff --git a/src/Core/Hooks/Capability/BehavioralHookType.php b/src/Core/Hooks/Capability/BehavioralHookType.php new file mode 100644 index 0000000000..6de875e557 --- /dev/null +++ b/src/Core/Hooks/Capability/BehavioralHookType.php @@ -0,0 +1,37 @@ +. + * + */ + +namespace Friendica\Core\Hooks\Capability; + +/** + * An enum of hook types, based on behavioral design patterns + * @see https://refactoring.guru/design-patterns/behavioral-patterns + */ +interface BehavioralHookType +{ + /** + * Defines the key for the list of strategy-hooks. + * + * @see https://refactoring.guru/design-patterns/strategy + */ + const STRATEGY = 'strategy'; + const EVENT = 'event'; +} diff --git a/src/Core/Hooks/Capability/ICanCreateInstances.php b/src/Core/Hooks/Capability/ICanCreateInstances.php new file mode 100644 index 0000000000..55740d2767 --- /dev/null +++ b/src/Core/Hooks/Capability/ICanCreateInstances.php @@ -0,0 +1,41 @@ +. + * + */ + +namespace Friendica\Core\Hooks\Capability; + +/** + * creates special instances for given classes + */ +interface ICanCreateInstances +{ + /** + * Returns a new instance of a given class for the corresponding name + * + * The instance will be build based on the registered strategy and the (unique) name + * + * @param string $class The fully-qualified name of the given class or interface which will get returned + * @param string $strategy An arbitrary identifier to find a concrete instance strategy. + * @param array $arguments Additional arguments, which can be passed to the constructor of "$class" at runtime + * + * @return object The concrete instance of the type "$class" + */ + public function create(string $class, string $strategy, array $arguments = []): object; +} diff --git a/src/Core/Hooks/Capability/ICanRegisterStrategies.php b/src/Core/Hooks/Capability/ICanRegisterStrategies.php new file mode 100644 index 0000000000..875665764f --- /dev/null +++ b/src/Core/Hooks/Capability/ICanRegisterStrategies.php @@ -0,0 +1,46 @@ +. + * + */ + +namespace Friendica\Core\Hooks\Capability; + +use Friendica\Core\Hooks\Exceptions\HookRegisterArgumentException; + +/** + * Register strategies for given classes + */ +interface ICanRegisterStrategies +{ + /** + * Register a class(strategy) for a given interface with a unique name. + * + * @see https://refactoring.guru/design-patterns/strategy + * + * @param string $interface The interface, which the given class implements + * @param string $class The fully-qualified given class name + * A placeholder for dependencies is possible as well + * @param ?string $name An arbitrary identifier for the given strategy, which will be used for factories, dependency injections etc. + * + * @return $this This interface for chain-calls + * + * @throws HookRegisterArgumentException in case the given class for the interface isn't valid or already set + */ + public function registerStrategy(string $interface, string $class, ?string $name = null): self; +} diff --git a/src/Core/Hooks/Model/DiceInstanceManager.php b/src/Core/Hooks/Model/DiceInstanceManager.php index a8b0b540ce..194fc6e5c7 100644 --- a/src/Core/Hooks/Model/DiceInstanceManager.php +++ b/src/Core/Hooks/Model/DiceInstanceManager.php @@ -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; diff --git a/src/Core/Hooks/Util/StrategiesFileManager.php b/src/Core/Hooks/Util/StrategiesFileManager.php index 700c401f2b..d6651ac981 100644 --- a/src/Core/Hooks/Util/StrategiesFileManager.php +++ b/src/Core/Hooks/Util/StrategiesFileManager.php @@ -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; /** diff --git a/src/Core/KeyValueStorage/Capabilities/IManageKeyValuePairs.php b/src/Core/KeyValueStorage/Capabilities/IManageKeyValuePairs.php deleted file mode 100644 index c9d215c49c..0000000000 --- a/src/Core/KeyValueStorage/Capabilities/IManageKeyValuePairs.php +++ /dev/null @@ -1,64 +0,0 @@ -. - * - */ - -namespace Friendica\Core\KeyValueStorage\Capabilities; - -use Friendica\Core\KeyValueStorage\Exceptions\KeyValueStoragePersistenceException; - -/** - * Interface for Friendica specific Key-Value pair storage - */ -interface IManageKeyValuePairs extends \ArrayAccess -{ - /** - * Get a particular value from the KeyValue Storage - * - * @param string $key The key to query - * - * @return mixed Stored value or null if it does not exist - * - * @throws KeyValueStoragePersistenceException In case the persistence layer throws errors - * - */ - public function get(string $key); - - /** - * Sets a value for a given key - * - * Note: Please do not store booleans - convert to 0/1 integer values! - * - * @param string $key The configuration key to set - * @param mixed $value The value to store - * - * @throws KeyValueStoragePersistenceException In case the persistence layer throws errors - */ - public function set(string $key, $value): void; - - /** - * Deletes the given key. - * - * @param string $key The configuration key to delete - * - * @throws KeyValueStoragePersistenceException In case the persistence layer throws errors - * - */ - public function delete(string $key): void; -} diff --git a/src/Core/KeyValueStorage/Capability/IManageKeyValuePairs.php b/src/Core/KeyValueStorage/Capability/IManageKeyValuePairs.php new file mode 100644 index 0000000000..5d9c8455ee --- /dev/null +++ b/src/Core/KeyValueStorage/Capability/IManageKeyValuePairs.php @@ -0,0 +1,64 @@ +. + * + */ + +namespace Friendica\Core\KeyValueStorage\Capability; + +use Friendica\Core\KeyValueStorage\Exceptions\KeyValueStoragePersistenceException; + +/** + * Interface for Friendica specific Key-Value pair storage + */ +interface IManageKeyValuePairs extends \ArrayAccess +{ + /** + * Get a particular value from the KeyValue Storage + * + * @param string $key The key to query + * + * @return mixed Stored value or null if it does not exist + * + * @throws KeyValueStoragePersistenceException In case the persistence layer throws errors + * + */ + public function get(string $key); + + /** + * Sets a value for a given key + * + * Note: Please do not store booleans - convert to 0/1 integer values! + * + * @param string $key The configuration key to set + * @param mixed $value The value to store + * + * @throws KeyValueStoragePersistenceException In case the persistence layer throws errors + */ + public function set(string $key, $value): void; + + /** + * Deletes the given key. + * + * @param string $key The configuration key to delete + * + * @throws KeyValueStoragePersistenceException In case the persistence layer throws errors + * + */ + public function delete(string $key): void; +} diff --git a/src/Core/KeyValueStorage/Factory/KeyValueStorage.php b/src/Core/KeyValueStorage/Factory/KeyValueStorage.php index 1bce84f4e6..ee6cb17318 100644 --- a/src/Core/KeyValueStorage/Factory/KeyValueStorage.php +++ b/src/Core/KeyValueStorage/Factory/KeyValueStorage.php @@ -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 { diff --git a/src/Core/KeyValueStorage/Type/AbstractKeyValueStorage.php b/src/Core/KeyValueStorage/Type/AbstractKeyValueStorage.php index a6924b61f5..6b16665276 100644 --- a/src/Core/KeyValueStorage/Type/AbstractKeyValueStorage.php +++ b/src/Core/KeyValueStorage/Type/AbstractKeyValueStorage.php @@ -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 diff --git a/src/Core/Logger/Capabilities/ICheckLoggerSettings.php b/src/Core/Logger/Capabilities/ICheckLoggerSettings.php deleted file mode 100644 index fb93d18e80..0000000000 --- a/src/Core/Logger/Capabilities/ICheckLoggerSettings.php +++ /dev/null @@ -1,42 +0,0 @@ -. - * - */ - -namespace Friendica\Core\Logger\Capabilities; - -/** - * Whenever a logging specific check is necessary, use this interface to encapsulate and centralize this logic - */ -interface ICheckLoggerSettings -{ - /** - * Checks if the logfile is set and usable - * - * @return string|null null in case everything is ok, otherwise returns the error - */ - public function checkLogfile(): ?string; - - /** - * Checks if the debugging logfile is usable in case it is set! - * - * @return string|null null in case everything is ok, otherwise returns the error - */ - public function checkDebugLogfile(): ?string; -} diff --git a/src/Core/Logger/Capabilities/IHaveCallIntrospections.php b/src/Core/Logger/Capabilities/IHaveCallIntrospections.php deleted file mode 100644 index 83d75f976f..0000000000 --- a/src/Core/Logger/Capabilities/IHaveCallIntrospections.php +++ /dev/null @@ -1,51 +0,0 @@ -. - * - */ - -namespace Friendica\Core\Logger\Capabilities; - -interface IHaveCallIntrospections -{ - /** - * A list of classes, which shouldn't get logged - * - * @var string[] - */ - public const IGNORE_CLASS_LIST = [ - \Friendica\Core\Logger::class, - \Friendica\Core\Logger\Factory\Logger::class, - 'Friendica\\Core\\Logger\\Type', - \Friendica\Util\Profiler::class, - ]; - - /** - * Adds new classes to get skipped - * - * @param array $classNames - */ - public function addClasses(array $classNames): void; - - /** - * Returns the introspection record of the current call - * - * @return array - */ - public function getRecord(): array; -} diff --git a/src/Core/Logger/Capabilities/LogChannel.php b/src/Core/Logger/Capabilities/LogChannel.php deleted file mode 100644 index 31915168b9..0000000000 --- a/src/Core/Logger/Capabilities/LogChannel.php +++ /dev/null @@ -1,43 +0,0 @@ -. - * - */ - -namespace Friendica\Core\Logger\Capabilities; - -/** - * An enum class for the Log channels - */ -interface LogChannel -{ - /** @var string channel for the auth_ejabbered script */ - public const AUTH_JABBERED = 'auth_ejabberd'; - /** @var string Default channel in case it isn't set explicit */ - public const DEFAULT = self::APP; - /** @var string channel for console execution */ - public const CONSOLE = 'console'; - /** @var string channel for developer focused logging */ - public const DEV = 'dev'; - /** @var string channel for daemon executions */ - public const DAEMON = 'daemon'; - /** @var string channel for worker execution */ - public const WORKER = 'worker'; - /** @var string channel for frontend app executions */ - public const APP = 'app'; -} diff --git a/src/Core/Logger/Capability/ICheckLoggerSettings.php b/src/Core/Logger/Capability/ICheckLoggerSettings.php new file mode 100644 index 0000000000..abdbc3b50a --- /dev/null +++ b/src/Core/Logger/Capability/ICheckLoggerSettings.php @@ -0,0 +1,42 @@ +. + * + */ + +namespace Friendica\Core\Logger\Capability; + +/** + * Whenever a logging specific check is necessary, use this interface to encapsulate and centralize this logic + */ +interface ICheckLoggerSettings +{ + /** + * Checks if the logfile is set and usable + * + * @return string|null null in case everything is ok, otherwise returns the error + */ + public function checkLogfile(): ?string; + + /** + * Checks if the debugging logfile is usable in case it is set! + * + * @return string|null null in case everything is ok, otherwise returns the error + */ + public function checkDebugLogfile(): ?string; +} diff --git a/src/Core/Logger/Capability/IHaveCallIntrospections.php b/src/Core/Logger/Capability/IHaveCallIntrospections.php new file mode 100644 index 0000000000..918232af39 --- /dev/null +++ b/src/Core/Logger/Capability/IHaveCallIntrospections.php @@ -0,0 +1,51 @@ +. + * + */ + +namespace Friendica\Core\Logger\Capability; + +interface IHaveCallIntrospections +{ + /** + * A list of classes, which shouldn't get logged + * + * @var string[] + */ + public const IGNORE_CLASS_LIST = [ + \Friendica\Core\Logger::class, + \Friendica\Core\Logger\Factory\Logger::class, + 'Friendica\\Core\\Logger\\Type', + \Friendica\Util\Profiler::class, + ]; + + /** + * Adds new classes to get skipped + * + * @param array $classNames + */ + public function addClasses(array $classNames): void; + + /** + * Returns the introspection record of the current call + * + * @return array + */ + public function getRecord(): array; +} diff --git a/src/Core/Logger/Capability/LogChannel.php b/src/Core/Logger/Capability/LogChannel.php new file mode 100644 index 0000000000..c3b6316440 --- /dev/null +++ b/src/Core/Logger/Capability/LogChannel.php @@ -0,0 +1,43 @@ +. + * + */ + +namespace Friendica\Core\Logger\Capability; + +/** + * An enum class for the Log channels + */ +interface LogChannel +{ + /** @var string channel for the auth_ejabbered script */ + public const AUTH_JABBERED = 'auth_ejabberd'; + /** @var string Default channel in case it isn't set explicit */ + public const DEFAULT = self::APP; + /** @var string channel for console execution */ + public const CONSOLE = 'console'; + /** @var string channel for developer focused logging */ + public const DEV = 'dev'; + /** @var string channel for daemon executions */ + public const DAEMON = 'daemon'; + /** @var string channel for worker execution */ + public const WORKER = 'worker'; + /** @var string channel for frontend app executions */ + public const APP = 'app'; +} diff --git a/src/Core/Logger/Factory/AbstractLoggerTypeFactory.php b/src/Core/Logger/Factory/AbstractLoggerTypeFactory.php index 402176d8e6..86dfeae63b 100644 --- a/src/Core/Logger/Factory/AbstractLoggerTypeFactory.php +++ b/src/Core/Logger/Factory/AbstractLoggerTypeFactory.php @@ -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; /** diff --git a/src/Core/Logger/Factory/Logger.php b/src/Core/Logger/Factory/Logger.php index c370cc4dd7..f1086f5853 100644 --- a/src/Core/Logger/Factory/Logger.php +++ b/src/Core/Logger/Factory/Logger.php @@ -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; diff --git a/src/Core/Logger/Factory/StreamLogger.php b/src/Core/Logger/Factory/StreamLogger.php index caad78e3b4..7f32d66b1d 100644 --- a/src/Core/Logger/Factory/StreamLogger.php +++ b/src/Core/Logger/Factory/StreamLogger.php @@ -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; diff --git a/src/Core/Logger/Type/AbstractLogger.php b/src/Core/Logger/Type/AbstractLogger.php index 77a61e9206..e592ee86d6 100644 --- a/src/Core/Logger/Type/AbstractLogger.php +++ b/src/Core/Logger/Type/AbstractLogger.php @@ -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; diff --git a/src/Core/Logger/Type/StreamLogger.php b/src/Core/Logger/Type/StreamLogger.php index 87f1a3937f..e09a320473 100644 --- a/src/Core/Logger/Type/StreamLogger.php +++ b/src/Core/Logger/Type/StreamLogger.php @@ -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; diff --git a/src/Core/Logger/Type/SyslogLogger.php b/src/Core/Logger/Type/SyslogLogger.php index 88dc1964dd..fb8cb97ae7 100644 --- a/src/Core/Logger/Type/SyslogLogger.php +++ b/src/Core/Logger/Type/SyslogLogger.php @@ -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; diff --git a/src/Core/Logger/Util/Introspection.php b/src/Core/Logger/Util/Introspection.php index e0f7e85540..0b703da825 100644 --- a/src/Core/Logger/Util/Introspection.php +++ b/src/Core/Logger/Util/Introspection.php @@ -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 diff --git a/src/Core/Logger/Util/LoggerSettingsCheck.php b/src/Core/Logger/Util/LoggerSettingsCheck.php index 7782216dab..cb598d5f2d 100644 --- a/src/Core/Logger/Util/LoggerSettingsCheck.php +++ b/src/Core/Logger/Util/LoggerSettingsCheck.php @@ -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} */ diff --git a/src/Core/PConfig/Factory/PConfig.php b/src/Core/PConfig/Factory/PConfig.php index 4195619bc2..0596752899 100644 --- a/src/Core/PConfig/Factory/PConfig.php +++ b/src/Core/PConfig/Factory/PConfig.php @@ -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 diff --git a/src/DI.php b/src/DI.php index 1917f710d3..34cf1c68d5 100644 --- a/src/DI.php +++ b/src/DI.php @@ -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); } /** diff --git a/src/Module/Friendica.php b/src/Module/Friendica.php index c6e2768bd3..1bd6bd411e 100644 --- a/src/Module/Friendica.php +++ b/src/Module/Friendica.php @@ -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; diff --git a/src/Module/Statistics.php b/src/Module/Statistics.php index 514f10bb73..e69f754216 100644 --- a/src/Module/Statistics.php +++ b/src/Module/Statistics.php @@ -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; @@ -38,7 +38,7 @@ class Statistics extends BaseModule protected $config; /** @var IManageKeyValuePairs */ protected $keyValue; - + public function __construct(L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, IManageConfigValues $config, IManageKeyValuePairs $keyValue, Response $response, array $server, array $parameters = []) { parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); diff --git a/static/dependencies.config.php b/static/dependencies.config.php index 9c1ead9053..3dfde6b5f4 100644 --- a/static/dependencies.config.php +++ b/static/dependencies.config.php @@ -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], diff --git a/static/strategies.config.php b/static/strategies.config.php index 339a59a878..8df0c04788 100644 --- a/static/strategies.config.php +++ b/static/strategies.config.php @@ -38,11 +38,11 @@ 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 => [ - PConfig\Type\JitPConfig::class => ['jit'], + PConfig\Type\JitPConfig::class => ['jit'], PConfig\Type\PreloadPConfig::class => ['preload', ''], ], ]; diff --git a/tests/src/Core/Addon/Model/AddonLoaderTest.php b/tests/src/Core/Addon/Model/AddonLoaderTest.php index 189110fded..f49333b32d 100644 --- a/tests/src/Core/Addon/Model/AddonLoaderTest.php +++ b/tests/src/Core/Addon/Model/AddonLoaderTest.php @@ -54,7 +54,7 @@ class AddonLoaderTest extends MockedTest [ + \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 => [''], ], diff --git a/tests/src/Core/Hooks/Util/StrategiesFileManagerTest.php b/tests/src/Core/Hooks/Util/StrategiesFileManagerTest.php index 592f6f1e06..ebb213fa7b 100644 --- a/tests/src/Core/Hooks/Util/StrategiesFileManagerTest.php +++ b/tests/src/Core/Hooks/Util/StrategiesFileManagerTest.php @@ -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; diff --git a/tests/src/Core/KeyValueStorage/DBKeyValueStorageTest.php b/tests/src/Core/KeyValueStorage/DBKeyValueStorageTest.php index 80a0f16de0..3a3b255365 100644 --- a/tests/src/Core/KeyValueStorage/DBKeyValueStorageTest.php +++ b/tests/src/Core/KeyValueStorage/DBKeyValueStorageTest.php @@ -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; diff --git a/tests/src/Core/KeyValueStorage/KeyValueStorageTest.php b/tests/src/Core/KeyValueStorage/KeyValueStorageTest.php index 6ccc0f5f4d..ddb0acc4dc 100644 --- a/tests/src/Core/KeyValueStorage/KeyValueStorageTest.php +++ b/tests/src/Core/KeyValueStorage/KeyValueStorageTest.php @@ -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 diff --git a/tests/src/Core/Logger/SyslogLoggerWrapper.php b/tests/src/Core/Logger/SyslogLoggerWrapper.php index 1e0c4535f9..dce28b164c 100644 --- a/tests/src/Core/Logger/SyslogLoggerWrapper.php +++ b/tests/src/Core/Logger/SyslogLoggerWrapper.php @@ -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; /**