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