5 use Friendica\Core\Cache;
6 use Friendica\Core\Config;
7 use Friendica\Core\L10n\L10n;
8 use Friendica\Core\Lock\ILock;
9 use Friendica\Core\Process;
10 use Friendica\Core\Session\ISession;
11 use Friendica\Database\Database;
12 use Friendica\Factory;
13 use Friendica\Model\User\Cookie;
15 use Psr\Log\LoggerInterface;
18 * The configuration defines "complex" dependencies inside Friendica
19 * So this classes shouldn't be simple or their dependencies are already defined here.
21 * This kind of dependencies are NOT required to be defined here:
22 * - $a = new ClassA(new ClassB());
23 * - $a = new ClassA();
24 * - $a = new ClassA(Configuration $configuration);
26 * This kind of dependencies SHOULD be defined here:
27 * - $a = new ClassA();
30 * - $a = new ClassA($creationPassedVariable);
35 // marks all class result as shared for other creations, so there's just
36 // one instance for the whole execution
40 'instanceOf' => Util\BasePath::class,
42 ['getPath', [], Dice::CHAIN_CALL],
44 'constructParams' => [
49 Util\BasePath::class => [
50 'constructParams' => [
55 Util\ConfigFileLoader::class => [
57 'constructParams' => [
58 [Dice::INSTANCE => '$basepath'],
61 Config\Cache\ConfigCache::class => [
62 'instanceOf' => Factory\ConfigFactory::class,
64 ['createCache', [], Dice::CHAIN_CALL],
69 ['determineRunMode', [true, $_SERVER], Dice::CHAIN_CALL],
70 ['determine', [], Dice::CHAIN_CALL],
73 Config\IConfiguration::class => [
74 'instanceOf' => Factory\ConfigFactory::class,
76 ['createConfig', [], Dice::CHAIN_CALL],
79 Config\IPConfiguration::class => [
80 'instanceOf' => Factory\ConfigFactory::class,
82 ['createPConfig', [], Dice::CHAIN_CALL],
86 'constructParams' => [
87 [Dice::INSTANCE => \Psr\Log\NullLogger::class],
92 * Creates the App\BaseURL
95 * $baseURL = new App\BaseURL($configuration, $_SERVER);
97 App\BaseURL::class => [
98 'constructParams' => [
103 'constructParams' => [
104 [Dice::INSTANCE => '$basepath'],
108 * Create a Logger, which implements the LoggerInterface
111 * $loggerFactory = new Factory\LoggerFactory();
112 * $logger = $loggerFactory->create($channel, $configuration, $profiler);
114 * Attention1: We can use DICE for detecting dependencies inside "chained" calls too
115 * Attention2: The variable "$channel" is passed inside the creation of the dependencies per:
116 * $app = $dice->create(App::class, [], ['$channel' => 'index']);
117 * and is automatically passed as an argument with the same name
119 LoggerInterface::class => [
120 'instanceOf' => Factory\LoggerFactory::class,
121 'constructParams' => [
125 ['create', ['index'], Dice::CHAIN_CALL],
129 'instanceOf' => Factory\LoggerFactory::class,
130 'constructParams' => [
134 ['createDev', [], Dice::CHAIN_CALL],
137 Cache\ICache::class => [
138 'instanceOf' => Factory\CacheFactory::class,
140 ['create', [], Dice::CHAIN_CALL],
143 Cache\IMemoryCache::class => [
144 'instanceOf' => Factory\CacheFactory::class,
146 ['create', [], Dice::CHAIN_CALL],
150 'instanceOf' => Factory\LockFactory::class,
152 ['create', [], Dice::CHAIN_CALL],
155 App\Arguments::class => [
156 'instanceOf' => App\Arguments::class,
158 ['determine', [$_SERVER, $_GET], Dice::CHAIN_CALL],
161 App\Module::class => [
162 'instanceOf' => App\Module::class,
164 ['determineModule', [], Dice::CHAIN_CALL],
168 'constructParams' => [
169 [Dice::INSTANCE => '$basepath'],
172 App\Router::class => [
173 'constructParams' => [
177 ['loadRoutes', [include __DIR__ . '/routes.config.php'], Dice::CHAIN_CALL],
181 'constructParams' => [
186 'instanceOf' => Factory\SessionFactory::class,
188 ['createSession', [$_SERVER], Dice::CHAIN_CALL],
189 ['start', [], Dice::CHAIN_CALL],
193 'constructParams' => [