Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.2KB

  1. <?php
  2. namespace Friendica\Factory;
  3. use Friendica\Core\Config;
  4. class ConfigFactory
  5. {
  6. /**
  7. * @param Config\ConfigCacheLoader $loader The Config Cache loader (INI/config/.htconfig)
  8. *
  9. * @return Config\ConfigCache
  10. */
  11. public static function createCache(Config\ConfigCacheLoader $loader)
  12. {
  13. $configCache = new Config\ConfigCache();
  14. $loader->loadConfigFiles($configCache);
  15. return $configCache;
  16. }
  17. /**
  18. * @param string $type The adapter type
  19. * @param Config\IConfigCache $config The config cache of this adapter
  20. *
  21. * @return Config\IConfigAdapter
  22. */
  23. public static function createConfig($type, $config)
  24. {
  25. if ($type == 'preload') {
  26. return new Config\PreloadConfigAdapter($config);
  27. } else {
  28. return new Config\JITConfigAdapter($config);
  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. *
  36. * @return Config\IPConfigAdapter
  37. */
  38. public static function createPConfig($type, $uid, $config)
  39. {
  40. if ($type == 'preload') {
  41. return new Config\PreloadPConfigAdapter($uid, $config);
  42. } else {
  43. return new Config\JITPConfigAdapter($config);
  44. }
  45. }
  46. }