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 ['determineBackend', [$_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 Util\BaseURL
91 * $baseURL = new Util\BaseURL($configuration, $_SERVER);
93 Util\BaseURL::class => [
94 'constructParams' => [
99 * Create a Logger, which implements the LoggerInterface
102 * $loggerFactory = new Factory\LoggerFactory();
103 * $logger = $loggerFactory->create($channel, $configuration, $profiler);
105 * Attention1: We can use DICE for detecting dependencies inside "chained" calls too
106 * Attention2: The variable "$channel" is passed inside the creation of the dependencies per:
107 * $app = $dice->create(App::class, [], ['$channel' => 'index']);
108 * and is automatically passed as an argument with the same name
110 LoggerInterface::class => [
111 'instanceOf' => Factory\LoggerFactory::class,
113 ['create', [], Dice::CHAIN_CALL],
117 'instanceOf' => Factory\LoggerFactory::class,
119 ['createDev', [], Dice::CHAIN_CALL],
122 Cache\ICache::class => [
123 'instanceOf' => Factory\CacheFactory::class,
125 ['create', [], Dice::CHAIN_CALL],
128 Cache\IMemoryCache::class => [
129 'instanceOf' => Factory\CacheFactory::class,
131 ['create', [], Dice::CHAIN_CALL],
135 'instanceOf' => Factory\LockFactory::class,
137 ['create', [], Dice::CHAIN_CALL],
140 App\Arguments::class => [
141 'instanceOf' => App\Arguments::class,
143 ['determine', [$_SERVER, $_GET], Dice::CHAIN_CALL],
146 App\Module::class => [
147 'instanceOf' => App\Module::class,
149 ['determineModule', [], Dice::CHAIN_CALL],