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\Session\ISession;
10 use Friendica\Database\Database;
11 use Friendica\Factory;
13 use Psr\Log\LoggerInterface;
16 * The configuration defines "complex" dependencies inside Friendica
17 * So this classes shouldn't be simple or their dependencies are already defined here.
19 * This kind of dependencies are NOT required to be defined here:
20 * - $a = new ClassA(new ClassB());
21 * - $a = new ClassA();
22 * - $a = new ClassA(Configuration $configuration);
24 * This kind of dependencies SHOULD be defined here:
25 * - $a = new ClassA();
28 * - $a = new ClassA($creationPassedVariable);
33 // marks all class result as shared for other creations, so there's just
34 // one instance for the whole execution
38 'instanceOf' => Util\BasePath::class,
40 ['getPath', [], Dice::CHAIN_CALL],
42 'constructParams' => [
47 Util\BasePath::class => [
48 'constructParams' => [
53 Util\ConfigFileLoader::class => [
55 'constructParams' => [
56 [Dice::INSTANCE => '$basepath'],
59 Config\Cache\ConfigCache::class => [
60 'instanceOf' => Factory\ConfigFactory::class,
62 ['createCache', [], Dice::CHAIN_CALL],
67 ['determineRunMode', [true, $_SERVER], Dice::CHAIN_CALL],
68 ['determine', [], Dice::CHAIN_CALL],
71 Config\Configuration::class => [
72 'instanceOf' => Factory\ConfigFactory::class,
74 ['createConfig', [], Dice::CHAIN_CALL],
77 Config\PConfiguration::class => [
78 'instanceOf' => Factory\ConfigFactory::class,
80 ['createPConfig', [], Dice::CHAIN_CALL],
84 'constructParams' => [
85 [DICE::INSTANCE => \Psr\Log\NullLogger::class],
90 * Creates the App\BaseURL
93 * $baseURL = new App\BaseURL($configuration, $_SERVER);
95 App\BaseURL::class => [
96 'constructParams' => [
101 'constructParams' => [
102 [Dice::INSTANCE => '$basepath'],
106 * Create a Logger, which implements the LoggerInterface
109 * $loggerFactory = new Factory\LoggerFactory();
110 * $logger = $loggerFactory->create($channel, $configuration, $profiler);
112 * Attention1: We can use DICE for detecting dependencies inside "chained" calls too
113 * Attention2: The variable "$channel" is passed inside the creation of the dependencies per:
114 * $app = $dice->create(App::class, [], ['$channel' => 'index']);
115 * and is automatically passed as an argument with the same name
117 LoggerInterface::class => [
118 'instanceOf' => Factory\LoggerFactory::class,
119 'constructParams' => [
123 ['create', ['index'], Dice::CHAIN_CALL],
127 'instanceOf' => Factory\LoggerFactory::class,
128 'constructParams' => [
132 ['createDev', [], Dice::CHAIN_CALL],
135 Cache\ICache::class => [
136 'instanceOf' => Factory\CacheFactory::class,
138 ['create', [], Dice::CHAIN_CALL],
141 Cache\IMemoryCache::class => [
142 'instanceOf' => Factory\CacheFactory::class,
144 ['create', [], Dice::CHAIN_CALL],
148 'instanceOf' => Factory\LockFactory::class,
150 ['create', [], Dice::CHAIN_CALL],
153 App\Arguments::class => [
154 'instanceOf' => App\Arguments::class,
156 ['determine', [$_SERVER, $_GET], Dice::CHAIN_CALL],
159 App\Module::class => [
160 'instanceOf' => App\Module::class,
162 ['determineModule', [], Dice::CHAIN_CALL],
165 Friendica\Core\Process::class => [
166 'constructParams' => [
167 [Dice::INSTANCE => '$basepath'],
170 App\Router::class => [
171 'constructParams' => [
175 ['loadRoutes', [include __DIR__ . '/routes.config.php'], Dice::CHAIN_CALL],
179 'constructParams' => [
184 'instanceOf' => Factory\SessionFactory::class,
186 ['createSession', [$_SERVER], Dice::CHAIN_CALL],
187 ['start', [], Dice::CHAIN_CALL],