]> git.mxchange.org Git - friendica.git/blob - src/Factory/ConfigFactory.php
Introduce DICE
[friendica.git] / src / Factory / ConfigFactory.php
1 <?php
2
3 namespace Friendica\Factory;
4
5 use Friendica\Core;
6 use Friendica\Core\Config;
7 use Friendica\Core\Config\Cache;
8 use Friendica\Model\Config\Config as ConfigModel;
9 use Friendica\Model\Config\PConfig as PConfigModel;
10 use Friendica\Util\ConfigFileLoader;
11
12 class ConfigFactory
13 {
14         /**
15          * @param ConfigFileLoader $loader The Config Cache loader (INI/config/.htconfig)
16          *
17          * @return Cache\ConfigCache
18          */
19         public function createCache(ConfigFileLoader $loader)
20         {
21                 $configCache = new Cache\ConfigCache();
22                 $loader->setupCache($configCache);
23
24                 return $configCache;
25         }
26
27         /**
28          * @param Cache\ConfigCache $configCache The config cache of this adapter
29          * @param ConfigModel       $configModel The configuration model
30          *
31          * @return Config\Configuration
32          */
33         public function createConfig(Cache\ConfigCache $configCache, ConfigModel $configModel)
34         {
35                 if ($configCache->get('system', 'config_adapter') === 'preload') {
36                         $configuration = new Config\PreloadConfiguration($configCache, $configModel);
37                 } else {
38                         $configuration = new Config\JitConfiguration($configCache, $configModel);
39                 }
40
41
42                 // Set the config in the static container for legacy usage
43                 Core\Config::init($configuration);
44
45                 return $configuration;
46         }
47
48         /**
49          * @param Cache\ConfigCache  $configCache  The config cache
50          * @param Cache\PConfigCache $pConfigCache The personal config cache
51          * @param PConfigModel       $configModel  The configuration model
52          *
53          * @return Config\PConfiguration
54          */
55         public function createPConfig(Cache\ConfigCache $configCache, Cache\PConfigCache $pConfigCache, PConfigModel $configModel)
56         {
57                 if ($configCache->get('system', 'config_adapter') === 'preload') {
58                         $configuration = new Config\PreloadPConfiguration($pConfigCache, $configModel);
59                 } else {
60                         $configuration = new Config\JitPConfiguration($pConfigCache, $configModel);
61                 }
62
63                 // Set the config in the static container for legacy usage
64                 Core\PConfig::init($configuration);
65
66                 return $configuration;
67         }
68 }