3 namespace Friendica\Factory;
7 use Friendica\Util\BasePath;
8 use Friendica\Util\BaseURL;
9 use Friendica\Util\Config;
11 class DependencyFactory
14 * Setting all default-dependencies of a friendica execution
16 * @param string $channel The channel of this execution
17 * @param string $directory The base directory
18 * @param bool $isBackend True, if it's a backend execution, otherwise false (Default true)
20 * @return App The application
24 public static function setUp($channel, $directory, $isBackend = true)
26 $basePath = BasePath::create($directory, $_SERVER);
27 $mode = new App\Mode($basePath);
28 $router = new App\Router();
29 $configLoader = new Config\ConfigFileLoader($basePath, $mode);
30 $configCache = Factory\ConfigFactory::createCache($configLoader);
31 $profiler = Factory\ProfilerFactory::create($configCache);
32 $database = Factory\DBFactory::init($configCache, $profiler, $_SERVER);
33 $config = Factory\ConfigFactory::createConfig($configCache);
34 // needed to call PConfig::init()
35 Factory\ConfigFactory::createPConfig($configCache);
36 $logger = Factory\LoggerFactory::create($channel, $database, $config, $profiler);
37 Factory\LoggerFactory::createDev($channel, $config, $profiler);
38 $baseURL = new BaseURL($config, $_SERVER);
40 return new App($database, $config, $mode, $router, $baseURL, $logger, $profiler, $isBackend);