]> git.mxchange.org Git - friendica.git/blob - src/DI.php
Remove unused dependency
[friendica.git] / src / DI.php
1 <?php
2
3 namespace Friendica;
4
5 use Dice\Dice;
6 use Psr\Log\LoggerInterface;
7
8 /**
9  * This class is capable of getting all dynamic created classes
10  *
11  * @see https://designpatternsphp.readthedocs.io/en/latest/Structural/Registry/README.html
12  */
13 abstract class DI
14 {
15         /** @var Dice */
16         private static $dice;
17
18         public static function init(Dice $dice)
19         {
20                 self::$dice = $dice;
21         }
22
23         //
24         // common instances
25         //
26
27         /**
28          * @return App
29          */
30         public static function app()
31         {
32                 return self::$dice->create(App::class);
33         }
34
35         /**
36          * @return Database\Database
37          */
38         public static function dba()
39         {
40                 return self::$dice->create(Database\Database::class);
41         }
42
43         //
44         // "App" namespace instances
45         //
46
47         /**
48          * @return App\Authentication
49          */
50         public static function auth()
51         {
52                 return self::$dice->create(App\Authentication::class);
53         }
54
55         /**
56          * @return App\Arguments
57          */
58         public static function args()
59         {
60                 return self::$dice->create(App\Arguments::class);
61         }
62
63         /**
64          * @return App\BaseURL
65          */
66         public static function baseUrl()
67         {
68                 return self::$dice->create(App\BaseURL::class);
69         }
70
71         /**
72          * @return App\Mode
73          */
74         public static function mode()
75         {
76                 return self::$dice->create(App\Mode::class);
77         }
78
79         /**
80          * @return App\Module
81          */
82         public static function module()
83         {
84                 return self::$dice->create(App\Module::class);
85         }
86
87         /**
88          * @return App\Page
89          */
90         public static function page()
91         {
92                 return self::$dice->create(App\Page::class);
93         }
94
95         /**
96          * @return App\Router
97          */
98         public static function router()
99         {
100                 return self::$dice->create(App\Router::class);
101         }
102
103         //
104         // "Content" namespace instances
105         //
106
107         /**
108          * @return Content\Item
109          */
110         public static function contentItem()
111         {
112                 return self::$dice->create(Content\Item::class);
113         }
114
115         /**
116          * @return Content\Text\BBCode\Video
117          */
118         public static function bbCodeVideo()
119         {
120                 return self::$dice->create(Content\Text\BBCode\Video::class);
121         }
122
123         //
124         // "Core" namespace instances
125         //
126
127         /**
128          * @return Core\Cache\ICache
129          */
130         public static function cache()
131         {
132                 return self::$dice->create(Core\Cache\ICache::class);
133         }
134
135         /**
136          * @return Core\Config\IConfig
137          */
138         public static function config()
139         {
140                 return self::$dice->create(Core\Config\IConfig::class);
141         }
142
143         /**
144          * @return Core\PConfig\IPConfig
145          */
146         public static function pConfig()
147         {
148                 return self::$dice->create(Core\PConfig\IPConfig::class);
149         }
150
151         /**
152          * @return Core\Lock\ILock
153          */
154         public static function lock()
155         {
156                 return self::$dice->create(Core\Lock\ILock::class);
157         }
158
159         /**
160          * @return Core\L10n
161          */
162         public static function l10n()
163         {
164                 return self::$dice->create(Core\L10n::class);
165         }
166
167         /**
168          * @return Core\Process
169          */
170         public static function process()
171         {
172                 return self::$dice->create(Core\Process::class);
173         }
174
175         /**
176          * @return Core\Session\ISession
177          */
178         public static function session()
179         {
180                 return self::$dice->create(Core\Session\ISession::class);
181         }
182
183         /**
184          * @return Core\StorageManager
185          */
186         public static function storageManager()
187         {
188                 return self::$dice->create(Core\StorageManager::class);
189         }
190
191         //
192         // "LoggerInterface" instances
193         //
194
195         /**
196          * @return LoggerInterface
197          */
198         public static function logger()
199         {
200                 return self::$dice->create(LoggerInterface::class);
201         }
202
203         /**
204          * @return LoggerInterface
205          */
206         public static function devLogger()
207         {
208                 return self::$dice->create('$devLogger');
209         }
210
211         /**
212          * @return LoggerInterface
213          */
214         public static function workerLogger()
215         {
216                 return self::$dice->create(Util\Logger\WorkerLogger::class);
217         }
218
219         //
220         // "Factory" namespace instances
221         //
222
223         /**
224          * @return Factory\Api\Mastodon\Account
225          */
226         public static function mstdnAccount()
227         {
228                 return self::$dice->create(Factory\Api\Mastodon\Account::class);
229         }
230
231         /**
232          * @return Factory\Api\Mastodon\Emoji
233          */
234         public static function mstdnEmoji()
235         {
236                 return self::$dice->create(Factory\Api\Mastodon\Emoji::class);
237         }
238
239         /**
240          * @return Factory\Api\Mastodon\Field
241          */
242         public static function mstdnField()
243         {
244                 return self::$dice->create(Factory\Api\Mastodon\Field::class);
245         }
246
247         /**
248          * @return Factory\Api\Mastodon\FollowRequest
249          */
250         public static function mstdnFollowRequest()
251         {
252                 return self::$dice->create(Factory\Api\Mastodon\FollowRequest::class);
253         }
254
255         /**
256          * @return Factory\Api\Mastodon\Relationship
257          */
258         public static function mstdnRelationship()
259         {
260                 return self::$dice->create(Factory\Api\Mastodon\Relationship::class);
261         }
262
263         /**
264          * @return Factory\Notification\Notification
265          */
266         public static function notification()
267         {
268                 return self::$dice->create(Factory\Notification\Notification::class);
269         }
270
271         /**
272          * @return Factory\Notification\Introduction
273          */
274         public static function notificationIntro()
275         {
276                 return self::$dice->create(Factory\Notification\Introduction::class);
277         }
278
279         //
280         // "Model" namespace instances
281         //
282
283         /**
284          * @return Model\User\Cookie
285          */
286         public static function cookie()
287         {
288                 return self::$dice->create(Model\User\Cookie::class);
289         }
290
291         /**
292          * @return Model\Storage\IStorage
293          */
294         public static function storage()
295         {
296                 return self::$dice->create(Model\Storage\IStorage::class);
297         }
298
299         //
300         // "Repository" namespace
301         //
302
303         /**
304          * @return Repository\FSuggest;
305          */
306         public static function fsuggest()
307         {
308                 return self::$dice->create(Repository\FSuggest::class);
309         }
310
311         /**
312          * @return Repository\Introduction
313          */
314         public static function intro()
315         {
316                 return self::$dice->create(Repository\Introduction::class);
317         }
318
319         /**
320          * @return Repository\PermissionSet
321          */
322         public static function permissionSet()
323         {
324                 return self::$dice->create(Repository\PermissionSet::class);
325         }
326
327         /**
328          * @return Repository\ProfileField
329          */
330         public static function profileField()
331         {
332                 return self::$dice->create(Repository\ProfileField::class);
333         }
334
335         /**
336          * @return Repository\Notify
337          */
338         public static function notify()
339         {
340                 return self::$dice->create(Repository\Notify::class);
341         }
342
343         //
344         // "Protocol" namespace instances
345         //
346
347         /**
348          * @return Protocol\Activity
349          */
350         public static function activity()
351         {
352                 return self::$dice->create(Protocol\Activity::class);
353         }
354
355         //
356         // "Util" namespace instances
357         //
358
359         /**
360          * @return Util\ACLFormatter
361          */
362         public static function aclFormatter()
363         {
364                 return self::$dice->create(Util\ACLFormatter::class);
365         }
366
367         /**
368          * @return Util\DateTimeFormat
369          */
370         public static function dtFormat()
371         {
372                 return self::$dice->create(Util\DateTimeFormat::class);
373         }
374
375         /**
376          * @return Util\FileSystem
377          */
378         public static function fs()
379         {
380                 return self::$dice->create(Util\FileSystem::class);
381         }
382
383         /**
384          * @return Util\Profiler
385          */
386         public static function profiler()
387         {
388                 return self::$dice->create(Util\Profiler::class);
389         }
390
391         /**
392          * @return Util\Emailer
393          */
394         public static function emailer()
395         {
396                 return self::$dice->create(Util\Emailer::class);
397         }
398 }