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\Database\Database;
10 use Friendica\Factory;
12 use Psr\Log\LoggerInterface;
15 * The configuration defines "complex" dependencies inside Friendica
16 * So this classes shouldn't be simple or their dependencies are already defined here.
18 * This kind of dependencies are NOT required to be defined here:
19 * - $a = new ClassA(new ClassB());
20 * - $a = new ClassA();
21 * - $a = new ClassA(Configuration $configuration);
23 * This kind of dependencies SHOULD be defined here:
24 * - $a = new ClassA();
27 * - $a = new ClassA($creationPassedVariable);
32 // marks all class result as shared for other creations, so there's just
33 // one instance for the whole execution
37 'instanceOf' => Util\BasePath::class,
39 ['getPath', [], Dice::CHAIN_CALL],
41 'constructParams' => [
46 Util\BasePath::class => [
47 'constructParams' => [
52 Util\ConfigFileLoader::class => [
54 'constructParams' => [
55 [Dice::INSTANCE => '$basepath'],
58 Config\Cache\ConfigCache::class => [
59 'instanceOf' => Factory\ConfigFactory::class,
61 ['createCache', [], Dice::CHAIN_CALL],
66 ['determineRunMode', [true, $_SERVER], Dice::CHAIN_CALL],
67 ['determine', [], Dice::CHAIN_CALL],
70 Config\Configuration::class => [
71 'instanceOf' => Factory\ConfigFactory::class,
73 ['createConfig', [], Dice::CHAIN_CALL],
76 Config\PConfiguration::class => [
77 'instanceOf' => Factory\ConfigFactory::class,
79 ['createPConfig', [], Dice::CHAIN_CALL],
83 'constructParams' => [
84 [DICE::INSTANCE => \Psr\Log\NullLogger::class],
89 * Creates the App\BaseURL
92 * $baseURL = new App\BaseURL($configuration, $_SERVER);
94 App\BaseURL::class => [
95 'constructParams' => [
100 'constructParams' => [
101 [Dice::INSTANCE => '$basepath'],
105 * Create a Logger, which implements the LoggerInterface
108 * $loggerFactory = new Factory\LoggerFactory();
109 * $logger = $loggerFactory->create($channel, $configuration, $profiler);
111 * Attention1: We can use DICE for detecting dependencies inside "chained" calls too
112 * Attention2: The variable "$channel" is passed inside the creation of the dependencies per:
113 * $app = $dice->create(App::class, [], ['$channel' => 'index']);
114 * and is automatically passed as an argument with the same name
116 LoggerInterface::class => [
117 'instanceOf' => Factory\LoggerFactory::class,
118 'constructParams' => [
122 ['create', ['index'], Dice::CHAIN_CALL],
126 'instanceOf' => Factory\LoggerFactory::class,
127 'constructParams' => [
131 ['createDev', [], Dice::CHAIN_CALL],
134 Cache\ICache::class => [
135 'instanceOf' => Factory\CacheFactory::class,
137 ['create', [], Dice::CHAIN_CALL],
140 Cache\IMemoryCache::class => [
141 'instanceOf' => Factory\CacheFactory::class,
143 ['create', [], Dice::CHAIN_CALL],
147 'instanceOf' => Factory\LockFactory::class,
149 ['create', [], Dice::CHAIN_CALL],
152 App\Arguments::class => [
153 'instanceOf' => App\Arguments::class,
155 ['determine', [$_SERVER, $_GET], Dice::CHAIN_CALL],
158 App\Module::class => [
159 'instanceOf' => App\Module::class,
161 ['determineModule', [], Dice::CHAIN_CALL],
164 Friendica\Core\Process::class => [
165 'constructParams' => [
166 [Dice::INSTANCE => '$basepath'],
169 App\Router::class => [
170 'constructParams' => [
174 ['addRoutes', [include __DIR__ . '/routes.config.php'], Dice::CHAIN_CALL],
178 'constructParams' => [