[LIB][Util] Update Common::setConfig to throw an exception if appropriate, add Formatting::{toString,toArray}

This commit is contained in:
Hugo Sales
2020-07-25 14:42:00 +00:00
committed by Hugo Sales
parent 647fd421ee
commit b772702895
2 changed files with 38 additions and 6 deletions

View File

@@ -52,12 +52,17 @@ abstract class Common
/**
* Set sysadmin's configuration preferences for GNU social
*
* @param mixed $value
*/
public static function setConfig(string $section, string $setting, mixed $value): void
public static function setConfig(string $section, string $setting, $value): void
{
$ojb = DB::getPartialReference('config', ['section' => $section, 'setting' => $setting]);
$obj->setValue(serialize($value));
DB::persist($obj);
$c = DB::getPartialReference('config', ['section' => $section, 'setting' => $setting]);
if ($c === null) {
throw new \Exception("The field section = {$section} and setting = {$setting} doesn't exist");
}
$c->setValue(serialize($value));
DB::flush();
}