friendica-github/src/Factory/DependencyFactory.php

39 lines
1.2 KiB
PHP
Raw Normal View History

2019-02-12 19:12:25 +00:00
<?php
namespace Friendica\Factory;
use Friendica\App;
use Friendica\Core\Config\Cache;
use Friendica\Factory;
use Friendica\Util\BasePath;
class DependencyFactory
{
/**
* Setting all default-dependencies of a friendica execution
*
* @param string $channel The channel of this execution
* @param string $directory The base directory
* @param bool $isBackend True, if it's a backend execution, otherwise false (Default true)
*
* @return App The application
*
* @throws \Exception
*/
public static function setUp($channel, $directory, $isBackend = true)
{
$basePath = BasePath::create($directory, $_SERVER);
$configLoader = new Cache\ConfigCacheLoader($basePath);
2019-02-12 19:12:25 +00:00
$configCache = Factory\ConfigFactory::createCache($configLoader);
$profiler = Factory\ProfilerFactory::create($configCache);
Factory\DBFactory::init($basePath, $configCache, $profiler, $_SERVER);
2019-02-12 19:12:25 +00:00
$config = Factory\ConfigFactory::createConfig($configCache);
// needed to call PConfig::init()
Factory\ConfigFactory::createPConfig($configCache);
2019-02-28 08:41:31 +00:00
$logger = Factory\LoggerFactory::create($channel, $config, $profiler);
Factory\LoggerFactory::createDev($channel, $config);
2019-02-12 19:12:25 +00:00
return new App($basePath, $config, $logger, $profiler, $isBackend);
2019-02-12 19:12:25 +00:00
}
}