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 Friendica\Security\PermissionSet\Depository\PermissionSet;
26 use Psr\Log\LoggerInterface;
29 * This class is capable of getting all dynamic created classes
31 * @see https://designpatternsphp.readthedocs.io/en/latest/Structural/Registry/README.html
38 public static function init(Dice $dice)
44 * Returns a clone of the current dice instance
45 * This usefull for overloading the current instance with mocked methods during tests
49 public static function getDice()
51 return clone self::$dice;
61 public static function app()
63 return self::$dice->create(App::class);
67 * @return Database\Database
69 public static function dba()
71 return self::$dice->create(Database\Database::class);
75 // "App" namespace instances
79 * @return App\Arguments
81 public static function args()
83 return self::$dice->create(App\Arguments::class);
89 public static function baseUrl()
91 return self::$dice->create(App\BaseURL::class);
97 public static function mode()
99 return self::$dice->create(App\Mode::class);
105 public static function module()
107 return self::$dice->create(App\Module::class);
113 public static function page()
115 return self::$dice->create(App\Page::class);
121 public static function router()
123 return self::$dice->create(App\Router::class);
127 // "Content" namespace instances
131 * @return Content\Item
133 public static function contentItem()
135 return self::$dice->create(Content\Item::class);
139 * @return Content\Conversation
141 public static function conversation()
143 return self::$dice->create(Content\Conversation::class);
147 * @return Content\Text\BBCode\Video
149 public static function bbCodeVideo()
151 return self::$dice->create(Content\Text\BBCode\Video::class);
155 // "Core" namespace instances
159 * @return Core\Cache\ICache
161 public static function cache()
163 return self::$dice->create(Core\Cache\ICache::class);
167 * @return Core\Config\IConfig
169 public static function config()
171 return self::$dice->create(Core\Config\IConfig::class);
175 * @return Core\PConfig\IPConfig
177 public static function pConfig()
179 return self::$dice->create(Core\PConfig\IPConfig::class);
183 * @return Core\Lock\ILock
185 public static function lock()
187 return self::$dice->create(Core\Lock\ILock::class);
193 public static function l10n()
195 return self::$dice->create(Core\L10n::class);
199 * @return Core\Process
201 public static function process()
203 return self::$dice->create(Core\Process::class);
207 * @return Core\Session\ISession
209 public static function session()
211 return self::$dice->create(Core\Session\ISession::class);
215 * @return Core\StorageManager
217 public static function storageManager()
219 return self::$dice->create(Core\StorageManager::class);
223 // "LoggerInterface" instances
227 * @return LoggerInterface
229 public static function logger()
231 return self::$dice->create(LoggerInterface::class);
235 * @return LoggerInterface
237 public static function devLogger()
239 return self::$dice->create('$devLogger');
243 * @return LoggerInterface
245 public static function workerLogger()
247 return self::$dice->create(Util\Logger\WorkerLogger::class);
251 // "Factory" namespace instances
255 * @return Factory\Api\Mastodon\Account
257 public static function mstdnAccount()
259 return self::$dice->create(Factory\Api\Mastodon\Account::class);
263 * @return Factory\Api\Mastodon\Application
265 public static function mstdnApplication()
267 return self::$dice->create(Factory\Api\Mastodon\Application::class);
271 * @return Factory\Api\Mastodon\Attachment
273 public static function mstdnAttachment()
275 return self::$dice->create(Factory\Api\Mastodon\Attachment::class);
279 * @return Factory\Api\Mastodon\Card
281 public static function mstdnCard()
283 return self::$dice->create(Factory\Api\Mastodon\Card::class);
287 * @return Factory\Api\Mastodon\Conversation
289 public static function mstdnConversation()
291 return self::$dice->create(Factory\Api\Mastodon\Conversation::class);
295 * @return Factory\Api\Mastodon\Emoji
297 public static function mstdnEmoji()
299 return self::$dice->create(Factory\Api\Mastodon\Emoji::class);
303 * @return Factory\Api\Mastodon\Error
305 public static function mstdnError()
307 return self::$dice->create(Factory\Api\Mastodon\Error::class);
311 * @return Factory\Api\Mastodon\FollowRequest
313 public static function mstdnFollowRequest()
315 return self::$dice->create(Factory\Api\Mastodon\FollowRequest::class);
319 * @return Factory\Api\Mastodon\Relationship
321 public static function mstdnRelationship()
323 return self::$dice->create(Factory\Api\Mastodon\Relationship::class);
327 * @return Factory\Api\Mastodon\Status
329 public static function mstdnStatus()
331 return self::$dice->create(Factory\Api\Mastodon\Status::class);
335 * @return Factory\Api\Mastodon\ScheduledStatus
337 public static function mstdnScheduledStatus()
339 return self::$dice->create(Factory\Api\Mastodon\ScheduledStatus::class);
343 * @return Factory\Api\Mastodon\Subscription
345 public static function mstdnSubscription()
347 return self::$dice->create(Factory\Api\Mastodon\Subscription::class);
351 * @return Factory\Api\Mastodon\ListEntity
353 public static function mstdnList()
355 return self::$dice->create(Factory\Api\Mastodon\ListEntity::class);
359 * @return Factory\Api\Mastodon\Notification
361 public static function mstdnNotification()
363 return self::$dice->create(Factory\Api\Mastodon\Notification::class);
367 * @return Factory\Api\Twitter\User
369 public static function twitterUser()
371 return self::$dice->create(Factory\Api\Twitter\User::class);
374 public static function notificationIntro(): Navigation\Notifications\Factory\Introduction
376 return self::$dice->create(Navigation\Notifications\Factory\Introduction::class);
380 // "Model" namespace instances
383 * @return Model\Process
385 public static function modelProcess()
387 return self::$dice->create(Model\Process::class);
391 * @return Model\User\Cookie
393 public static function cookie()
395 return self::$dice->create(Model\User\Cookie::class);
399 * @return Model\Storage\IWritableStorage
401 public static function storage()
403 return self::$dice->create(Model\Storage\IWritableStorage::class);
407 * @return Model\Log\ParsedLogIterator
409 public static function parsedLogIterator()
411 return self::$dice->create(Model\Log\ParsedLogIterator::class);
415 // "Network" namespace
419 * @return Network\IHTTPClient
421 public static function httpClient()
423 return self::$dice->create(Network\IHTTPClient::class);
427 // "Repository" namespace
431 * @return Repository\FSuggest;
433 public static function fsuggest()
435 return self::$dice->create(Repository\FSuggest::class);
439 * @return Repository\Introduction
441 public static function intro()
443 return self::$dice->create(Repository\Introduction::class);
447 * @return PermissionSet
449 public static function permissionSet()
451 return self::$dice->create(PermissionSet::class);
455 * @return \Friendica\Security\PermissionSet\Factory\PermissionSet
457 public static function permissionSetFactory()
459 return self::$dice->create(\Friendica\Security\PermissionSet\Factory\PermissionSet::class);
463 * @return Repository\ProfileField
465 public static function profileField()
467 return self::$dice->create(Repository\ProfileField::class);
470 public static function notification(): Navigation\Notifications\Depository\Notification
472 return self::$dice->create(Navigation\Notifications\Depository\Notification::class);
475 public static function notificationFactory(): Navigation\Notifications\Factory\Notification
477 return self::$dice->create(Navigation\Notifications\Factory\Notification::class);
480 public static function notify(): Navigation\Notifications\Depository\Notify
482 return self::$dice->create(Navigation\Notifications\Depository\Notify::class);
485 public static function notifyFactory(): Navigation\Notifications\Factory\Notify
487 return self::$dice->create(Navigation\Notifications\Factory\Notify::class);
490 public static function formattedNotificationFactory(): Navigation\Notifications\Factory\FormattedNotification
492 return self::$dice->create(Navigation\Notifications\Factory\FormattedNotification::class);
496 // "Protocol" namespace instances
500 * @return Protocol\Activity
502 public static function activity()
504 return self::$dice->create(Protocol\Activity::class);
508 // "Security" namespace instances
512 * @return \Friendica\Security\Authentication
514 public static function auth()
516 return self::$dice->create(Security\Authentication::class);
520 // "Util" namespace instances
524 * @return Util\ACLFormatter
526 public static function aclFormatter()
528 return self::$dice->create(Util\ACLFormatter::class);
534 public static function basePath()
536 return self::$dice->create('$basepath');
540 * @return Util\DateTimeFormat
542 public static function dtFormat()
544 return self::$dice->create(Util\DateTimeFormat::class);
548 * @return Util\FileSystem
550 public static function fs()
552 return self::$dice->create(Util\FileSystem::class);
556 * @return Util\Profiler
558 public static function profiler()
560 return self::$dice->create(Util\Profiler::class);
564 * @return Util\Emailer
566 public static function emailer()
568 return self::$dice->create(Util\Emailer::class);