Option to change/set plugin settings by plugin name

This commit is contained in:
slawkens
2025-08-22 18:20:37 +02:00
parent 17ca93d020
commit 4b948e9510

View File

@@ -3,6 +3,7 @@
namespace MyAAC\Commands; namespace MyAAC\Commands;
use MyAAC\Models\Settings as SettingsModel; use MyAAC\Models\Settings as SettingsModel;
use MyAAC\Plugins;
use MyAAC\Settings; use MyAAC\Settings;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
@@ -17,7 +18,7 @@ class SettingsSetCommand extends Command
->setDescription('Updates the setting specified by argument in database') ->setDescription('Updates the setting specified by argument in database')
->addArgument('key', ->addArgument('key',
InputArgument::REQUIRED, InputArgument::REQUIRED,
'Setting name/key' 'Setting key in format name.key'
) )
->addArgument('value', ->addArgument('value',
InputArgument::REQUIRED, InputArgument::REQUIRED,
@@ -34,6 +35,18 @@ class SettingsSetCommand extends Command
$key = $input->getArgument('key'); $key = $input->getArgument('key');
$value = $input->getArgument('value'); $value = $input->getArgument('value');
// format settings_name.key
// example: core.template
$explode = explode('.', $key);
// find by plugin name
foreach (Plugins::getAllPluginsSettings() as $_key => $setting) {
if ($setting['pluginFilename'] === $explode[0]) {
$explode[0] = $_key;
$key = implode('.', $explode);
}
}
$settings = Settings::getInstance(); $settings = Settings::getInstance();
$settings->clearCache(); $settings->clearCache();
$settings->load(); $settings->load();
@@ -44,10 +57,6 @@ class SettingsSetCommand extends Command
return Command::FAILURE; return Command::FAILURE;
} }
// format plugin_name.key
// example: core.template
$explode = explode('.', $key);
$settings->updateInDatabase($explode[0], $explode[1], $value); $settings->updateInDatabase($explode[0], $explode[1], $value);
$settings->clearCache(); $settings->clearCache();