]> git.mxchange.org Git - friendica.git/blob - src/DI.php
Merge pull request #8070 from nupplaphil/bug/8069-logout
[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 Model\User\Cookie cookie()
32  * @method static Model\Notify notify()
33  * @method static Model\Introduction intro()
34  * @method static Protocol\Activity activity()
35  * @method static Util\ACLFormatter aclFormatter()
36  * @method static Util\DateTimeFormat dtFormat()
37  * @method static Util\FileSystem fs()
38  * @method static Util\Profiler profiler()
39  * @method static LoggerInterface logger()
40  * @method static LoggerInterface devLogger()
41  * @method static LoggerInterface workerLogger()
42  *
43  */
44 abstract class DI
45 {
46         const CLASS_MAPPING = [
47                 'app'          => App::class,
48                 'auth'         => App\Authentication::class,
49                 'args'         => App\Arguments::class,
50                 'baseUrl'      => App\BaseURL::class,
51                 'mode'         => App\Mode::class,
52                 'module'       => App\Module::class,
53                 'page'         => App\Page::class,
54                 'router'       => App\Router::class,
55                 'contentItem'  => Content\Item::class,
56                 'bbCodeVideo'  => Content\Text\BBCode\Video::class,
57                 'cache'        => Core\Cache\ICache::class,
58                 'config'       => Core\Config\IConfiguration::class,
59                 'pConfig'      => Core\Config\IPConfiguration::class,
60                 'l10n'         => Core\L10n\L10n::class,
61                 'lock'         => Core\Lock\ILock::class,
62                 'process'      => Core\Process::class,
63                 'session'      => Core\Session\ISession::class,
64                 'dba'          => Database\Database::class,
65                 'cookie'       => Model\User\Cookie::class,
66                 'notify'       => Model\Notify::class,
67                 'intro'        => Model\Introduction::class,
68                 'activity'     => Protocol\Activity::class,
69                 'aclFormatter' => Util\ACLFormatter::class,
70                 'dtFormat'     => Util\DateTimeFormat::class,
71                 'fs'           => Util\FileSystem::class,
72                 'workerLogger' => Util\Logger\WorkerLogger::class,
73                 'profiler'     => Util\Profiler::class,
74                 'logger'       => LoggerInterface::class,
75                 'devLogger'    => '$devLogger',
76         ];
77
78         /** @var Dice */
79         private static $dice;
80
81         public static function init(Dice $dice)
82         {
83                 self::$dice = $dice;
84         }
85
86         public static function __callStatic($name, $arguments)
87         {
88                 return self::$dice->create(self::CLASS_MAPPING[$name], $arguments);
89         }
90 }