]> git.mxchange.org Git - friendica.git/blob - src/Factory/ConfigFactory.php
3) Introducing ConfigFactory
[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         public static function createCache(Config\ConfigCacheLoader $loader)
10         {
11                 $configCache = new Config\ConfigCache();
12                 $loader->loadConfigFiles($configCache);
13
14                 return $configCache;
15         }
16
17         /**
18          * @param string              $type   The adapter type
19          * @param Config\IConfigCache $config The config cache of this adapter
20          * @return Config\IConfigAdapter
21          */
22         public static function createConfig($type, $config)
23         {
24                 if ($type == 'preload') {
25                         return new Config\PreloadConfigAdapter($config);
26                 } else {
27                         return new Config\JITConfigAdapter($config);
28                 }
29         }
30
31         /**
32          * @param string               $type   The adapter type
33          * @param int                  $uid    The UID of the current user
34          * @param Config\IPConfigCache $config The config cache of this adapter
35          * @return Config\IPConfigAdapter
36          */
37         public static function createPConfig($type, $uid, $config)
38         {
39                 if ($type == 'preload') {
40                         return new Config\PreloadPConfigAdapter($uid, $config);
41                 } else {
42                         return new Config\JITPConfigAdapter($config);
43                 }
44         }
45 }