]> git.mxchange.org Git - friendica.git/blobdiff - src/DI.php
Improved order of systems
[friendica.git] / src / DI.php
index efd29f9c0c0dc5356ef3c57844cfc643e62fd727..7ed581254d038b059cd47c8e716ede449c960b66 100644 (file)
@@ -3,21 +3,6 @@
 namespace Friendica;
 
 use Dice\Dice;
-use Friendica\Core\Cache\ICache;
-use Friendica\Core\Config\Configuration;
-use Friendica\Core\Config\PConfiguration;
-use Friendica\Core\L10n\L10n;
-use Friendica\Core\Lock\ILock;
-use Friendica\Core\Session\ISession;
-use Friendica\Database\Database;
-use Friendica\Model\Notify;
-use Friendica\Protocol\Activity;
-use Friendica\Util\ACLFormatter;
-use Friendica\Content\Item as ContentItem;
-use Friendica\Content\Text\BBCode\Video as BBCodeVideo;
-use Friendica\Util\DateTimeFormat;
-use Friendica\Util\FileSystem;
-use Friendica\Util\Logger\WorkerLogger;
 use Psr\Log\LoggerInterface;
 
 /**
@@ -26,21 +11,6 @@ use Psr\Log\LoggerInterface;
  * There has to be a "method" phpDoc for each new class, containing result class for a proper matching
  *
  * @method static App app()
- * @method static ACLFormatter aclFormatter()
- * @method static Notify notify()
- * @method static Activity activity()
- * @method static ContentItem contentItem()
- * @method static BBCodeVideo bbCodeVideo()
- * @method static DateTimeFormat dtFormat()
- * @method static ICache cache()
- * @method static Configuration config()
- * @method static PConfiguration pConfig()
- * @method static ILock lock()
- * @method static L10n l10n()
- * @method static LoggerInterface logger()
- * @method static LoggerInterface devLogger()
- * @method static LoggerInterface workerLogger()
- * @method static ISession session()
  * @method static App\Authentication auth()
  * @method static App\Arguments args()
  * @method static App\BaseURL baseUrl()
@@ -48,12 +18,69 @@ use Psr\Log\LoggerInterface;
  * @method static App\Module module()
  * @method static App\Page page()
  * @method static App\Router router()
- * @method static Database dba()
- * @method static FileSystem fs()
+ * @method static Content\Item contentItem()
+ * @method static Content\Text\BBCode\Video bbCodeVideo()
+ * @method static Core\Cache\ICache cache()
+ * @method static Core\Config\IConfiguration config()
+ * @method static Core\Config\IPConfiguration pConfig()
+ * @method static Core\Lock\ILock lock()
+ * @method static Core\L10n\L10n l10n()
+ * @method static Core\Process process()
+ * @method static Core\Session\ISession session()
+ * @method static Database\Database dba()
+ * @method static Factory\Mastodon\Account mstdnAccount()
+ * @method static Factory\Mastodon\FollowRequest mstdnFollowRequest()
+ * @method static Factory\Mastodon\Relationship mstdnRelationship()
+ * @method static Model\User\Cookie cookie()
+ * @method static Model\Notify notify()
+ * @method static Repository\Introduction intro()
+ * @method static Protocol\Activity activity()
+ * @method static Util\ACLFormatter aclFormatter()
+ * @method static Util\DateTimeFormat dtFormat()
+ * @method static Util\FileSystem fs()
+ * @method static Util\Profiler profiler()
+ * @method static LoggerInterface logger()
+ * @method static LoggerInterface devLogger()
+ * @method static LoggerInterface workerLogger()
  *
  */
