3 * @copyright Copyright (C) 2010-2021, the Friendica project
5 * @license GNU AGPL version 3 or any later version
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
25 use Psr\Log\LoggerInterface;
28 * This class is capable of getting all dynamic created classes
30 * @see https://designpatternsphp.readthedocs.io/en/latest/Structural/Registry/README.html
37 public static function init(Dice $dice)
43 * Returns a clone of the current dice instance
44 * This usefull for overloading the current instance with mocked methods during tests
48 public static function getDice()
50 return clone self::$dice;
60 public static function app()
62 return self::$dice->create(App::class);
66 * @return Database\Database
68 public static function dba()
70 return self::$dice->create(Database\Database::class);
74 // "App" namespace instances
78 * @return App\Arguments
80 public static function args()
82 return self::$dice->create(App\Arguments::class);
88 public static function baseUrl()
90 return self::$dice->create(App\BaseURL::class);
96 public static function mode()
98 return self::$dice->create(App\Mode::class);
104 public static function module()
106 return self::$dice->create(App\Module::class);
112 public static function page()
114 return self::$dice->create(App\Page::class);
120 public static function router()
122 return self::$dice->create(App\Router::class);
126 // "Content" namespace instances
130 * @return Content\Item
132 public static function contentItem()
134 return self::$dice->create(Content\Item::class);
138 * @return Content\Conversation
140 public static function conversation()
142 return self::$dice->create(Content\Conversation::class);
146 * @return Content\Text\BBCode\Video
148 public static function bbCodeVideo()
150 return self::$dice->create(Content\Text\BBCode\Video::class);
154 // "Core" namespace instances
158 * @return Core\Cache\ICache
160 public static function cache()
162 return self::$dice->create(Core\Cache\ICache::class);
166 * @return Core\Config\IConfig
168 public static function config()
170 return self::$dice->create(Core\Config\IConfig::class);
174 * @return Core\PConfig\IPConfig
176 public static function pConfig()
178 return self::$dice->create(Core\PConfig\IPConfig::class);
182 * @return Core\Lock\ILock
184 public static function lock()
186 return self::$dice->create(Core\Lock\ILock::class);
192 public static function l10n()
194 return self::$dice->create(Core\L10n::class);
198 * @return Core\Process
200 public static function process()
202 return self::$dice->create(Core\Process::class);
206 * @return Core\Session\ISession
208 public static function session()
210 return self::$dice->create(Core\Session\ISession::class);
214 * @return Core\StorageManager
216 public static function storageManager()
218 return self::$dice->create(Core\StorageManager::class);
222 // "LoggerInterface" instances
226 * @return LoggerInterface
228 public static function logger()
230 return self::$dice->create(LoggerInterface::class);
234 * @return LoggerInterface
236 public static function devLogger()
238 return self::$dice->create('$devLogger');
242 * @return LoggerInterface
244 public static function workerLogger()
246 return self::$dice->create(Util\Logger\WorkerLogger::class);
250 // "Factory" namespace instances
254 * @return Factory\Api\Mastodon\Account
256 public static function mstdnAccount()
258 return self::$dice->create(Factory\Api\Mastodon\Account::class);
262 * @return Factory\Api\Mastodon\Application
264 public static function mstdnApplication()
266 return self::$dice->create(Factory\Api\Mastodon\Application::class);
270 * @return Factory\Api\Mastodon\Attachment
272 public static function mstdnAttachment()
274 return self::$dice->create(Factory\Api\Mastodon\Attachment::class);
278 * @return Factory\Api\Mastodon\Card
280 public static function mstdnCard()
282 return self::$dice->create(Factory\Api\Mastodon\Card::class);
286 * @return Factory\Api\Mastodon\Conversation
288 public static function mstdnConversation()
290 return self::$dice->create(Factory\Api\Mastodon\Conversation::class);
294 * @return Factory\Api\Mastodon\Emoji
296 public static function mstdnEmoji()
298 return self::$dice->create(Factory\Api\Mastodon\Emoji::class);
302 * @return Factory\Api\Mastodon\Error
304 public static function mstdnError()
306 return self::$dice->create(Factory\Api\Mastodon\Error::class);
310 * @return Factory\Api\Mastodon\FollowRequest
312 public static function mstdnFollowRequest()
314 return self::$dice->create(Factory\Api\Mastodon\FollowRequest::class);
318 * @return Factory\Api\Mastodon\Relationship
320 public static function mstdnRelationship()
322 return self::$dice->create(Factory\Api\Mastodon\Relationship::class);
326 * @return Factory\Api\Mastodon\Status
328 public static function mstdnStatus()
330 return self::$dice->create(Factory\Api\Mastodon\Status::class);
334 * @return Factory\Api\Mastodon\ScheduledStatus
336 public static function mstdnScheduledStatus()
338 return self::$dice->create(Factory\Api\Mastodon\ScheduledStatus::class);
342 * @return Factory\Api\Mastodon\Subscription
344 public static function mstdnSubscription()
346 return self::$dice->create(Factory\Api\Mastodon\Subscription::class);
350 * @return Factory\Api\Mastodon\ListEntity
352 public static function mstdnList()
354 return self::$dice->create(Factory\Api\Mastodon\ListEntity::class);
358 * @return Factory\Api\Mastodon\Notification
360 public static function mstdnNotification()
362 return self::$dice->create(Factory\Api\Mastodon\Notification::class);
366 * @return Factory\Api\Twitter\User
368 public static function twitterUser()
370 return self::$dice->create(Factory\Api\Twitter\User::class);
373 public static function notificationIntro(): Navigation\Notifications\Factory\Introduction
375 return self::$dice->create(Navigation\Notifications\Factory\Introduction::class);
379 // "Model" namespace instances
382 * @return Model\Process
384 public static function modelProcess()
386 return self::$dice->create(Model\Process::class);
390 * @return Model\User\Cookie
392 public static function cookie()
394 return self::$dice->create(Model\User\Cookie::class);
398 * @return Model\Storage\IWritableStorage
400 public static function storage()
402 return self::$dice->create(Model\Storage\IWritableStorage::class);
406 * @return Model\Log\ParsedLogIterator
408 public static function parsedLogIterator()
410 return self::$dice->create(Model\Log\ParsedLogIterator::class);
414 // "Network" namespace
418 * @return Network\IHTTPClient
420 public static function httpClient()
422 return self::$dice->create(Network\IHTTPClient::class);
426 // "Repository" namespace
430 * @return Repository\FSuggest;
432 public static function fsuggest()
434 return self::$dice->create(Repository\FSuggest::class);
438 * @return Repository\Introduction
440 public static function intro()
442 return self::$dice->create(Repository\Introduction::class);
446 * @return Repository\PermissionSet
448 public static function permissionSet()
450 return self::$dice->create(Repository\PermissionSet::class);
454 * @return Repository\ProfileField
456 public static function profileField()
458 return self::$dice->create(Repository\ProfileField::class);
461 public static function notification(): Navigation\Notifications\Depository\Notification
463 return self::$dice->create(Navigation\Notifications\Depository\Notification::class);
466 public static function notificationFactory(): Navigation\Notifications\Factory\Notification
468 return self::$dice->create(Navigation\Notifications\Factory\Notification::class);
471 public static function notify(): Navigation\Notifications\Depository\Notify
473 return self::$dice->create(Navigation\Notifications\Depository\Notify::class);
476 public static function notifyFactory(): Navigation\Notifications\Factory\Notify
478 return self::$dice->create(Navigation\Notifications\Factory\Notify::class);
481 public static function formattedNotificationFactory(): Navigation\Notifications\Factory\FormattedNotification
483 return self::$dice->create(Navigation\Notifications\Factory\FormattedNotification::class);
487 // "Protocol" namespace instances
491 * @return Protocol\Activity
493 public static function activity()
495 return self::$dice->create(Protocol\Activity::class);
499 // "Security" namespace instances
503 * @return \Friendica\Security\Authentication
505 public static function auth()
507 return self::$dice->create(Security\Authentication::class);
511 // "Util" namespace instances
515 * @return Util\ACLFormatter
517 public static function aclFormatter()
519 return self::$dice->create(Util\ACLFormatter::class);
525 public static function basePath()
527 return self::$dice->create('$basepath');
531 * @return Util\DateTimeFormat
533 public static function dtFormat()
535 return self::$dice->create(Util\DateTimeFormat::class);
539 * @return Util\FileSystem
541 public static function fs()
543 return self::$dice->create(Util\FileSystem::class);
547 * @return Util\Profiler
549 public static function profiler()
551 return self::$dice->create(Util\Profiler::class);
555 * @return Util\Emailer
557 public static function emailer()
559 return self::$dice->create(Util\Emailer::class);