Introduce DICE

- Adding dice library
- Adding dependency config

- Removing Factories
- Refactoring App\Mode constructor
- Refactoring App\Router constructor
- Refactoring BasePath for DI usage
- Refactoring ConfigFileLoader constructor
- Refactoring Profiler constructor

- Adjust entrypoints (index, console, worker, ..)

- Adding functional test for DI
- Fix tests because of refactorings
This commit is contained in:
Philipp Holzer 2019-07-21 01:22:10 +02:00
parent 5887b9c499
commit 55999730e0
No known key found for this signature in database
GPG key ID: D8365C3D36B77D90
28 changed files with 563 additions and 308 deletions

View file

@ -3,7 +3,6 @@
namespace Friendica\Util;
use Exception;
use Friendica\App;
use Friendica\Core\Addon;
use Friendica\Core\Config\Cache\ConfigCache;
@ -52,10 +51,6 @@ class ConfigFileLoader
*/
const SAMPLE_END = '-sample';
/**
* @var App\Mode
*/
private $appMode;
/**
* @var string
*/
@ -69,12 +64,11 @@ class ConfigFileLoader
*/
private $staticDir;
public function __construct($baseDir, App\Mode $mode)
public function __construct(string $basePath)
{
$this->baseDir = $baseDir;
$this->configDir = $baseDir . DIRECTORY_SEPARATOR . self::CONFIG_DIR;
$this->staticDir = $baseDir . DIRECTORY_SEPARATOR . self::STATIC_DIR;
$this->appMode = $mode;
$this->baseDir = $basePath;
$this->configDir = $this->baseDir . DIRECTORY_SEPARATOR . self::CONFIG_DIR;
$this->staticDir = $this->baseDir . DIRECTORY_SEPARATOR . self::STATIC_DIR;
}
/**
@ -102,7 +96,7 @@ class ConfigFileLoader
$this->loadCoreConfig($config);
// In case of install mode, add the found basepath (because there isn't a basepath set yet
if (!$raw && ($this->appMode->isInstall() || empty($config->get('system', 'basepath')))) {
if (!$raw && empty($config->get('system', 'basepath'))) {
// Setting at least the basepath we know
$config->set('system', 'basepath', $this->baseDir);
}