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