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 'instanceOf' => Util\BasePath::class,
31 ['getPath', [], Dice::CHAIN_CALL],
33 'constructParams' => [
38 Util\BasePath::class => [
40 'constructParams' => [
45 Util\ConfigFileLoader::class => [
47 'constructParams' => [
48 [Dice::INSTANCE => '$basepath'],
51 Config\Cache\ConfigCache::class => [
52 'instanceOf' => Factory\ConfigFactory::class,
54 ['createCache', [], Dice::CHAIN_CALL],
60 ['determine', [], Dice::CHAIN_CALL],
62 // marks the result as shared for other creations, so there's just
63 // one instance for the whole execution
66 Config\Configuration::class => [
68 'instanceOf' => Factory\ConfigFactory::class,
70 ['createConfig', [], Dice::CHAIN_CALL],
73 Config\PConfiguration::class => [
75 'instanceOf' => Factory\ConfigFactory::class,
77 ['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 => [
95 'constructParams' => [
100 * Create a Logger, which implements the LoggerInterface
103 * $loggerFactory = new Factory\LoggerFactory();
104 * $logger = $loggerFactory->create($channel, $configuration, $profiler);
106 * Attention1: We can use DICE for detecting dependencies inside "chained" calls too
107 * Attention2: The variable "$channel" is passed inside the creation of the dependencies per:
108 * $app = $dice->create(App::class, [], ['$channel' => 'index']);
109 * and is automatically passed as an argument with the same name
111 LoggerInterface::class => [
113 'instanceOf' => Factory\LoggerFactory::class,
115 ['create', [], Dice::CHAIN_CALL],
120 'instanceOf' => Factory\LoggerFactory::class,
122 ['createDev', [], Dice::CHAIN_CALL],