[CORE][Util][Common] Correct behaviour for absense of value
This commit is contained in:
parent
517ed953f2
commit
071b769997
@ -73,13 +73,22 @@ abstract class Common
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Access sysadmin's configuration preferences for GNU social
|
* Access sysadmin's configuration preferences for GNU social
|
||||||
|
* Returns value if exists, null if not set
|
||||||
*/
|
*/
|
||||||
public static function config(string $section, ?string $setting = null)
|
public static function config(string $section, ?string $setting = null)
|
||||||
{
|
{
|
||||||
|
if (!array_key_exists($section, self::$config)) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
if ($setting !== null) {
|
if ($setting !== null) {
|
||||||
|
if (array_key_exists($setting, self::$config[$section])) {
|
||||||
return self::$config[$section][$setting];
|
return self::$config[$section][$setting];
|
||||||
} else {
|
} else {
|
||||||
return self::$config[$section] ?? [];
|
return null;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return self::$config[$section];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user