-class DI
+abstract class DI
 {
+       const CLASS_MAPPING = [
+               'app'          => App::class,
+               'auth'         => App\Authentication::class,
+               'args'         => App\Arguments::class,
+               'baseUrl'      => App\BaseURL::class,
+               'mode'         => App\Mode::class,
+               'module'       => App\Module::class,
+               'page'         => App\Page::class,
+               'router'       => App\Router::class,
+               'contentItem'  => Content\Item::class,
+               'bbCodeVideo'  => Content\Text\BBCode\Video::class,
+               'cache'        => Core\Cache\ICache::class,
+               'config'       => Core\Config\IConfiguration::class,
+               'pConfig'      => Core\Config\IPConfiguration::class,
+               'l10n'         => Core\L10n\L10n::class,
+               'lock'         => Core\Lock\ILock::class,
+               'process'      => Core\Process::class,
+               'session'      => Core\Session\ISession::class,
+               'dba'          => Database\Database::class,
+               'mstdnAccount' => Factory\Mastodon\Account::class,
+               'mstdnFollowRequest' => Factory\Mastodon\FollowRequest::class,
+               'mstdnRelationship'  => Factory\Mastodon\Relationship::class,
+               'cookie'       => Model\User\Cookie::class,
+               'notify'       => Model\Notify::class,
+               'intro'        => Repository\Introduction::class,
+               'activity'     => Protocol\Activity::class,
+               'aclFormatter' => Util\ACLFormatter::class,
+               'dtFormat'     => Util\DateTimeFormat::class,
+               'fs'           => Util\FileSystem::class,
+               'workerLogger' => Util\Logger\WorkerLogger::class,
+               'profiler'     => Util\Profiler::class,
+               'logger'       => LoggerInterface::class,
+               'devLogger'    => '$devLogger',
+       ];
+
        /** @var Dice */
        private static $dice;
 
@@ -64,59 +91,6 @@ class DI
 
        public static function __callStatic($name, $arguments)
        {
-               switch ($name) {
-                       case 'app':
-                               return self::$dice->create(App::class, $arguments);
-                       case 'aclFormatter':
-                               return self::$dice->create(ACLFormatter::class, $arguments);
-                       case 'auth':
-                               return self::$dice->create(App\Authentication::class, $arguments);
-                       case 'args':
-                               return self::$dice->create(App\Arguments::class, $arguments);
-                       case 'baseUrl':
-                               return self::$dice->create(App\BaseURL::class, $arguments);
-                       case 'mode':
-                               return self::$dice->create(App\Mode::class, $arguments);
-                       case 'module':
-                               return self::$dice->create(App\Module::class, $arguments);
-                       case 'page':
-                               return self::$dice->create(App\Page::class, $arguments);
-                       case 'router':
-                               return self::$dice->create(App\Router::class, $arguments);
-                       case 'notify':
-                               return self::$dice->create(Notify::class, $arguments);
-                       case 'activity':
-                               return self::$dice->create(Activity::class, $arguments);
-                       case 'contentItem':
-                               return self::$dice->create(ContentItem::class, $arguments);
-                       case 'bbCodeVideo':
-                               return self::$dice->create(BBCodeVideo::class, $arguments);
-                       case 'dtFormat':
-                               return self::$dice->create(DateTimeFormat::class, $arguments);
-                       case 'cache':
-                               return self::$dice->create(ICache::class, $arguments);
-                       case 'config':
-                               return self::$dice->create(Configuration::class, $arguments);
-                       case 'pConfig':
-                               return self::$dice->create(PConfiguration::class, $arguments);
-                       case 'lock':
-                               return self::$dice->create(ILock::class, $arguments);
-                       case 'l10n':
-                               return self::$dice->create(L10n::class, $arguments);
-                       case 'logger':
-                               return self::$dice->create(LoggerInterface::class, $arguments);
-                       case 'devLogger':
-                               return self::$dice->create('$devLogger', $arguments);
-                       case 'workerLogger':
-                               return self::$dice->create(WorkerLogger::class, $arguments);
-                       case 'session':
-                               return self::$dice->create(ISession::class, $arguments);
-                       case 'dba':
-                               return self::$dice->create(Database::class, $arguments);
-                       case 'fs':
-                               return self::$dice->create(FileSystem::class, $arguments);
-                       default:
-                               return null;
-               }
+               return self::$dice->create(self::CLASS_MAPPING[$name], $arguments);
        }
 }