From fec773ba4b740f35c0a3ef92ca8444a4c7d02082 Mon Sep 17 00:00:00 2001 From: slawkens Date: Mon, 25 Aug 2025 11:35:56 +0200 Subject: [PATCH] plugin:enable/disable commands --- system/src/Commands/PluginDisableCommand.php | 36 ++++++++++++++++++++ system/src/Commands/PluginEnableCommand.php | 36 ++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 system/src/Commands/PluginDisableCommand.php create mode 100644 system/src/Commands/PluginEnableCommand.php diff --git a/system/src/Commands/PluginDisableCommand.php b/system/src/Commands/PluginDisableCommand.php new file mode 100644 index 00000000..baa268dd --- /dev/null +++ b/system/src/Commands/PluginDisableCommand.php @@ -0,0 +1,36 @@ +setName('plugin:disable') + ->setDescription('This command disables plugin') + ->addArgument('plugin-name', InputArgument::REQUIRED, 'Plugin that you want to disable'); + } + + protected function execute(InputInterface $input, OutputInterface $output): int + { + require SYSTEM . 'init.php'; + + $io = new SymfonyStyle($input, $output); + + $pluginName = $input->getArgument('plugin-name'); + + if (!Plugins::disable($pluginName)) { + $io->error('Error while disabling plugin ' . $pluginName . ': ' . Plugins::getError()); + return 2; + } + + $io->success('Successfully disabled plugin ' . $pluginName); + return Command::SUCCESS; + } +} diff --git a/system/src/Commands/PluginEnableCommand.php b/system/src/Commands/PluginEnableCommand.php new file mode 100644 index 00000000..ae1acea0 --- /dev/null +++ b/system/src/Commands/PluginEnableCommand.php @@ -0,0 +1,36 @@ +setName('plugin:enable') + ->setDescription('This command enables plugin') + ->addArgument('plugin-name', InputArgument::REQUIRED, 'Plugin that you want to enable'); + } + + protected function execute(InputInterface $input, OutputInterface $output): int + { + require SYSTEM . 'init.php'; + + $io = new SymfonyStyle($input, $output); + + $pluginName = $input->getArgument('plugin-name'); + + if (!Plugins::enable($pluginName)) { + $io->error('Error while enabling plugin ' . $pluginName . ': ' . Plugins::getError()); + return 2; + } + + $io->success('Successfully enabled plugin ' . $pluginName); + return Command::SUCCESS; + } +}