5 use Friendica\Core\Cache;
6 use Friendica\Core\Config;
7 use Friendica\Core\Lock\ILock;
8 use Friendica\Database\Database;
11 use Psr\Log\LoggerInterface;
14 * The configuration defines "complex" dependencies inside Friendica
15 * So this classes shouldn't be simple or their dependencies are already defined here.
17 * This kind of dependencies are NOT required to be defined here:
18 * - $a = new ClassA(new ClassB());
19 * - $a = new ClassA();
20 * - $a = new ClassA(Configuration $configuration);
22 * This kind of dependencies SHOULD be defined here:
23 * - $a = new ClassA();
26 * - $a = new ClassA($creationPassedVariable);
31 // marks all class result as shared for other creations, so there's just
32 // one instance for the whole execution
36 'instanceOf' => Util\BasePath::class,
38 ['getPath', [], Dice::CHAIN_CALL],
40 'constructParams' => [
45 Util\BasePath::class => [
46 'constructParams' => [
51 Util\ConfigFileLoader::class => [
53 'constructParams' => [
54 [Dice::INSTANCE => '$basepath'],
57 Config\Cache\ConfigCache::class => [
58 'instanceOf' => Factory\ConfigFactory::class,
60 ['createCache', [], Dice::CHAIN_CALL],
65 ['determineRunMode', [$_SERVER], Dice::CHAIN_CALL],
66 ['determine', [], Dice::CHAIN_CALL],
69 Config\Configuration::class => [
70 'instanceOf' => Factory\ConfigFactory::class,
72 ['createConfig', [], Dice::CHAIN_CALL],
75 Config\PConfiguration::class => [
76 'instanceOf' => Factory\ConfigFactory::class,
78 ['createPConfig', [], Dice::CHAIN_CALL],
82 'constructParams' => [
83 [DICE::INSTANCE => \Psr\Log\NullLogger::class],
88 * Creates the App\BaseURL
91 * $baseURL = new App\BaseURL($configuration, $_SERVER);
93 App\BaseURL::class => [
94 'constructParams' => [
99 'constructParams' => [
100 [Dice::INSTANCE => '$basepath'],
104 * Create a Logger, which implements the LoggerInterface
107 * $loggerFactory = new Factory\LoggerFactory();
108 * $logger = $loggerFactory->create($channel, $configuration, $profiler);
110 * Attention1: We can use DICE for detecting dependencies inside "chained" calls too
111 * Attention2: The variable "$channel" is passed inside the creation of the dependencies per:
112 * $app = $dice->create(App::class, [], ['$channel' => 'index']);
113 * and is automatically passed as an argument with the same name
115 LoggerInterface::class => [
116 'instanceOf' => Factory\LoggerFactory::class,
118 ['create', [], Dice::CHAIN_CALL],
122 'instanceOf' => Factory\LoggerFactory::class,
124 ['createDev', [], Dice::CHAIN_CALL],
127 Cache\ICache::class => [
128 'instanceOf' => Factory\CacheFactory::class,
130 ['create', [], Dice::CHAIN_CALL],
133 Cache\IMemoryCache::class => [
134 'instanceOf' => Factory\CacheFactory::class,
136 ['create', [], Dice::CHAIN_CALL],
140 'instanceOf' => Factory\LockFactory::class,
142 ['create', [], Dice::CHAIN_CALL],
145 App\Arguments::class => [
146 'instanceOf' => App\Arguments::class,
148 ['determine', [$_SERVER, $_GET], Dice::CHAIN_CALL],
151 App\Module::class => [
152 'instanceOf' => App\Module::class,
154 ['determineModule', [], Dice::CHAIN_CALL],