I’ve taken both @lukaskleinschmidt @lukasbestle approaches and made something new out of it:
namespace PluginName;
use c;
class settings {
public static function __callStatic($name, $args) {
// Set prefix
$prefix = 'plugin.name.';
// Set config names and fallbacks as settings
$settings = [
'log' => false,
'slug' => 'sync',
'token' => 'token',
];
// If config settings exists, return the config with fallback
if(isset($settings) && array_key_exists($name, $settings)) {
return c::get($prefix . $name, $settings[$name]);
}
}
In the config.php file you can add something like this:
c::set('plugin.name.log', 'logfile.txt');
And get it inside the plugin with:
echo settings::log();
I think it ended up beautifully. Any improvement appreciated.
I think I will name this new baby… “Lukas”
Update: I added array_key_exists
to also allow NULL values to be used