]> git.mxchange.org Git - friendica.git/blob - src/Factory/ConfigFactory.php
Merge pull request #6598 from annando/worker-index
[friendica.git] / src / Factory / ConfigFactory.php
1 <?php
2
3 namespace Friendica\Factory;
4
5 use Friendica\Core\Config;
6
7 class ConfigFactory
8 {
9         /**
10          * @param Config\ConfigCacheLoader $loader The Config Cache loader (INI/config/.htconfig)
11          *
12          * @return Config\ConfigCache
13          */
14         public static function createCache(Config\ConfigCacheLoader $loader)
15         {
16                 $configCache = new Config\ConfigCache();
17                 $loader->loadConfigFiles($configCache);
18
19                 return $configCache;
20         }
21
22         /**
23          * @param string              $type   The adapter type
24          * @param Config\IConfigCache $config The config cache of this adapter
25          *
26          * @return Config\IConfigAdapter
27          */
28         public static function createConfig($type, Config\IConfigCache $config)
29         {
30                 if ($type == 'preload') {
31                         return new Config\PreloadConfigAdapter($config);
32                 } else {
33                         return new Config\JITConfigAdapter($config);
34                 }
35         }
36
37         /**
38          * @param string               $type   The adapter type
39          * @param Config\IPConfigCache $config The config cache of this adapter
40          * @param int                  $uid    The UID of the current user
41          *
42          * @return Config\IPConfigAdapter
43          */
44         public static function createPConfig($type, Config\IPConfigCache $config, $uid = null)
45         {
46                 if ($type == 'preload') {
47                         return new Config\PreloadPConfigAdapter($config, $uid);
48                 } else {
49                         return new Config\JITPConfigAdapter($config);
50                 }
51         }
52 }