]> git.mxchange.org Git - friendica.git/blobdiff - static/dependencies.config.php
Introduce dynamic hook loading
[friendica.git] / static / dependencies.config.php
index bbf8c5599c1d65e6769b34b62ff859db150eea2d..2b246f84529a7cc028bf61fec51bcfb8fc86b37c 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2021, the Friendica project
+ * @copyright Copyright (C) 2010-2023, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -37,13 +37,18 @@ 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\ICanRegisterInstances;
+use Friendica\Core\Hooks\Model\DiceInstanceManager;
 use Friendica\Core\PConfig;
 use Friendica\Core\L10n;
 use Friendica\Core\Lock;
-use Friendica\Core\Process;
 use Friendica\Core\Session\Capability\IHandleSessions;
+use Friendica\Core\Session\Capability\IHandleUserSessions;
 use Friendica\Core\Storage\Repository\StorageManager;
 use Friendica\Database\Database;
+use Friendica\Database\Definition\DbaDefinition;
+use Friendica\Database\Definition\ViewDefinition;
 use Friendica\Factory;
 use Friendica\Core\Storage\Capability\ICanWriteToStorage;
 use Friendica\Model\User\Cookie;
@@ -58,6 +63,13 @@ return [
                // one instance for the whole execution
                'shared' => true,
        ],
+       \Friendica\Core\Addon\Capabilities\ICanLoadAddons::class => [
+               'instanceOf' => \Friendica\Core\Addon\Model\AddonLoader::class,
+               'constructParams' => [
+                       [Dice::INSTANCE => '$basepath'],
+                       [Dice::INSTANCE => Dice::SELF],
+               ],
+       ],
        '$basepath'                     => [
                'instanceOf'      => Util\BasePath::class,
                'call'            => [
@@ -74,10 +86,32 @@ return [
                        $_SERVER
                ]
        ],
-       Config\Util\ConfigFileLoader::class => [
+       DiceInstanceManager::class   => [
+               'constructParams' => [
+                       [Dice::INSTANCE => Dice::SELF],
+               ]
+       ],
+       \Friendica\Core\Hooks\Util\HookFileManager::class => [
+               'constructParams' => [
+                       [Dice::INSTANCE => '$basepath'],
+               ],
+       ],
+       ICanRegisterInstances::class => [
+               'instanceOf' => DiceInstanceManager::class,
+               'constructParams' => [
+                       [Dice::INSTANCE => Dice::SELF],
+               ],
+       ],
+       ICanCreateInstances::class   => [
+               'instanceOf' => DiceInstanceManager::class,
+               'constructParams' => [
+                       [Dice::INSTANCE => Dice::SELF],
+               ],
+       ],
+       Config\Util\ConfigFileManager::class => [
                'instanceOf' => Config\Factory\Config::class,
                'call'       => [
-                       ['createConfigFileLoader', [
+                       ['createConfigFileManager', [
                                [Dice::INSTANCE => '$basepath'],
                                $_SERVER,
                        ], Dice::CHAIN_CALL],
@@ -86,19 +120,21 @@ return [
        Config\ValueObject\Cache::class => [
                'instanceOf' => Config\Factory\Config::class,
                'call'       => [
-                       ['createCache', [$_SERVER], Dice::CHAIN_CALL],
+                       ['createCache', [], Dice::CHAIN_CALL],
                ],
        ],
        App\Mode::class              => [
                'call' => [
                        ['determineRunMode', [true, $_SERVER], Dice::CHAIN_CALL],
-                       ['determine', [], Dice::CHAIN_CALL],
+                       ['determine', [
+                               [Dice::INSTANCE => '$basepath']
+                       ], Dice::CHAIN_CALL],
                ],
        ],
        Config\Capability\IManageConfigValues::class => [
-               'instanceOf' => Config\Factory\Config::class,
-               'call'       => [
-                       ['create', [], Dice::CHAIN_CALL],
+               'instanceOf' => Config\Model\DatabaseConfig::class,
+               'constructParams' => [
+                       $_SERVER,
                ],
        ],
        PConfig\Capability\IManagePersonalConfigValues::class => [
@@ -107,9 +143,25 @@ return [
                        ['create', [], Dice::CHAIN_CALL],
                ]
        ],
+       DbaDefinition::class => [
+               'constructParams' => [
+                       [Dice::INSTANCE => '$basepath'],
+               ],
+               'call' => [
+                       ['load', [false], Dice::CHAIN_CALL],
+               ],
+       ],
+       ViewDefinition::class => [
+               'constructParams' => [
+                       [Dice::INSTANCE => '$basepath'],
+               ],
+               'call' => [
+                       ['load', [false], Dice::CHAIN_CALL],
+               ],
+       ],
        Database::class                         => [
                'constructParams' => [
-                       [Dice::INSTANCE => \Psr\Log\NullLogger::class],
+                       [Dice::INSTANCE => Config\Model\ReadOnlyFileConfig::class],
                ],
        ],
        /**
@@ -128,46 +180,52 @@ return [
                        [Dice::INSTANCE => '$basepath'],
                ],
        ],
-       /**
-        * Create a Logger, which implements the LoggerInterface
-        *
-        * Same as:
-        *   $loggerFactory = new Factory\LoggerFactory();
-        *   $logger = $loggerFactory->create($channel, $configuration, $profiler);
-        *
-        * Attention1: We can use DICE for detecting dependencies inside "chained" calls too
-        * Attention2: The variable "$channel" is passed inside the creation of the dependencies per:
-        *    $app = $dice->create(App::class, [], ['$channel' => 'index']);
-        *    and is automatically passed as an argument with the same name
-        */
-       LoggerInterface::class          => [
-               'instanceOf' => Factory\LoggerFactory::class,
-               'constructParams' => [
-                       'index',
+       \Psr\Log\LoggerInterface::class                                    => [
+               'instanceOf' => \Friendica\Core\Logger\Factory\Logger::class,
+               'call'       => [
+                       ['create', [], Dice::CHAIN_CALL],
                ],
+       ],
+       \Friendica\Core\Logger\Type\SyslogLogger::class                    => [
+               'instanceOf' => \Friendica\Core\Logger\Factory\SyslogLogger::class,
                'call'       => [
-                       ['create', ['index'], Dice::CHAIN_CALL],
+                       ['create', [], Dice::CHAIN_CALL],
                ],
        ],
-       '$devLogger'                    => [
-               'instanceOf' => Factory\LoggerFactory::class,
+       \Friendica\Core\Logger\Type\StreamLogger::class                    => [
+               'instanceOf' => \Friendica\Core\Logger\Factory\StreamLogger::class,
+               'call'       => [
+                       ['create', [], Dice::CHAIN_CALL],
+               ],
+       ],
+       \Friendica\Core\Logger\Type\ProfilerLogger::class                  => [
+               'instanceOf' => \Friendica\Core\Logger\Factory\ProfilerLogger::class,
+               'call'       => [
+                       ['create', [], Dice::CHAIN_CALL],
+               ],
+       ],
+       \Friendica\Core\Logger\Capabilities\IHaveCallIntrospections::class => [
+               'instanceOf'      => \Friendica\Core\Logger\Util\Introspection::class,
                'constructParams' => [
-                       'dev',
+                       \Friendica\Core\Logger\Capabilities\IHaveCallIntrospections::IGNORE_CLASS_LIST,
                ],
+       ],
+       '$devLogger'                                                       => [
+               'instanceOf' => \Friendica\Core\Logger\Factory\StreamLogger::class,
                'call'       => [
                        ['createDev', [], Dice::CHAIN_CALL],
-               ]
+               ],
        ],
        Cache\Capability\ICanCache::class => [
                'instanceOf' => Cache\Factory\Cache::class,
                'call'       => [
-                       ['create', [], Dice::CHAIN_CALL],
+                       ['createLocal', [], Dice::CHAIN_CALL],
                ],
        ],
        Cache\Capability\ICanCacheInMemory::class => [
                'instanceOf' => Cache\Factory\Cache::class,
                'call'       => [
-                       ['create', [], Dice::CHAIN_CALL],
+                       ['createLocal', [], Dice::CHAIN_CALL],
                ],
        ],
        Lock\Capability\ICanLock::class => [
@@ -182,22 +240,16 @@ return [
                        ['determine', [$_SERVER, $_GET], Dice::CHAIN_CALL],
                ],
        ],
-       App\Module::class => [
-               'instanceOf' => App\Module::class,
-               'call' => [
-                       ['determineModule', [], Dice::CHAIN_CALL],
-               ],
-       ],
-       Process::class => [
+       \Friendica\Core\System::class => [
                'constructParams' => [
                        [Dice::INSTANCE => '$basepath'],
-                       getmypid(),
                ],
        ],
        App\Router::class => [
                'constructParams' => [
                        $_SERVER,
                        __DIR__ . '/routes.config.php',
+                       [Dice::INSTANCE => Dice::SELF],
                        null
                ],
        ],
@@ -209,13 +261,16 @@ return [
        IHandleSessions::class => [
                'instanceOf' => \Friendica\Core\Session\Factory\Session::class,
                'call' => [
-                       ['createSession', [$_SERVER], Dice::CHAIN_CALL],
+                       ['create', [$_SERVER], Dice::CHAIN_CALL],
                        ['start', [], Dice::CHAIN_CALL],
                ],
        ],
+       IHandleUserSessions::class => [
+               'instanceOf' => \Friendica\Core\Session\Model\UserSession::class,
+       ],
        Cookie::class => [
                'constructParams' => [
-                       $_SERVER, $_COOKIE
+                       $_COOKIE
                ],
        ],
        ICanWriteToStorage::class => [
@@ -224,8 +279,11 @@ return [
                        ['getBackend', [], Dice::CHAIN_CALL],
                ],
        ],
-       Network\IHTTPClient::class => [
-               'instanceOf' => Factory\HTTPClientFactory::class,
+       \Friendica\Core\KeyValueStorage\Capabilities\IManageKeyValuePairs::class => [
+               'instanceOf' => \Friendica\Core\KeyValueStorage\Type\DBKeyValueStorage::class,
+       ],
+       Network\HTTPClient\Capability\ICanSendHttpRequests::class => [
+               'instanceOf' => Network\HTTPClient\Factory\HttpClient::class,
                'call'       => [
                        ['createClient', [], Dice::CHAIN_CALL],
                ],
@@ -240,4 +298,22 @@ return [
                        [Dice::INSTANCE => Util\ReversedFileReader::class],
                ]
        ],
+       \Friendica\Core\Worker\Repository\Process::class => [
+               'constructParams' => [
+                       $_SERVER
+               ],
+       ],
+       App\Request::class => [
+               'constructParams' => [
+                       $_SERVER
+               ],
+       ],
+       \Psr\Clock\ClockInterface::class => [
+               'instanceOf' => Util\Clock\SystemClock::class
+       ],
+       \Friendica\Module\Special\HTTPException::class => [
+               'constructParams' => [
+                       $_SERVER
+               ],
+       ],
 ];