]> git.mxchange.org Git - friendica.git/blob - src/DI.php
ReWork Notification Model/Module/Object/Repository/Factory
[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 \Friendica\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\Mastodon\Account
225          */
226         public static function mstdnAccount()
227         {
228                 return self::$dice->create(Factory\Mastodon\Account::class);
229         }
230
231         /**
232          * @return Factory\Mastodon\FollowRequest
233          */
234         public static function mstdnFollowRequest()
235         {
236                 return self::$dice->create(Factory\Mastodon\FollowRequest::class);
237         }
238
239         /**
240          * @return Factory\Mastodon\Relationship
241          */
242         public static function mstdnRelationship()
243         {
244                 return self::$dice->create(Factory\Mastodon\Relationship::class);
245         }
246
247         /**
248          * @return \Friendica\Factory\Notification\NotificationFactory
249          */
250         public static function factNotification()
251         {
252                 return self::$dice->create(Factory\Notification\NotificationFactory::class);
253         }
254
255         /**
256          * @return \Friendica\Factory\Notification\IntroductionFactory
257          */
258         public static function factNotIntro()
259         {
260                 return self::$dice->create(Factory\Notification\IntroductionFactory::class);
261         }
262
263         //
264         // "Model" namespace instances
265         //
266
267         /**
268          * @return Model\User\Cookie
269          */
270         public static function cookie()
271         {
272                 return self::$dice->create(Model\User\Cookie::class);
273         }
274
275         /**
276          * @return Repository\Notification
277          */
278         public static function notification()
279         {
280                 return self::$dice->create(Repository\Notification::class);
281         }
282
283         /**
284          * @return Model\Storage\IStorage
285          */
286         public static function storage()
287         {
288                 return self::$dice->create(Model\Storage\IStorage::class);
289         }
290
291         //
292         // "Repository" namespace
293         //
294
295         /**
296          * @return Repository\Introduction
297          */
298         public static function intro()
299         {
300                 return self::$dice->create(Repository\Introduction::class);
301         }
302
303         /**
304          * @return Repository\PermissionSet
305          */
306         public static function permissionSet()
307         {
308                 return self::$dice->create(Repository\PermissionSet::class);
309         }
310
311         /**
312          * @return Repository\ProfileField
313          */
314         public static function profileField()
315         {
316                 return self::$dice->create(Repository\ProfileField::class);
317         }
318
319         //
320         // "Protocol" namespace instances
321         //
322
323         /**
324          * @return Protocol\Activity
325          */
326         public static function activity()
327         {
328                 return self::$dice->create(Protocol\Activity::class);
329         }
330
331         //
332         // "Util" namespace instances
333         //
334
335         /**
336          * @return Util\ACLFormatter
337          */
338         public static function aclFormatter()
339         {
340                 return self::$dice->create(Util\ACLFormatter::class);
341         }
342
343         /**
344          * @return Util\DateTimeFormat
345          */
346         public static function dtFormat()
347         {
348                 return self::$dice->create(Util\DateTimeFormat::class);
349         }
350
351         /**
352          * @return Util\FileSystem
353          */
354         public static function fs()
355         {
356                 return self::$dice->create(Util\FileSystem::class);
357         }
358
359         /**
360          * @return Util\Profiler
361          */
362         public static function profiler()
363         {
364                 return self::$dice->create(Util\Profiler::class);
365         }
366 }