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 ['determine', [], Dice::CHAIN_CALL],
68 Config\Configuration::class => [
69 'instanceOf' => Factory\ConfigFactory::class,
71 ['createConfig', [], Dice::CHAIN_CALL],
74 Config\PConfiguration::class => [
75 'instanceOf' => Factory\ConfigFactory::class,
77 ['createPConfig', [], Dice::CHAIN_CALL],
81 'constructParams' => [
82 [DICE::INSTANCE => \Psr\Log\NullLogger::class],
87 * Creates the Util\BaseURL
90 * $baseURL = new Util\BaseURL($configuration, $_SERVER);
92 Util\BaseURL::class => [
93 'constructParams' => [
98 * Create a Logger, which implements the LoggerInterface
101 * $loggerFactory = new Factory\LoggerFactory();
102 * $logger = $loggerFactory->create($channel, $configuration, $profiler);
104 * Attention1: We can use DICE for detecting dependencies inside "chained" calls too
105 * Attention2: The variable "$channel" is passed inside the creation of the dependencies per:
106 * $app = $dice->create(App::class, [], ['$channel' => 'index']);
107 * and is automatically passed as an argument with the same name
109 LoggerInterface::class => [
110 'instanceOf' => Factory\LoggerFactory::class,
112 ['create', [], Dice::CHAIN_CALL],
116 'instanceOf' => Factory\LoggerFactory::class,
118 ['createDev', [], Dice::CHAIN_CALL],
121 Cache\ICache::class => [
122 'instanceOf' => Factory\CacheFactory::class,
124 ['create', [], Dice::CHAIN_CALL],
127 Cache\IMemoryCache::class => [
128 'instanceOf' => Factory\CacheFactory::class,
130 ['create', [], Dice::CHAIN_CALL],
134 'instanceOf' => Factory\LockFactory::class,
136 ['create', [], Dice::CHAIN_CALL],