5 use Friendica\Core\Config;
6 use Friendica\Database\Database;
9 use Psr\Log\LoggerInterface;
12 * The configuration defines "complex" dependencies inside Friendica
13 * So this classes shouldn't be simple or their dependencies are already defined here.
15 * This kind of dependencies are NOT required to be defined here:
16 * - $a = new ClassA(new ClassB());
17 * - $a = new ClassA();
18 * - $a = new ClassA(Configuration $configuration);
20 * This kind of dependencies SHOULD be defined here:
21 * - $a = new ClassA();
24 * - $a = new ClassA($creationPassedVariable);
29 // marks all class result as shared for other creations, so there's just
30 // one instance for the whole execution
34 'instanceOf' => Util\BasePath::class,
36 ['getPath', [], Dice::CHAIN_CALL],
38 'constructParams' => [
43 Util\BasePath::class => [
44 'constructParams' => [
49 Util\ConfigFileLoader::class => [
51 'constructParams' => [
52 [Dice::INSTANCE => '$basepath'],
55 Config\Cache\ConfigCache::class => [
56 'instanceOf' => Factory\ConfigFactory::class,
58 ['createCache', [], Dice::CHAIN_CALL],
63 ['determine', [], Dice::CHAIN_CALL],
66 Config\Configuration::class => [
68 'instanceOf' => Factory\ConfigFactory::class,
70 ['createConfig', [], Dice::CHAIN_CALL],
73 Config\PConfiguration::class => [
74 'instanceOf' => Factory\ConfigFactory::class,
76 ['createPConfig', [], Dice::CHAIN_CALL],
80 'constructParams' => [
81 [DICE::INSTANCE => \Psr\Log\NullLogger::class],
86 * Creates the Util\BaseURL
89 * $baseURL = new Util\BaseURL($configuration, $_SERVER);
91 Util\BaseURL::class => [
92 'constructParams' => [
97 * Create a Logger, which implements the LoggerInterface
100 * $loggerFactory = new Factory\LoggerFactory();
101 * $logger = $loggerFactory->create($channel, $configuration, $profiler);
103 * Attention1: We can use DICE for detecting dependencies inside "chained" calls too
104 * Attention2: The variable "$channel" is passed inside the creation of the dependencies per:
105 * $app = $dice->create(App::class, [], ['$channel' => 'index']);
106 * and is automatically passed as an argument with the same name
108 LoggerInterface::class => [
109 'instanceOf' => Factory\LoggerFactory::class,
111 ['create', [], Dice::CHAIN_CALL],
115 'instanceOf' => Factory\LoggerFactory::class,
117 ['createDev', [], Dice::CHAIN_CALL],