]> git.mxchange.org Git - friendica.git/blob - src/DI.php
Move L10n class from L10n subdir to Core (replacing old wrapper)
[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\IConfiguration
137          */
138         public static function config()
139         {
140                 return self::$dice->create(Core\Config\IConfiguration::class);
141         }
142
143         /**
144          * @return Core\Config\IPConfiguration
145          */
146         public static function pConfig()
147         {
148                 return self::$dice->create(Core\Config\IPConfiguration::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         public static function l10n()
160         {
161                 return self::$dice->create(Core\L10n::class);
162         }
163
164         /**
165          * @return Core\Process
166          */
167         public static function process()
168         {
169                 return self::$dice->create(Core\Process::class);
170         }
171
172         /**
173          * @return Core\Session\ISession
174          */
175         public static function session()
176         {
177                 return self::$dice->create(Core\Session\ISession::class);
178         }
179
180         /**
181          * @return Core\StorageManager
182          */
183         public static function storageManager()
184         {
185                 return self::$dice->create(Core\StorageManager::class);
186         }
187
188         //
189         // "LoggerInterface" instances
190         //
191
192         /**
193          * @return LoggerInterface
194          */
195         public static function logger()
196         {
197                 return self::$dice->create(LoggerInterface::class);
198         }
199
200         /**
201          * @return LoggerInterface
202          */
203         public static function devLogger()
204         {
205                 return self::$dice->create('$devLogger');
206         }
207
208         /**
209          * @return LoggerInterface
210          */
211         public static function workerLogger()
212         {
213                 return self::$dice->create(Util\Logger\WorkerLogger::class);
214         }
215
216         //
217         // "Factory" namespace instances
218         //
219
220         /**
221          * @return Factory\Mastodon\Account
222          */
223         public static function mstdnAccount()
224         {
225                 return self::$dice->create(Factory\Mastodon\Account::class);
226         }
227
228         /**
229          * @return Factory\Mastodon\FollowRequest
230          */
231         public static function mstdnFollowRequest()
232         {
233                 return self::$dice->create(Factory\Mastodon\FollowRequest::class);
234         }
235
236         /**
237          * @return Factory\Mastodon\Relationship
238          */
239         public static function mstdnRelationship()
240         {
241                 return self::$dice->create(Factory\Mastodon\Relationship::class);
242         }
243
244         //
245         // "Model" namespace instances
246         //
247
248         /**
249          * @return Model\User\Cookie
250          */
251         public static function cookie()
252         {
253                 return self::$dice->create(Model\User\Cookie::class);
254         }
255
256         /**
257          * @return Model\Notify
258          */
259         public static function notify()
260         {
261                 return self::$dice->create(Model\Notify::class);
262         }
263
264         /**
265          * @return Model\Storage\IStorage
266          */
267         public static function storage()
268         {
269                 return self::$dice->create(Model\Storage\IStorage::class);
270         }
271
272         //
273         // "Repository" namespace
274         //
275
276         /**
277          * @return Repository\Introduction
278          */
279         public static function intro()
280         {
281                 return self::$dice->create(Repository\Introduction::class);
282         }
283
284         //
285         // "Protocol" namespace instances
286         //
287
288         /**
289          * @return Protocol\Activity
290          */
291         public static function activity()
292         {
293                 return self::$dice->create(Protocol\Activity::class);
294         }
295
296         //
297         // "Util" namespace instances
298         //
299
300         /**
301          * @return Util\ACLFormatter
302          */
303         public static function aclFormatter()
304         {
305                 return self::$dice->create(Util\ACLFormatter::class);
306         }
307
308         /**
309          * @return Util\DateTimeFormat
310          */
311         public static function dtFormat()
312         {
313                 return self::$dice->create(Util\DateTimeFormat::class);
314         }
315
316         /**
317          * @return Util\FileSystem
318          */
319         public static function fs()
320         {
321                 return self::$dice->create(Util\FileSystem::class);
322         }
323
324         /**
325          * @return Util\Profiler
326          */
327         public static function profiler()
328         {
329                 return self::$dice->create(Util\Profiler::class);
330         }
331 }