It's always been one of my least favorite things in SMF. First off, it is a throwback to settings which mods added. When all of the forum's settings were in a file but mods could add settings to the database. So, the name is stupid.
I have always loved how we program to assume the setting doesn't exist, but it does add a lot of code that just checks if the key exists.
Every key from the database gets loaded. That's kind of a waste of a table which could be a simple key/value store. Settings should be immutable in the instance. If you want to change something, you should use another variable.
So, first off, I want to change $modSettings (and every usage of it) to be $elk['settings']. Since we don't have a DIC, $elk will just be an array. It will point to an instance of ElkArte\Settings.
The 30 second mockup
<?php
namespace ElkArte;
class Settings
{
protected $settings;
// @see reloadSettings()
public function reload()
{
}
public function __get($name)
{
return isset($this->settings[$name) ? $this->settings[$name] : null;
}
public function __isset($name)
{
return isset($this->settings[$name]);
}
protected function loadFromDatabase()
{
}
protected function loadFromCache()
{
}
}
Stop gap solution is to use $modSettings and $elk['settings'] at the same time. We can add a getAll() method which will return $settings and then it shouldn't really break anything.