3 * @copyright Copyright (C) 2010-2023, the Friendica project
5 * @license GNU AGPL version 3 or any later version
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 * The configuration defines "complex" dependencies inside Friendica
21 * So this classes shouldn't be simple or their dependencies are already defined here.
23 * This kind of dependencies are NOT required to be defined here:
24 * - $a = new ClassA(new ClassB());
25 * - $a = new ClassA();
26 * - $a = new ClassA(Configuration $configuration);
28 * This kind of dependencies SHOULD be defined here:
29 * - $a = new ClassA();
32 * - $a = new ClassA($creationPassedVariable);
38 use Friendica\Core\Cache;
39 use Friendica\Core\Config;
40 use Friendica\Core\Hooks\Capabilities\ICanCreateInstances;
41 use Friendica\Core\Hooks\Capabilities\ICanRegisterInstances;
42 use Friendica\Core\Hooks\Model\DiceInstanceManager;
43 use Friendica\Core\PConfig;
44 use Friendica\Core\L10n;
45 use Friendica\Core\Lock;
46 use Friendica\Core\Session\Capability\IHandleSessions;
47 use Friendica\Core\Session\Capability\IHandleUserSessions;
48 use Friendica\Core\Storage\Repository\StorageManager;
49 use Friendica\Database\Database;
50 use Friendica\Database\Definition\DbaDefinition;
51 use Friendica\Database\Definition\ViewDefinition;
52 use Friendica\Factory;
53 use Friendica\Core\Storage\Capability\ICanWriteToStorage;
54 use Friendica\Model\User\Cookie;
55 use Friendica\Model\Log\ParsedLogIterator;
56 use Friendica\Network;
58 use Psr\Log\LoggerInterface;
62 // marks all class result as shared for other creations, so there's just
63 // one instance for the whole execution
66 \Friendica\Core\Addon\Capabilities\ICanLoadAddons::class => [
67 'instanceOf' => \Friendica\Core\Addon\Model\AddonLoader::class,
68 'constructParams' => [
69 [Dice::INSTANCE => '$basepath'],
70 [Dice::INSTANCE => Dice::SELF],
74 'instanceOf' => Util\BasePath::class,
76 ['getPath', [], Dice::CHAIN_CALL],
78 'constructParams' => [
83 Util\BasePath::class => [
84 'constructParams' => [
89 DiceInstanceManager::class => [
90 'constructParams' => [
91 [Dice::INSTANCE => Dice::SELF],
94 \Friendica\Core\Hooks\Util\HookFileManager::class => [
95 'constructParams' => [
96 [Dice::INSTANCE => '$basepath'],
99 ICanRegisterInstances::class => [
100 'instanceOf' => DiceInstanceManager::class,
101 'constructParams' => [
102 [Dice::INSTANCE => Dice::SELF],
105 ICanCreateInstances::class => [
106 'instanceOf' => DiceInstanceManager::class,
107 'constructParams' => [
108 [Dice::INSTANCE => Dice::SELF],
111 Config\Util\ConfigFileManager::class => [
112 'instanceOf' => Config\Factory\Config::class,
114 ['createConfigFileManager', [
115 [Dice::INSTANCE => '$basepath'],
117 ], Dice::CHAIN_CALL],
120 Config\ValueObject\Cache::class => [
121 'instanceOf' => Config\Factory\Config::class,
123 ['createCache', [], Dice::CHAIN_CALL],
128 ['determineRunMode', [true, $_SERVER], Dice::CHAIN_CALL],
130 [Dice::INSTANCE => '$basepath']
131 ], Dice::CHAIN_CALL],
134 Config\Capability\IManageConfigValues::class => [
135 'instanceOf' => Config\Model\DatabaseConfig::class,
136 'constructParams' => [
140 PConfig\Capability\IManagePersonalConfigValues::class => [
141 'instanceOf' => PConfig\Factory\PConfig::class,
143 ['create', [], Dice::CHAIN_CALL],
146 DbaDefinition::class => [
147 'constructParams' => [
148 [Dice::INSTANCE => '$basepath'],
151 ['load', [false], Dice::CHAIN_CALL],
154 ViewDefinition::class => [
155 'constructParams' => [
156 [Dice::INSTANCE => '$basepath'],
159 ['load', [false], Dice::CHAIN_CALL],
163 'constructParams' => [
164 [Dice::INSTANCE => Config\Model\ReadOnlyFileConfig::class],
168 * Creates the App\BaseURL
171 * $baseURL = new App\BaseURL($configuration, $_SERVER);
173 App\BaseURL::class => [
174 'constructParams' => [
179 'constructParams' => [
180 [Dice::INSTANCE => '$basepath'],
183 \Psr\Log\LoggerInterface::class => [
184 'instanceOf' => \Friendica\Core\Logger\Factory\Logger::class,
186 ['create', [], Dice::CHAIN_CALL],
189 \Friendica\Core\Logger\Type\SyslogLogger::class => [
190 'instanceOf' => \Friendica\Core\Logger\Factory\SyslogLogger::class,
192 ['create', [], Dice::CHAIN_CALL],
195 \Friendica\Core\Logger\Type\StreamLogger::class => [
196 'instanceOf' => \Friendica\Core\Logger\Factory\StreamLogger::class,
198 ['create', [], Dice::CHAIN_CALL],
201 \Friendica\Core\Logger\Type\ProfilerLogger::class => [
202 'instanceOf' => \Friendica\Core\Logger\Factory\ProfilerLogger::class,
204 ['create', [], Dice::CHAIN_CALL],
207 \Friendica\Core\Logger\Capabilities\IHaveCallIntrospections::class => [
208 'instanceOf' => \Friendica\Core\Logger\Util\Introspection::class,
209 'constructParams' => [
210 \Friendica\Core\Logger\Capabilities\IHaveCallIntrospections::IGNORE_CLASS_LIST,
214 'instanceOf' => \Friendica\Core\Logger\Factory\StreamLogger::class,
216 ['createDev', [], Dice::CHAIN_CALL],
219 Cache\Capability\ICanCache::class => [
220 'instanceOf' => Cache\Factory\Cache::class,
222 ['createLocal', [], Dice::CHAIN_CALL],
225 Cache\Capability\ICanCacheInMemory::class => [
226 'instanceOf' => Cache\Factory\Cache::class,
228 ['createLocal', [], Dice::CHAIN_CALL],
231 Lock\Capability\ICanLock::class => [
232 'instanceOf' => Lock\Factory\Lock::class,
234 ['create', [], Dice::CHAIN_CALL],
237 App\Arguments::class => [
238 'instanceOf' => App\Arguments::class,
240 ['determine', [$_SERVER, $_GET], Dice::CHAIN_CALL],
243 \Friendica\Core\System::class => [
244 'constructParams' => [
245 [Dice::INSTANCE => '$basepath'],
248 App\Router::class => [
249 'constructParams' => [
251 __DIR__ . '/routes.config.php',
252 [Dice::INSTANCE => Dice::SELF],
257 'constructParams' => [
261 IHandleSessions::class => [
262 'instanceOf' => \Friendica\Core\Session\Factory\Session::class,
264 ['create', [$_SERVER], Dice::CHAIN_CALL],
265 ['start', [], Dice::CHAIN_CALL],
268 IHandleUserSessions::class => [
269 'instanceOf' => \Friendica\Core\Session\Model\UserSession::class,
272 'constructParams' => [
276 ICanWriteToStorage::class => [
277 'instanceOf' => StorageManager::class,
279 ['getBackend', [], Dice::CHAIN_CALL],
282 \Friendica\Core\KeyValueStorage\Capabilities\IManageKeyValuePairs::class => [
283 'instanceOf' => \Friendica\Core\KeyValueStorage\Type\DBKeyValueStorage::class,
285 Network\HTTPClient\Capability\ICanSendHttpRequests::class => [
286 'instanceOf' => Network\HTTPClient\Factory\HttpClient::class,
288 ['createClient', [], Dice::CHAIN_CALL],
291 Factory\Api\Mastodon\Error::class => [
292 'constructParams' => [
296 ParsedLogIterator::class => [
297 'constructParams' => [
298 [Dice::INSTANCE => Util\ReversedFileReader::class],
301 \Friendica\Core\Worker\Repository\Process::class => [
302 'constructParams' => [
306 App\Request::class => [
307 'constructParams' => [
311 \Psr\Clock\ClockInterface::class => [
312 'instanceOf' => Util\Clock\SystemClock::class
314 \Friendica\Module\Special\HTTPException::class => [
315 'constructParams' => [