]> git.mxchange.org Git - friendica.git/blob - static/dependencies.config.php
Introduce dynamic hook loading
[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\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;
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\HookFileManager::class => [
95                 'constructParams' => [
96                         [Dice::INSTANCE => '$basepath'],
97                 ],
98         ],
99         ICanRegisterInstances::class => [
100                 'instanceOf' => DiceInstanceManager::class,
101                 'constructParams' => [
102                         [Dice::INSTANCE => Dice::SELF],
103                 ],
104         ],
105         ICanCreateInstances::class   => [
106                 'instanceOf' => DiceInstanceManager::class,
107                 'constructParams' => [
108                         [Dice::INSTANCE => Dice::SELF],
109                 ],
110         ],
111         Config\Util\ConfigFileManager::class => [
112                 'instanceOf' => Config\Factory\Config::class,
113                 'call'       => [
114                         ['createConfigFileManager', [
115                                 [Dice::INSTANCE => '$basepath'],
116                                 $_SERVER,
117                         ], Dice::CHAIN_CALL],
118                 ],
119         ],
120         Config\ValueObject\Cache::class => [
121                 'instanceOf' => Config\Factory\Config::class,
122                 'call'       => [
123                         ['createCache', [], Dice::CHAIN_CALL],
124                 ],
125         ],
126         App\Mode::class              => [
127                 'call' => [
128                         ['determineRunMode', [true, $_SERVER], Dice::CHAIN_CALL],
129                         ['determine', [
130                                 [Dice::INSTANCE => '$basepath']
131                         ], Dice::CHAIN_CALL],
132                 ],
133         ],
134         Config\Capability\IManageConfigValues::class => [
135                 'instanceOf' => Config\Model\DatabaseConfig::class,
136                 'constructParams' => [
137                         $_SERVER,
138                 ],
139         ],
140         PConfig\Capability\IManagePersonalConfigValues::class => [
141                 'instanceOf' => PConfig\Factory\PConfig::class,
142                 'call'       => [
143                         ['create', [], Dice::CHAIN_CALL],
144                 ]
145         ],
146         DbaDefinition::class => [
147                 'constructParams' => [
148                         [Dice::INSTANCE => '$basepath'],
149                 ],
150                 'call' => [
151                         ['load', [false], Dice::CHAIN_CALL],
152                 ],
153         ],
154         ViewDefinition::class => [
155                 'constructParams' => [
156                         [Dice::INSTANCE => '$basepath'],
157                 ],
158                 'call' => [
159                         ['load', [false], Dice::CHAIN_CALL],
160                 ],
161         ],
162         Database::class                         => [
163                 'constructParams' => [
164                         [Dice::INSTANCE => Config\Model\ReadOnlyFileConfig::class],
165                 ],
166         ],
167         /**
168          * Creates the App\BaseURL
169          *
170          * Same as:
171          *   $baseURL = new App\BaseURL($configuration, $_SERVER);
172          */
173         App\BaseURL::class             => [
174                 'constructParams' => [
175                         $_SERVER,
176                 ],
177         ],
178         App\Page::class => [
179                 'constructParams' => [
180                         [Dice::INSTANCE => '$basepath'],
181                 ],
182         ],
183         \Psr\Log\LoggerInterface::class                                    => [
184                 'instanceOf' => \Friendica\Core\Logger\Factory\Logger::class,
185                 'call'       => [
186                         ['create', [], Dice::CHAIN_CALL],
187                 ],
188         ],
189         \Friendica\Core\Logger\Type\SyslogLogger::class                    => [
190                 'instanceOf' => \Friendica\Core\Logger\Factory\SyslogLogger::class,
191                 'call'       => [
192                         ['create', [], Dice::CHAIN_CALL],
193                 ],
194         ],
195         \Friendica\Core\Logger\Type\StreamLogger::class                    => [
196                 'instanceOf' => \Friendica\Core\Logger\Factory\StreamLogger::class,
197                 'call'       => [
198                         ['create', [], Dice::CHAIN_CALL],
199                 ],
200         ],
201         \Friendica\Core\Logger\Type\ProfilerLogger::class                  => [
202                 'instanceOf' => \Friendica\Core\Logger\Factory\ProfilerLogger::class,
203                 'call'       => [
204                         ['create', [], Dice::CHAIN_CALL],
205                 ],
206         ],
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,
211                 ],
212         ],
213         '$devLogger'                                                       => [
214                 'instanceOf' => \Friendica\Core\Logger\Factory\StreamLogger::class,
215                 'call'       => [
216                         ['createDev', [], Dice::CHAIN_CALL],
217                 ],
218         ],
219         Cache\Capability\ICanCache::class => [
220                 'instanceOf' => Cache\Factory\Cache::class,
221                 'call'       => [
222                         ['createLocal', [], Dice::CHAIN_CALL],
223                 ],
224         ],
225         Cache\Capability\ICanCacheInMemory::class => [
226                 'instanceOf' => Cache\Factory\Cache::class,
227                 'call'       => [
228                         ['createLocal', [], Dice::CHAIN_CALL],
229                 ],
230         ],
231         Lock\Capability\ICanLock::class => [
232                 'instanceOf' => Lock\Factory\Lock::class,
233                 'call'       => [
234                         ['create', [], Dice::CHAIN_CALL],
235                 ],
236         ],
237         App\Arguments::class => [
238                 'instanceOf' => App\Arguments::class,
239                 'call' => [
240                         ['determine', [$_SERVER, $_GET], Dice::CHAIN_CALL],
241                 ],
242         ],
243         \Friendica\Core\System::class => [
244                 'constructParams' => [
245                         [Dice::INSTANCE => '$basepath'],
246                 ],
247         ],
248         App\Router::class => [
249                 'constructParams' => [
250                         $_SERVER,
251                         __DIR__ . '/routes.config.php',
252                         [Dice::INSTANCE => Dice::SELF],
253                         null
254                 ],
255         ],
256         L10n::class => [
257                 'constructParams' => [
258                         $_SERVER, $_GET
259                 ],
260         ],
261         IHandleSessions::class => [
262                 'instanceOf' => \Friendica\Core\Session\Factory\Session::class,
263                 'call' => [
264                         ['create', [$_SERVER], Dice::CHAIN_CALL],
265                         ['start', [], Dice::CHAIN_CALL],
266                 ],
267         ],
268         IHandleUserSessions::class => [
269                 'instanceOf' => \Friendica\Core\Session\Model\UserSession::class,
270         ],
271         Cookie::class => [
272                 'constructParams' => [
273                         $_COOKIE
274                 ],
275         ],
276         ICanWriteToStorage::class => [
277                 'instanceOf' => StorageManager::class,
278                 'call' => [
279                         ['getBackend', [], Dice::CHAIN_CALL],
280                 ],
281         ],
282         \Friendica\Core\KeyValueStorage\Capabilities\IManageKeyValuePairs::class => [
283                 'instanceOf' => \Friendica\Core\KeyValueStorage\Type\DBKeyValueStorage::class,
284         ],
285         Network\HTTPClient\Capability\ICanSendHttpRequests::class => [
286                 'instanceOf' => Network\HTTPClient\Factory\HttpClient::class,
287                 'call'       => [
288                         ['createClient', [], Dice::CHAIN_CALL],
289                 ],
290         ],
291         Factory\Api\Mastodon\Error::class => [
292                 'constructParams' => [
293                         $_SERVER
294                 ],
295         ],
296         ParsedLogIterator::class => [
297                 'constructParams' => [
298                         [Dice::INSTANCE => Util\ReversedFileReader::class],
299                 ]
300         ],
301         \Friendica\Core\Worker\Repository\Process::class => [
302                 'constructParams' => [
303                         $_SERVER
304                 ],
305         ],
306         App\Request::class => [
307                 'constructParams' => [
308                         $_SERVER
309                 ],
310         ],
311         \Psr\Clock\ClockInterface::class => [
312                 'instanceOf' => Util\Clock\SystemClock::class
313         ],
314         \Friendica\Module\Special\HTTPException::class => [
315                 'constructParams' => [
316                         $_SERVER
317                 ],
318         ],
319 ];