Creating Friendica\App\Mode for encapsulating the App Mode

This commit is contained in:
Philipp Holzer
2018-10-05 22:36:09 +02:00
parent 3c7d41c388
commit 065340dc32
9 changed files with 128 additions and 89 deletions

View File

@@ -31,7 +31,7 @@ class Config extends BaseObject
public static function init()
{
// Database isn't ready or populated yet
if (!(self::getApp()->mode & App::MODE_DBCONFIGAVAILABLE)) {
if (!App\Mode::has(App\Mode::DBCONFIGAVAILABLE)) {
return;
}
@@ -55,7 +55,7 @@ class Config extends BaseObject
public static function load($family = "config")
{
// Database isn't ready or populated yet
if (!(self::getApp()->mode & App::MODE_DBCONFIGAVAILABLE)) {
if (!App\Mode::has(App\Mode::DBCONFIGAVAILABLE)) {
return;
}
@@ -88,7 +88,7 @@ class Config extends BaseObject
public static function get($family, $key, $default_value = null, $refresh = false)
{
// Database isn't ready or populated yet, fallback to file config
if (!(self::getApp()->mode & App::MODE_DBCONFIGAVAILABLE)) {
if (!App\Mode::has(App\Mode::DBCONFIGAVAILABLE)) {
return self::getApp()->getConfigValue($family, $key, $default_value);
}
@@ -116,7 +116,7 @@ class Config extends BaseObject
public static function set($family, $key, $value)
{
// Database isn't ready or populated yet
if (!(self::getApp()->mode & App::MODE_DBCONFIGAVAILABLE)) {
if (!App\Mode::has(App\Mode::DBCONFIGAVAILABLE)) {
return false;
}
@@ -141,7 +141,7 @@ class Config extends BaseObject
public static function delete($family, $key)
{
// Database isn't ready or populated yet
if (!(self::getApp()->mode & App::MODE_DBCONFIGAVAILABLE)) {
if (!App\Mode::has(App\Mode::DBCONFIGAVAILABLE)) {
return false;
}

View File

@@ -56,7 +56,7 @@ HELP;
throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
}
if ($a->mode === App::MODE_INSTALL) {
if (App\Mode::isInstall()) {
throw new RuntimeException('Friendica isn\'t properly installed yet.');
}

View File

@@ -65,7 +65,7 @@ HELP;
$this->out('Options: ' . var_export($this->options, true));
}
if (!($a->mode & App::MODE_DBCONFIGAVAILABLE)) {
if (!App\Mode::has(App\Mode::DBCONFIGAVAILABLE)) {
$this->out('Database isn\'t ready or populated yet, database cache won\'t be available');
}

View File

@@ -84,7 +84,7 @@ HELP;
throw new CommandArgsException('Too many arguments');
}
if (!($a->mode & App::MODE_DBCONFIGAVAILABLE)) {
if (!App\Mode::has(App\Mode::DBCONFIGAVAILABLE)) {
$this->out('Database isn\'t ready or populated yet, showing file config only');
}
@@ -143,7 +143,7 @@ HELP;
if (count($this->args) == 0) {
Core\Config::load();
if (Core\Config::get('system', 'config_adapter') == 'jit' && $a->mode & App::MODE_DBCONFIGAVAILABLE) {
if (Core\Config::get('system', 'config_adapter') == 'jit' && App\Mode::has(App\Mode::DBCONFIGAVAILABLE)) {
$this->out('Warning: The JIT (Just In Time) Config adapter doesn\'t support loading the entire configuration, showing file config only');
}

View File

@@ -30,7 +30,7 @@ class PConfig extends BaseObject
public static function init($uid)
{
// Database isn't ready or populated yet
if (!(self::getApp()->mode & App::MODE_DBCONFIGAVAILABLE)) {
if (!App\Mode::has(App\Mode::DBCONFIGAVAILABLE)) {
return;
}
@@ -55,7 +55,7 @@ class PConfig extends BaseObject
public static function load($uid, $family)
{
// Database isn't ready or populated yet
if (!(self::getApp()->mode & App::MODE_DBCONFIGAVAILABLE)) {
if (!App\Mode::has(App\Mode::DBCONFIGAVAILABLE)) {
return;
}
@@ -84,7 +84,7 @@ class PConfig extends BaseObject
public static function get($uid, $family, $key, $default_value = null, $refresh = false)
{
// Database isn't ready or populated yet
if (!(self::getApp()->mode & App::MODE_DBCONFIGAVAILABLE)) {
if (!App\Mode::has(App\Mode::DBCONFIGAVAILABLE)) {
return;
}
@@ -113,7 +113,7 @@ class PConfig extends BaseObject
public static function set($uid, $family, $key, $value)
{
// Database isn't ready or populated yet
if (!(self::getApp()->mode & App::MODE_DBCONFIGAVAILABLE)) {
if (!App\Mode::has(App\Mode::DBCONFIGAVAILABLE)) {
return false;
}
@@ -139,7 +139,7 @@ class PConfig extends BaseObject
public static function delete($uid, $family, $key)
{
// Database isn't ready or populated yet
if (!(self::getApp()->mode & App::MODE_DBCONFIGAVAILABLE)) {
if (!App\Mode::has(App\Mode::DBCONFIGAVAILABLE)) {
return false;
}