Revert "Introduce Arguments / Module class"

This commit is contained in:
Hypolite Petovan 2019-08-11 18:01:11 -04:00 committed by GitHub
parent e9fc2af1c3
commit fcb1a78352
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 358 additions and 1083 deletions

View file

@ -24,9 +24,27 @@ class Mode
*/
private $mode;
public function __construct(int $mode = 0)
/**
* @var string the basepath of the application
*/
private $basepath;
/**
* @var Database
*/
private $database;
/**
* @var ConfigCache
*/
private $configCache;
public function __construct(BasePath $basepath, Database $database, ConfigCache $configCache)
{
$this->mode = $mode;
$this->basepath = $basepath->getPath();
$this->database = $database;
$this->configCache = $configCache;
$this->mode = 0;
}
/**
@ -36,46 +54,50 @@ class Mode
* - App::MODE_MAINTENANCE: The maintenance mode has been set
* - App::MODE_NORMAL : Normal run with all features enabled
*
* @return Mode returns the determined mode
* @param string $basePath the Basepath of the Application
*
* @return Mode returns itself
*
* @throws \Exception
*/
public function determine(BasePath $basepath, Database $database, ConfigCache $configCache)
public function determine($basePath = null)
{
$mode = 0;
$basepathName = $basepath->getPath();
if (!file_exists($basepathName . '/config/local.config.php')
&& !file_exists($basepathName . '/config/local.ini.php')
&& !file_exists($basepathName . '/.htconfig.php')) {
return new Mode($mode);
if (!empty($basePath)) {
$this->basepath = $basePath;
}
$mode |= Mode::LOCALCONFIGPRESENT;
$this->mode = 0;
if (!$database->connected()) {
return new Mode($mode);
if (!file_exists($this->basepath . '/config/local.config.php')
&& !file_exists($this->basepath . '/config/local.ini.php')
&& !file_exists($this->basepath . '/.htconfig.php')) {
return $this;
}
$mode |= Mode::DBAVAILABLE;
$this->mode |= Mode::LOCALCONFIGPRESENT;
if ($database->fetchFirst("SHOW TABLES LIKE 'config'") === false) {
return new Mode($mode);
if (!$this->database->connected()) {
return $this;
}
$mode |= Mode::DBCONFIGAVAILABLE;
$this->mode |= Mode::DBAVAILABLE;
if (!empty($configCache->get('system', 'maintenance')) ||
if ($this->database->fetchFirst("SHOW TABLES LIKE 'config'") === false) {
return $this;
}
$this->mode |= Mode::DBCONFIGAVAILABLE;
if (!empty($this->configCache->get('system', 'maintenance')) ||
// Don't use Config or Configuration here because we're possibly BEFORE initializing the Configuration,
// so this could lead to a dependency circle
!empty($database->selectFirst('config', ['v'], ['cat' => 'system', 'k' => 'maintenance'])['v'])) {
return new Mode($mode);
!empty($this->database->selectFirst('config', ['v'], ['cat' => 'system', 'k' => 'maintenance'])['v'])) {
return $this;
}
$mode |= Mode::MAINTENANCEDISABLED;
$this->mode |= Mode::MAINTENANCEDISABLED;
return new Mode($mode);
return $this;
}
/**