]> git.mxchange.org Git - friendica.git/blob - static/dependencies.config.php
98a9f3077db211bec8140bdd2d155dbeb48138b0
[friendica.git] / static / dependencies.config.php
1 <?php
2 /**
3  * @copyright Copyright (C) 2010-2023, the Friendica project
4  *
5  * @license GNU AGPL version 3 or any later version
6  *
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.
11  *
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.
16  *
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/>.
19  *
20  * The configuration defines "complex" dependencies inside Friendica
21  * So this classes shouldn't be simple or their dependencies are already defined here.
22  *
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);
27  *
28  * This kind of dependencies SHOULD be defined here:
29  *   - $a = new ClassA();
30  *     $b = $a->create();
31  *
32  *   - $a = new ClassA($creationPassedVariable);
33  *
34  */
35
36 use Dice\Dice;
37 use Friendica\App;
38 use Friendica\Core\Cache;
39 use Friendica\Core\Config;
40 use Friendica\Core\Hooks\Capabilities\ICanCreateInstances;
41 use Friendica\Core\Hooks\Capabilities\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;
57 use Friendica\Util;
58 use Psr\Log\LoggerInterface;
59
60 return [
61         '*'                             => [
62                 // marks all class result as shared for other creations, so there's just
63                 // one instance for the whole execution
64                 'shared' => true,
65         ],
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],
71                 ],
72         ],
73         '$basepath'                     => [
74                 'instanceOf'      => Util\BasePath::class,
75                 'call'            => [
76                         ['getPath', [], Dice::CHAIN_CALL],
77                 ],
78                 'constructParams' => [
79                         dirname(__FILE__, 2),
80                         $_SERVER
81                 ]
82         ],
83         Util\BasePath::class         => [
84                 'constructParams' => [
85                         dirname(__FILE__, 2),
86                         $_SERVER
87                 ]
88         ],
89         DiceInstanceManager::class   => [
90                 'constructParams' => [
91                         [Dice::INSTANCE => Dice::SELF],
92                 ]
93         ],
94         \Friendica\Core\Hooks\Util\StrategiesFileManager::class => [
95                 'constructParams' => [
96                         [Dice::INSTANCE => '$basepath'],
97                 ],
98                 'call' => [
99                         ['loadConfig'],
100                 ],
101         ],
102         ICanRegisterStrategies::class => [
103                 'instanceOf' => DiceInstanceManager::class,
104                 'constructParams' => [
105                         [Dice::INSTANCE => Dice::SELF],
106                 ],
107         ],
108         ICanCreateInstances::class   => [
109                 'instanceOf' => DiceInstanceManager::class,
110                 'constructParams' => [
111                         [Dice::INSTANCE => Dice::SELF],
112                 ],
113         ],
114         Config\Util\ConfigFileManager::class => [
115                 'instanceOf' => Config\Factory\Config::class,
116                 'call'       => [
117                         ['createConfigFileManager', [
118                                 [Dice::INSTANCE => '$basepath'],
119                                 $_SERVER,
120                         ], Dice::CHAIN_CALL],
121                 ],
122         ],
123         Config\ValueObject\Cache::class => [
124                 'instanceOf' => Config\Factory\Config::class,
125                 'call'       => [
126                         ['createCache', [], Dice::CHAIN_CALL],
127                 ],
128         ],
129         App\Mode::class              => [
130                 'call' => [
131                         ['determineRunMode', [true, $_SERVER], Dice::CHAIN_CALL],
132                         ['determine', [
133                                 [Dice::INSTANCE => '$basepath']
134                         ], Dice::CHAIN_CALL],
135                 ],
136         ],
137         Config\Capability\IManageConfigValues::class => [
138                 'instanceOf' => Config\Model\DatabaseConfig::class,
139                 'constructParams' => [
140                         $_SERVER,
141                 ],
142         ],
143         PConfig\Capability\IManagePersonalConfigValues::class => [
144                 'instanceOf' => PConfig\Factory\PConfig::class,
145                 'call'       => [
146                         ['create', [], Dice::CHAIN_CALL],
147                 ]
148         ],
149         DbaDefinition::class => [
150                 'constructParams' => [
151                         [Dice::INSTANCE => '$basepath'],
152                 ],
153                 'call' => [
154                         ['load', [false], Dice::CHAIN_CALL],
155                 ],
156         ],
157         ViewDefinition::class => [
158                 'constructParams' => [
159                         [Dice::INSTANCE => '$basepath'],
160                 ],
161                 'call' => [
162                         ['load', [false], Dice::CHAIN_CALL],
163                 ],
164         ],
165         Database::class                         => [
166                 'constructParams' => [
167                         [Dice::INSTANCE => Config\Model\ReadOnlyFileConfig::class],
168                 ],
169         ],
170         /**
171          * Creates the App\BaseURL
172          *
173          * Same as:
174          *   $baseURL = new App\BaseURL($configuration, $_SERVER);
175          */
176         App\BaseURL::class             => [
177                 'constructParams' => [
178                         $_SERVER,
179                 ],
180         ],
181         App\Page::class => [
182                 'constructParams' => [
183                         [Dice::INSTANCE => '$basepath'],
184                 ],
185         ],
186         \Psr\Log\LoggerInterface::class                                    => [
187                 'instanceOf' => \Friendica\Core\Logger\Factory\Logger::class,
188                 'call'       => [
189                         ['create', [], Dice::CHAIN_CALL],
190                 ],
191         ],
192         \Friendica\Core\Logger\Type\SyslogLogger::class                    => [
193                 'instanceOf' => \Friendica\Core\Logger\Factory\SyslogLogger::class,
194                 'call'       => [
195                         ['create', [], Dice::CHAIN_CALL],
196                 ],
197         ],
198         \Friendica\Core\Logger\Type\StreamLogger::class                    => [
199                 'instanceOf' => \Friendica\Core\Logger\Factory\StreamLogger::class,
200                 'call'       => [
201                         ['create', [], Dice::CHAIN_CALL],
202                 ],
203         ],
204         \Friendica\Core\Logger\Capabilities\IHaveCallIntrospections::class => [
205                 'instanceOf'      => \Friendica\Core\Logger\Util\Introspection::class,
206                 'constructParams' => [
207                         \Friendica\Core\Logger\Capabilities\IHaveCallIntrospections::IGNORE_CLASS_LIST,
208                 ],
209         ],
210         '$devLogger'                                                       => [
211                 'instanceOf' => \Friendica\Core\Logger\Factory\StreamLogger::class,
212                 'call'       => [
213                         ['createDev', [], Dice::CHAIN_CALL],
214                 ],
215         ],
216         Cache\Capability\ICanCache::class => [
217                 'instanceOf' => Cache\Factory\Cache::class,
218                 'call'       => [
219                         ['createLocal', [], Dice::CHAIN_CALL],
220                 ],
221         ],
222         Cache\Capability\ICanCacheInMemory::class => [
223                 'instanceOf' => Cache\Factory\Cache::class,
224                 'call'       => [
225                         ['createLocal', [], Dice::CHAIN_CALL],
226                 ],
227         ],
228         Lock\Capability\ICanLock::class => [
229                 'instanceOf' => Lock\Factory\Lock::class,
230                 'call'       => [
231                         ['create', [], Dice::CHAIN_CALL],
232                 ],
233         ],
234         App\Arguments::class => [
235                 'instanceOf' => App\Arguments::class,
236                 'call' => [
237                         ['determine', [$_SERVER, $_GET], Dice::CHAIN_CALL],
238                 ],
239         ],
240         \Friendica\Core\System::class => [
241                 'constructParams' => [
242                         [Dice::INSTANCE => '$basepath'],
243                 ],
244         ],
245         App\Router::class => [
246                 'constructParams' => [
247                         $_SERVER,
248                         __DIR__ . '/routes.config.php',
249                         [Dice::INSTANCE => Dice::SELF],
250                         null
251                 ],
252         ],
253         L10n::class => [
254                 'constructParams' => [
255                         $_SERVER, $_GET
256                 ],
257         ],
258         IHandleSessions::class => [
259                 'instanceOf' => \Friendica\Core\Session\Factory\Session::class,
260                 'call' => [
261                         ['create', [$_SERVER], Dice::CHAIN_CALL],
262                         ['start', [], Dice::CHAIN_CALL],
263                 ],
264         ],
265         IHandleUserSessions::class => [
266                 'instanceOf' => \Friendica\Core\Session\Model\UserSession::class,
267         ],
268         Cookie::class => [
269                 'constructParams' => [
270                         $_COOKIE
271                 ],
272         ],
273         ICanWriteToStorage::class => [
274                 'instanceOf' => StorageManager::class,
275                 'call' => [
276                         ['getBackend', [], Dice::CHAIN_CALL],
277                 ],
278         ],
279         \Friendica\Core\KeyValueStorage\Capabilities\IManageKeyValuePairs::class => [
280                 'instanceOf' => \Friendica\Core\KeyValueStorage\Type\DBKeyValueStorage::class,
281         ],
282         Network\HTTPClient\Capability\ICanSendHttpRequests::class => [
283                 'instanceOf' => Network\HTTPClient\Factory\HttpClient::class,
284                 'call'       => [
285                         ['createClient', [], Dice::CHAIN_CALL],
286                 ],
287         ],
288         Factory\Api\Mastodon\Error::class => [
289                 'constructParams' => [
290                         $_SERVER
291                 ],
292         ],
293         ParsedLogIterator::class => [
294                 'constructParams' => [
295                         [Dice::INSTANCE => Util\ReversedFileReader::class],
296                 ]
297         ],
298         \Friendica\Core\Worker\Repository\Process::class => [
299                 'constructParams' => [
300                         $_SERVER
301                 ],
302         ],
303         App\Request::class => [
304                 'constructParams' => [
305                         $_SERVER
306                 ],
307         ],
308         \Psr\Clock\ClockInterface::class => [
309                 'instanceOf' => Util\Clock\SystemClock::class
310         ],
311         \Friendica\Module\Special\HTTPException::class => [
312                 'constructParams' => [
313                         $_SERVER
314                 ],
315         ],
316 ];