]> git.mxchange.org Git - friendica.git/blob - src/DI.php
Update the Introductions domain to use repository, model and collection
[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  * There has to be a "method" phpDoc for each new class, containing result class for a proper matching
12  *
13  * @method static App app()
14  * @method static App\Authentication auth()
15  * @method static App\Arguments args()
16  * @method static App\BaseURL baseUrl()
17  * @method static App\Mode mode()
18  * @method static App\Module module()
19  * @method static App\Page page()
20  * @method static App\Router router()
21  * @method static Content\Item contentItem()
22  * @method static Content\Text\BBCode\Video bbCodeVideo()
23  * @method static Core\Cache\ICache cache()
24  * @method static Core\Config\IConfiguration config()
25  * @method static Core\Config\IPConfiguration pConfig()
26  * @method static Core\Lock\ILock lock()
27  * @method static Core\L10n\L10n l10n()
28  * @method static Core\Process process()
29  * @method static Core\Session\ISession session()
30  * @method static Database\Database dba()
31  * @method static Factory\Mastodon\Account mstdnAccount()
32  * @method static Factory\Mastodon\FollowRequest mstdnFollowRequest()
33  * @method static Factory\Mastodon\Relationship mstdnRelationship()
34  * @method static Model\User\Cookie cookie()
35  * @method static Model\Notify notify()
36  * @method static Repository\Introduction intro()
37  * @method static Protocol\Activity activity()
38  * @method static Util\ACLFormatter aclFormatter()
39  * @method static Util\DateTimeFormat dtFormat()
40  * @method static Util\FileSystem fs()
41  * @method static Util\Profiler profiler()
42  * @method static LoggerInterface logger()
43  * @method static LoggerInterface devLogger()
44  * @method static LoggerInterface workerLogger()
45  *
46  */
47 abstract class DI
48 {
49         const CLASS_MAPPING = [
50                 'app'          => App::class,
51                 'auth'         => App\Authentication::class,
52                 'args'         => App\Arguments::class,
53                 'baseUrl'      => App\BaseURL::class,
54                 'mode'         => App\Mode::class,
55                 'module'       => App\Module::class,
56                 'page'         => App\Page::class,
57                 'router'       => App\Router::class,
58                 'contentItem'  => Content\Item::class,
59                 'bbCodeVideo'  => Content\Text\BBCode\Video::class,
60                 'cache'        => Core\Cache\ICache::class,
61                 'config'       => Core\Config\IConfiguration::class,
62                 'pConfig'      => Core\Config\IPConfiguration::class,
63                 'l10n'         => Core\L10n\L10n::class,
64                 'lock'         => Core\Lock\ILock::class,
65                 'process'      => Core\Process::class,
66                 'session'      => Core\Session\ISession::class,
67                 'dba'          => Database\Database::class,
68                 'mstdnAccount' => Factory\Mastodon\Account::class,
69                 'mstdnFollowRequest' => Factory\Mastodon\FollowRequest::class,
70                 'mstdnRelationship'  => Factory\Mastodon\Relationship::class,
71                 'cookie'       => Model\User\Cookie::class,
72                 'notify'       => Model\Notify::class,
73                 'intro'        => Repository\Introduction::class,
74                 'activity'     => Protocol\Activity::class,
75                 'aclFormatter' => Util\ACLFormatter::class,
76                 'dtFormat'     => Util\DateTimeFormat::class,
77                 'fs'           => Util\FileSystem::class,
78                 'workerLogger' => Util\Logger\WorkerLogger::class,
79                 'profiler'     => Util\Profiler::class,
80                 'logger'       => LoggerInterface::class,
81                 'devLogger'    => '$devLogger',
82         ];
83
84         /** @var Dice */
85         private static $dice;
86
87         public static function init(Dice $dice)
88         {
89                 self::$dice = $dice;
90         }
91
92         public static function __callStatic($name, $arguments)
93         {
94                 return self::$dice->create(self::CLASS_MAPPING[$name], $arguments);
95         }
96 }