]> git.mxchange.org Git - friendica.git/blob - src/Factory/DependencyFactory.php
Merge pull request #6978 from annando/no-queue
[friendica.git] / src / Factory / DependencyFactory.php
1 <?php
2
3 namespace Friendica\Factory;
4
5 use Friendica\App;
6 use Friendica\Factory;
7 use Friendica\Util\BasePath;
8 use Friendica\Util\Config;
9
10 class DependencyFactory
11 {
12         /**
13          * Setting all default-dependencies of a friendica execution
14          *
15          * @param string $channel   The channel of this execution
16          * @param string $directory The base directory
17          * @param bool   $isBackend True, if it's a backend execution, otherwise false (Default true)
18          *
19          * @return App The application
20          *
21          * @throws \Exception
22          */
23         public static function setUp($channel, $directory, $isBackend = true)
24         {
25                 $basePath = BasePath::create($directory, $_SERVER);
26                 $mode = new App\Mode($basePath);
27                 $router = new App\Router();
28                 $configLoader = new Config\ConfigFileLoader($basePath, $mode);
29                 $configCache = Factory\ConfigFactory::createCache($configLoader);
30                 $profiler = Factory\ProfilerFactory::create($configCache);
31                 Factory\DBFactory::init($basePath, $configCache, $profiler, $_SERVER);
32                 $config = Factory\ConfigFactory::createConfig($configCache);
33                 // needed to call PConfig::init()
34                 Factory\ConfigFactory::createPConfig($configCache);
35                 $logger = Factory\LoggerFactory::create($channel, $config, $profiler);
36                 Factory\LoggerFactory::createDev($channel, $config, $profiler);
37
38                 return new App($config, $mode, $router, $logger, $profiler, $isBackend);
39         }
40 }