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.
 
 
 
 
 
 

37 lines
1.0 KiB

  1. <?php
  2. namespace Friendica\Factory;
  3. use Friendica\App;
  4. use Friendica\Core\Config\Cache;
  5. use Friendica\Factory;
  6. use Friendica\Util\BasePath;
  7. class DependencyFactory
  8. {
  9. /**
  10. * Setting all default-dependencies of a friendica execution
  11. *
  12. * @param string $channel The channel of this execution
  13. * @param string $directory The base directory
  14. * @param bool $isBackend True, if it's a backend execution, otherwise false (Default true)
  15. *
  16. * @return App The application
  17. *
  18. * @throws \Exception
  19. */
  20. public static function setUp($channel, $directory, $isBackend = true)
  21. {
  22. $basedir = BasePath::create($directory, $_SERVER);
  23. $configLoader = new Cache\ConfigCacheLoader($basedir);
  24. $configCache = Factory\ConfigFactory::createCache($configLoader);
  25. Factory\DBFactory::init($configCache, $_SERVER);
  26. $config = Factory\ConfigFactory::createConfig($configCache);
  27. // needed to call PConfig::init()
  28. Factory\ConfigFactory::createPConfig($configCache);
  29. Factory\LoggerFactory::create($channel, $config);
  30. return new App($config, $isBackend);
  31. }
  32. }