Add settings.callbacks.get

This commit is contained in:
slawkens 2023-07-13 16:47:09 +02:00
parent e83880653a
commit afa1adb90b
3 changed files with 15 additions and 8 deletions

View File

@ -4,6 +4,7 @@ $deprecatedConfig = [
'template',
'template_allow_change',
'vocations_amount',
'vocations',
'client',
'session_prefix',
'friendly_urls',
@ -44,11 +45,3 @@ foreach ($deprecatedConfig as $key => $value) {
//var_dump($settings['core.'.$value]['value']);
}
$vocationsParsed = array_map(
function(string $value): string {
return trim($value);
},
explode(',', setting('core.vocations'))
);
config(['vocations', $vocationsParsed]);

View File

@ -434,6 +434,10 @@ class Settings implements ArrayAccess
}
}
if (isset($ret['callbacks']['get'])) {
$ret['value'] = $ret['callbacks']['get']($ret['value']);
}
$this->cache[$offset] = $ret;
return $ret;
}

View File

@ -142,6 +142,11 @@ return [
'type' => 'textarea',
'desc' => 'Separated by comma ,',
'default' => 'None, Sorcerer, Druid, Paladin, Knight, Master Sorcerer, Elder Druid,Royal Paladin, Elite Knight',
'callbacks' => [
'get' => function ($value) {
return array_map('trim', explode(',', $value));
},
],
],
'client' => [
'name' => 'Client Version',
@ -673,6 +678,11 @@ Sent by MyAAC,<br/>
'type' => 'text',
'desc' => 'This looktypes needs to have different margin-top and margin-left because they are wrong positioned',
'default' => '75, 126, 127, 266, 302',
'callbacks' => [
'get' => function ($value) {
return array_map('trim', explode(',', $value));
},
],
],
[
'type' => 'section',