2019-02-12 19:12:25 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Friendica\Factory;
|
|
|
|
|
|
|
|
use Friendica\App;
|
2019-04-14 16:40:39 +00:00
|
|
|
use Friendica\Database\DBA;
|
2019-02-12 19:12:25 +00:00
|
|
|
use Friendica\Factory;
|
|
|
|
use Friendica\Util\BasePath;
|
2019-04-08 19:12:10 +00:00
|
|
|
use Friendica\Util\BaseURL;
|
2019-03-23 14:37:05 +00:00
|
|
|
use Friendica\Util\Config;
|
2019-02-12 19:12:25 +00:00
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2019-02-22 22:51:13 +00:00
|
|
|
$basePath = BasePath::create($directory, $_SERVER);
|
2019-03-14 01:36:49 +00:00
|
|
|
$mode = new App\Mode($basePath);
|
2019-04-06 03:16:12 +00:00
|
|
|
$router = new App\Router();
|
2019-03-24 11:54:26 +00:00
|
|
|
$configLoader = new Config\ConfigFileLoader($basePath, $mode);
|
2019-02-12 19:12:25 +00:00
|
|
|
$configCache = Factory\ConfigFactory::createCache($configLoader);
|
2019-02-17 20:12:12 +00:00
|
|
|
$profiler = Factory\ProfilerFactory::create($configCache);
|
2019-03-26 21:04:31 +00:00
|
|
|
Factory\DBFactory::init($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);
|
2019-04-14 16:40:39 +00:00
|
|
|
DBA::setLogger($logger);
|
2019-03-14 01:36:49 +00:00
|
|
|
Factory\LoggerFactory::createDev($channel, $config, $profiler);
|
2019-04-08 19:12:10 +00:00
|
|
|
$baseURL = new BaseURL($config, $_SERVER);
|
2019-02-12 19:12:25 +00:00
|
|
|
|
2019-04-08 19:12:10 +00:00
|
|
|
return new App($config, $mode, $router, $baseURL, $logger, $profiler, $isBackend);
|
2019-02-12 19:12:25 +00:00
|
|
|
}
|
|
|
|
}
|