diff --git a/system/src/Commands/SettingsSetCommand.php b/system/src/Commands/SettingsSetCommand.php index 4ad33227..eac0ecc5 100644 --- a/system/src/Commands/SettingsSetCommand.php +++ b/system/src/Commands/SettingsSetCommand.php @@ -3,6 +3,7 @@ namespace MyAAC\Commands; use MyAAC\Models\Settings as SettingsModel; +use MyAAC\Plugins; use MyAAC\Settings; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -17,7 +18,7 @@ class SettingsSetCommand extends Command ->setDescription('Updates the setting specified by argument in database') ->addArgument('key', InputArgument::REQUIRED, - 'Setting name/key' + 'Setting key in format name.key' ) ->addArgument('value', InputArgument::REQUIRED, @@ -34,6 +35,18 @@ class SettingsSetCommand extends Command $key = $input->getArgument('key'); $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->clearCache(); $settings->load(); @@ -44,10 +57,6 @@ class SettingsSetCommand extends Command return Command::FAILURE; } - // format plugin_name.key - // example: core.template - $explode = explode('.', $key); - $settings->updateInDatabase($explode[0], $explode[1], $value); $settings->clearCache();