improved setting manager + setting caching
This commit is contained in:
parent
ba41cb3456
commit
471fc1dd79
@ -178,7 +178,7 @@ class SettingManager implements CallbackListener {
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function initSetting($object, $settingName, $default) {
|
public function initSetting($object, $settingName, $default) {
|
||||||
if ($default === null || is_object($default)) {
|
if (is_null($default) || is_object($default)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$className = $this->getClassName($object);
|
$className = $this->getClassName($object);
|
||||||
@ -298,6 +298,9 @@ class SettingManager implements CallbackListener {
|
|||||||
*/
|
*/
|
||||||
public function setSetting($object, $settingName, $value) {
|
public function setSetting($object, $settingName, $value) {
|
||||||
$className = $this->getClassName($object);
|
$className = $this->getClassName($object);
|
||||||
|
|
||||||
|
var_dump($className, $settingName, $value);
|
||||||
|
|
||||||
$mysqli = $this->maniaControl->database->mysqli;
|
$mysqli = $this->maniaControl->database->mysqli;
|
||||||
$settingQuery = "UPDATE `" . self::TABLE_SETTINGS . "`
|
$settingQuery = "UPDATE `" . self::TABLE_SETTINGS . "`
|
||||||
SET `value` = ?
|
SET `value` = ?
|
||||||
@ -308,8 +311,8 @@ class SettingManager implements CallbackListener {
|
|||||||
trigger_error($mysqli->error);
|
trigger_error($mysqli->error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$value = $this->formatSetting($value);
|
$setting = $this->formatSetting($value);
|
||||||
$settingStatement->bind_param('sss', $value, $className, $settingName);
|
$settingStatement->bind_param('sss', $setting, $className, $settingName);
|
||||||
$success = $settingStatement->execute();
|
$success = $settingStatement->execute();
|
||||||
if ($settingStatement->error) {
|
if ($settingStatement->error) {
|
||||||
trigger_error($settingStatement->error);
|
trigger_error($settingStatement->error);
|
||||||
@ -318,10 +321,7 @@ class SettingManager implements CallbackListener {
|
|||||||
}
|
}
|
||||||
$settingStatement->close();
|
$settingStatement->close();
|
||||||
|
|
||||||
//FIXME store changed value
|
$this->storedSettings[$className . $settingName] = $value;
|
||||||
if (isset($this->storedSettings[$className . $settingName])) {
|
|
||||||
unset($this->storedSettings[$className . $settingName]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Trigger settings changed Callback
|
// Trigger settings changed Callback
|
||||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_SETTINGS_CHANGED, $className, $settingName, $value);
|
$this->maniaControl->callbackManager->triggerCallback(self::CB_SETTINGS_CHANGED, $className, $settingName, $value);
|
||||||
@ -355,6 +355,9 @@ class SettingManager implements CallbackListener {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$settingStatement->close();
|
$settingStatement->close();
|
||||||
|
if (isset($this->storedSettings[$className . $settingName])) {
|
||||||
|
unset($this->storedSettings[$className . $settingName]);
|
||||||
|
}
|
||||||
return $success;
|
return $success;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -384,6 +387,9 @@ class SettingManager implements CallbackListener {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$settingStatement->close();
|
$settingStatement->close();
|
||||||
|
if (isset($this->storedSettings[$className . $settingName])) {
|
||||||
|
unset($this->storedSettings[$className . $settingName]);
|
||||||
|
}
|
||||||
return $success;
|
return $success;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -454,6 +460,7 @@ class SettingManager implements CallbackListener {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$settingStatement->close();
|
$settingStatement->close();
|
||||||
|
$this->storedSettings = array();
|
||||||
return $success;
|
return $success;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user