mirror of
https://github.com/friendica/friendica
synced 2025-04-26 18:30:11 +00:00
Adding DependencyFactory
This commit is contained in:
parent
0a318925a4
commit
cdcf1667d7
6 changed files with 48 additions and 74 deletions
36
src/Factory/DependencyFactory.php
Normal file
36
src/Factory/DependencyFactory.php
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?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)
|
||||
{
|
||||
$basedir = BasePath::create($directory, $_SERVER);
|
||||
$configLoader = new Cache\ConfigCacheLoader($basedir);
|
||||
$configCache = Factory\ConfigFactory::createCache($configLoader);
|
||||
Factory\DBFactory::init($configCache, $_SERVER);
|
||||
$config = Factory\ConfigFactory::createConfig($configCache);
|
||||
// needed to call PConfig::init()
|
||||
Factory\ConfigFactory::createPConfig($configCache);
|
||||
Factory\LoggerFactory::create($channel, $config);
|
||||
|
||||
return new App($config, $isBackend);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue