From 6f1ddc498d64edddd56aaa910f2968f8ef8c9834 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Wed, 11 Feb 2026 14:19:07 +0000
Subject: [PATCH 1/2] Initial plan
From 1d54b66ca1c99c349d4af6cbd2ac904b75060026 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Wed, 11 Feb 2026 14:24:04 +0000
Subject: [PATCH 2/2] Add CLI commands to enable and disable plugin features
Co-authored-by: ccailly <42278610+ccailly@users.noreply.github.com>
---
src/Command/DisableFeatureCommand.php | 104 ++++++++++++++++++++
src/Command/EnableFeatureCommand.php | 104 ++++++++++++++++++++
tests/Command/DisableFeatureCommandTest.php | 85 ++++++++++++++++
tests/Command/EnableFeatureCommandTest.php | 85 ++++++++++++++++
4 files changed, 378 insertions(+)
create mode 100644 src/Command/DisableFeatureCommand.php
create mode 100644 src/Command/EnableFeatureCommand.php
create mode 100644 tests/Command/DisableFeatureCommandTest.php
create mode 100644 tests/Command/EnableFeatureCommandTest.php
diff --git a/src/Command/DisableFeatureCommand.php b/src/Command/DisableFeatureCommand.php
new file mode 100644
index 0000000..fec30f3
--- /dev/null
+++ b/src/Command/DisableFeatureCommand.php
@@ -0,0 +1,104 @@
+setName('plugins:advancedforms:disable');
+ $this->setDescription(__('Disable a feature of the advancedforms plugin.', 'advancedforms'));
+ $this->setHelp(
+ __('This command disables a specific feature (question type) of the advancedforms plugin.', 'advancedforms')
+ . "\n\n"
+ . __('Available features:', 'advancedforms')
+ . "\n"
+ . implode("\n", array_map(
+ fn($type) => sprintf(' - %s: %s', $type::getConfigKey(), $type->getConfigTitle()),
+ ConfigManager::getInstance()->getConfigurableQuestionTypes(),
+ ))
+ );
+
+ $this->addArgument(
+ 'feature',
+ InputArgument::REQUIRED,
+ __('The feature config key to disable (e.g., enable_question_type_ip_address).', 'advancedforms'),
+ );
+ }
+
+ #[Override]
+ protected function execute(InputInterface $input, OutputInterface $output): int
+ {
+ $feature = $input->getArgument('feature');
+ $config_manager = ConfigManager::getInstance();
+
+ $valid_keys = array_map(
+ fn($type) => $type::getConfigKey(),
+ $config_manager->getConfigurableQuestionTypes(),
+ );
+
+ if (!in_array($feature, $valid_keys, true)) {
+ $output->writeln(sprintf(
+ '' . __('Invalid feature key "%s".', 'advancedforms') . '',
+ $feature,
+ ));
+ $output->writeln(__('Available features:', 'advancedforms'));
+ foreach ($config_manager->getConfigurableQuestionTypes() as $type) {
+ $output->writeln(sprintf(' - %s: %s', $type::getConfigKey(), $type->getConfigTitle()));
+ }
+ return Command::FAILURE;
+ }
+
+ Config::setConfigurationValues('advancedforms', [
+ $feature => 0,
+ ]);
+
+ $output->writeln(sprintf(
+ '' . __('Feature "%s" has been disabled.', 'advancedforms') . '',
+ $feature,
+ ));
+
+ return Command::SUCCESS;
+ }
+}
diff --git a/src/Command/EnableFeatureCommand.php b/src/Command/EnableFeatureCommand.php
new file mode 100644
index 0000000..f3684f6
--- /dev/null
+++ b/src/Command/EnableFeatureCommand.php
@@ -0,0 +1,104 @@
+setName('plugins:advancedforms:enable');
+ $this->setDescription(__('Enable a feature of the advancedforms plugin.', 'advancedforms'));
+ $this->setHelp(
+ __('This command enables a specific feature (question type) of the advancedforms plugin.', 'advancedforms')
+ . "\n\n"
+ . __('Available features:', 'advancedforms')
+ . "\n"
+ . implode("\n", array_map(
+ fn($type) => sprintf(' - %s: %s', $type::getConfigKey(), $type->getConfigTitle()),
+ ConfigManager::getInstance()->getConfigurableQuestionTypes(),
+ ))
+ );
+
+ $this->addArgument(
+ 'feature',
+ InputArgument::REQUIRED,
+ __('The feature config key to enable (e.g., enable_question_type_ip_address).', 'advancedforms'),
+ );
+ }
+
+ #[Override]
+ protected function execute(InputInterface $input, OutputInterface $output): int
+ {
+ $feature = $input->getArgument('feature');
+ $config_manager = ConfigManager::getInstance();
+
+ $valid_keys = array_map(
+ fn($type) => $type::getConfigKey(),
+ $config_manager->getConfigurableQuestionTypes(),
+ );
+
+ if (!in_array($feature, $valid_keys, true)) {
+ $output->writeln(sprintf(
+ '' . __('Invalid feature key "%s".', 'advancedforms') . '',
+ $feature,
+ ));
+ $output->writeln(__('Available features:', 'advancedforms'));
+ foreach ($config_manager->getConfigurableQuestionTypes() as $type) {
+ $output->writeln(sprintf(' - %s: %s', $type::getConfigKey(), $type->getConfigTitle()));
+ }
+ return Command::FAILURE;
+ }
+
+ Config::setConfigurationValues('advancedforms', [
+ $feature => 1,
+ ]);
+
+ $output->writeln(sprintf(
+ '' . __('Feature "%s" has been enabled.', 'advancedforms') . '',
+ $feature,
+ ));
+
+ return Command::SUCCESS;
+ }
+}
diff --git a/tests/Command/DisableFeatureCommandTest.php b/tests/Command/DisableFeatureCommandTest.php
new file mode 100644
index 0000000..564d59a
--- /dev/null
+++ b/tests/Command/DisableFeatureCommandTest.php
@@ -0,0 +1,85 @@
+enableConfigurableItem($item);
+ $this->assertTrue(
+ ConfigManager::getInstance()->isConfigurableItemEnabled($item),
+ );
+
+ // Act: run the disable command
+ $command = new DisableFeatureCommand();
+ $tester = new CommandTester($command);
+ $tester->execute(['feature' => $item::getConfigKey()]);
+
+ // Assert: command succeeded and feature is disabled
+ $this->assertEquals(Command::SUCCESS, $tester->getStatusCode());
+ $this->assertFalse(
+ ConfigManager::getInstance()->isConfigurableItemEnabled($item),
+ );
+ $this->assertStringContainsString(
+ $item::getConfigKey(),
+ $tester->getDisplay(),
+ );
+ }
+
+ public function testDisableInvalidFeature(): void
+ {
+ // Act: run the disable command with an invalid feature key
+ $command = new DisableFeatureCommand();
+ $tester = new CommandTester($command);
+ $tester->execute(['feature' => 'invalid_feature_key']);
+
+ // Assert: command failed
+ $this->assertEquals(Command::FAILURE, $tester->getStatusCode());
+ $this->assertStringContainsString(
+ 'invalid_feature_key',
+ $tester->getDisplay(),
+ );
+ }
+}
diff --git a/tests/Command/EnableFeatureCommandTest.php b/tests/Command/EnableFeatureCommandTest.php
new file mode 100644
index 0000000..8ad5e45
--- /dev/null
+++ b/tests/Command/EnableFeatureCommandTest.php
@@ -0,0 +1,85 @@
+disableConfigurableItem($item);
+ $this->assertFalse(
+ ConfigManager::getInstance()->isConfigurableItemEnabled($item),
+ );
+
+ // Act: run the enable command
+ $command = new EnableFeatureCommand();
+ $tester = new CommandTester($command);
+ $tester->execute(['feature' => $item::getConfigKey()]);
+
+ // Assert: command succeeded and feature is enabled
+ $this->assertEquals(Command::SUCCESS, $tester->getStatusCode());
+ $this->assertTrue(
+ ConfigManager::getInstance()->isConfigurableItemEnabled($item),
+ );
+ $this->assertStringContainsString(
+ $item::getConfigKey(),
+ $tester->getDisplay(),
+ );
+ }
+
+ public function testEnableInvalidFeature(): void
+ {
+ // Act: run the enable command with an invalid feature key
+ $command = new EnableFeatureCommand();
+ $tester = new CommandTester($command);
+ $tester->execute(['feature' => 'invalid_feature_key']);
+
+ // Assert: command failed
+ $this->assertEquals(Command::FAILURE, $tester->getStatusCode());
+ $this->assertStringContainsString(
+ 'invalid_feature_key',
+ $tester->getDisplay(),
+ );
+ }
+}