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\Capability\ICanCreateInstances;
41 use Friendica\Core\Hooks\Capability\ICanRegisterStrategies;
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\Capability\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\StrategiesFileManager::class => [
95 'constructParams' => [
96 [Dice::INSTANCE => '$basepath'],
102 ICanRegisterStrategies::class => [
103 'instanceOf' => DiceInstanceManager::class,
104 'constructParams' => [
105 [Dice::INSTANCE => Dice::SELF],
108 ICanCreateInstances::class => [
109 'instanceOf' => DiceInstanceManager::class,
110 'constructParams' => [
111 [Dice::INSTANCE => Dice::SELF],
114 Config\Util\ConfigFileManager::class => [
115 'instanceOf' => Config\Factory\Config::class,
117 ['createConfigFileManager', [
118 [Dice::INSTANCE => '$basepath'],
120 ], Dice::CHAIN_CALL],
123 Config\ValueObject\Cache::class => [
124 'instanceOf' => Config\Factory\Config::class,
126 ['createCache', [], Dice::CHAIN_CALL],
131 ['determineRunMode', [true, $_SERVER], Dice::CHAIN_CALL],
133 [Dice::INSTANCE => '$basepath']
134 ], Dice::CHAIN_CALL],
137 Config\Capability\IManageConfigValues::class => [
138 'instanceOf' => Config\Model\DatabaseConfig::class,
139 'constructParams' => [
143 PConfig\Capability\IManagePersonalConfigValues::class => [
144 'instanceOf' => PConfig\Factory\PConfig::class,
146 ['create', [], Dice::CHAIN_CALL],
149 DbaDefinition::class => [
150 'constructParams' => [
151 [Dice::INSTANCE => '$basepath'],
154 ['load', [false], Dice::CHAIN_CALL],
157 ViewDefinition::class => [
158 'constructParams' => [
159 [Dice::INSTANCE => '$basepath'],
162 ['load', [false], Dice::CHAIN_CALL],
166 'constructParams' => [
167 [Dice::INSTANCE => Config\Model\ReadOnlyFileConfig::class],
171 * Creates the App\BaseURL
174 * $baseURL = new App\BaseURL($configuration, $_SERVER);
176 App\BaseURL::class => [
177 'constructParams' => [
182 'instanceOf' => App\BaseURL::class,
183 'constructParams' => [
187 ['getHost', [], Dice::CHAIN_CALL],
190 Cache\Type\AbstractCache::class => [
191 'constructParams' => [
192 [Dice::INSTANCE => '$hostname'],
196 'constructParams' => [
197 [Dice::INSTANCE => '$basepath'],
200 \Psr\Log\LoggerInterface::class => [
201 'instanceOf' => \Friendica\Core\Logger\Factory\Logger::class,
203 ['create', [], Dice::CHAIN_CALL],
206 \Friendica\Core\Logger\Type\SyslogLogger::class => [
207 'instanceOf' => \Friendica\Core\Logger\Factory\SyslogLogger::class,
209 ['create', [], Dice::CHAIN_CALL],
212 \Friendica\Core\Logger\Type\StreamLogger::class => [
213 'instanceOf' => \Friendica\Core\Logger\Factory\StreamLogger::class,
215 ['create', [], Dice::CHAIN_CALL],
218 \Friendica\Core\Logger\Capability\IHaveCallIntrospections::class => [
219 'instanceOf' => \Friendica\Core\Logger\Util\Introspection::class,
220 'constructParams' => [
221 \Friendica\Core\Logger\Capability\IHaveCallIntrospections::IGNORE_CLASS_LIST,
225 'instanceOf' => \Friendica\Core\Logger\Factory\StreamLogger::class,
227 ['createDev', [], Dice::CHAIN_CALL],
230 Cache\Capability\ICanCache::class => [
231 'instanceOf' => Cache\Factory\Cache::class,
233 ['createLocal', [], Dice::CHAIN_CALL],
236 Cache\Capability\ICanCacheInMemory::class => [
237 'instanceOf' => Cache\Factory\Cache::class,
239 ['createLocal', [], Dice::CHAIN_CALL],
242 Lock\Capability\ICanLock::class => [
243 'instanceOf' => Lock\Factory\Lock::class,
245 ['create', [], Dice::CHAIN_CALL],
248 App\Arguments::class => [
249 'instanceOf' => App\Arguments::class,
251 ['determine', [$_SERVER, $_GET], Dice::CHAIN_CALL],
254 \Friendica\Core\System::class => [
255 'constructParams' => [
256 [Dice::INSTANCE => '$basepath'],
259 App\Router::class => [
260 'constructParams' => [
262 __DIR__ . '/routes.config.php',
263 [Dice::INSTANCE => Dice::SELF],
268 'constructParams' => [
272 IHandleSessions::class => [
273 'instanceOf' => \Friendica\Core\Session\Factory\Session::class,
275 ['create', [$_SERVER], Dice::CHAIN_CALL],
276 ['start', [], Dice::CHAIN_CALL],
279 IHandleUserSessions::class => [
280 'instanceOf' => \Friendica\Core\Session\Model\UserSession::class,
283 'constructParams' => [
287 ICanWriteToStorage::class => [
288 'instanceOf' => StorageManager::class,
290 ['getBackend', [], Dice::CHAIN_CALL],
293 \Friendica\Core\KeyValueStorage\Capability\IManageKeyValuePairs::class => [
294 'instanceOf' => \Friendica\Core\KeyValueStorage\Factory\KeyValueStorage::class,
296 ['create', [], Dice::CHAIN_CALL],
299 Network\HTTPClient\Capability\ICanSendHttpRequests::class => [
300 'instanceOf' => Network\HTTPClient\Factory\HttpClient::class,
302 ['createClient', [], Dice::CHAIN_CALL],
305 Factory\Api\Mastodon\Error::class => [
306 'constructParams' => [
310 ParsedLogIterator::class => [
311 'constructParams' => [
312 [Dice::INSTANCE => Util\ReversedFileReader::class],
315 \Friendica\Core\Worker\Repository\Process::class => [
316 'constructParams' => [
320 App\Request::class => [
321 'constructParams' => [
325 \Psr\Clock\ClockInterface::class => [
326 'instanceOf' => Util\Clock\SystemClock::class
328 \Friendica\Module\Special\HTTPException::class => [
329 'constructParams' => [
333 \Friendica\Module\Api\ApiResponse::class => [
334 'constructParams' => [
336 $_GET['callback'] ?? '',