From d5743f008d9221f4199570fb0a6cb63d0cf88038 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 26 Nov 2013 18:11:54 +0100 Subject: [ticket/12039] Add config:* to the command line interface tool PHPBB3-12039 --- phpBB/phpbb/console/command/config/increment.php | 62 ++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 phpBB/phpbb/console/command/config/increment.php (limited to 'phpBB/phpbb/console/command/config/increment.php') diff --git a/phpBB/phpbb/console/command/config/increment.php b/phpBB/phpbb/console/command/config/increment.php new file mode 100644 index 0000000000..0974d34cc5 --- /dev/null +++ b/phpBB/phpbb/console/command/config/increment.php @@ -0,0 +1,62 @@ +config = $config; + + parent::__construct(); + } + + protected function configure() + { + $this + ->setName('config:increment') + ->setDescription('Sets a configuration option\'s value') + ->addArgument( + 'config-key', + InputArgument::REQUIRED, + 'The configuration option\'s name' + ) + ->addArgument( + 'increment', + InputArgument::REQUIRED, + 'Amount to increment by' + ) + ->addArgument( + 'use-cache', + InputArgument::OPTIONAL, + 'Whether this variable should be cached or if it changes too frequently to be efficiently cached.', + true + ) + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $key = $input->getArgument('config-key'); + $increment = $input->getArgument('increment'); + $use_cache = $input->getArgument('use-cache'); + $use_cache = (strtolower($use_cache) !== 'false' && $use_cache); + + $this->config->increment($key, $increment, $use_cache); + + $output->writeln("Successfully incremented config $key"); + } +} -- cgit v1.2.1 From e6749261f1797cd4bb9b93398ed92ae5d9c32b26 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 27 Nov 2013 14:16:34 +0100 Subject: [ticket/12039] Use an abstract class and some more minor adjustments PHPBB3-12039 --- phpBB/phpbb/console/command/config/increment.php | 34 +++++++++--------------- 1 file changed, 12 insertions(+), 22 deletions(-) (limited to 'phpBB/phpbb/console/command/config/increment.php') diff --git a/phpBB/phpbb/console/command/config/increment.php b/phpBB/phpbb/console/command/config/increment.php index 0974d34cc5..06b2772230 100644 --- a/phpBB/phpbb/console/command/config/increment.php +++ b/phpBB/phpbb/console/command/config/increment.php @@ -10,50 +10,40 @@ namespace phpbb\console\command\config; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -class increment extends \phpbb\console\command\command +class increment extends command { - /** @var \phpbb\config\config */ - protected $config; - - function __construct(\phpbb\config\config $config) - { - $this->config = $config; - - parent::__construct(); - } - protected function configure() { $this ->setName('config:increment') - ->setDescription('Sets a configuration option\'s value') + ->setDescription("Sets a configuration option's value") ->addArgument( - 'config-key', + 'key', InputArgument::REQUIRED, - 'The configuration option\'s name' + "The configuration option's name" ) ->addArgument( 'increment', InputArgument::REQUIRED, 'Amount to increment by' ) - ->addArgument( - 'use-cache', - InputArgument::OPTIONAL, - 'Whether this variable should be cached or if it changes too frequently to be efficiently cached.', - true + ->addOption( + 'dynamic', + 'd', + InputOption::VALUE_NONE, + 'Set this option if the configuration option changes too frequently to be efficiently cached.' ) ; } protected function execute(InputInterface $input, OutputInterface $output) { - $key = $input->getArgument('config-key'); + $key = $input->getArgument('key'); $increment = $input->getArgument('increment'); - $use_cache = $input->getArgument('use-cache'); - $use_cache = (strtolower($use_cache) !== 'false' && $use_cache); + $use_cache = !$input->getOption('dynamic'); $this->config->increment($key, $increment, $use_cache); -- cgit v1.2.1 From de727b80e285970c0e770c8597c6b56adb513a4d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 27 Nov 2013 15:16:40 +0100 Subject: [ticket/12039] Fix option descriptions PHPBB3-12039 --- phpBB/phpbb/console/command/config/increment.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/console/command/config/increment.php') diff --git a/phpBB/phpbb/console/command/config/increment.php b/phpBB/phpbb/console/command/config/increment.php index 06b2772230..5f5d03b50b 100644 --- a/phpBB/phpbb/console/command/config/increment.php +++ b/phpBB/phpbb/console/command/config/increment.php @@ -19,7 +19,7 @@ class increment extends command { $this ->setName('config:increment') - ->setDescription("Sets a configuration option's value") + ->setDescription("Increment a configuration option's value") ->addArgument( 'key', InputArgument::REQUIRED, -- cgit v1.2.1 From 98200161fc642ce447395a4b8db3b1a3c674c734 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 26 Dec 2013 19:03:43 +0100 Subject: [ticket/12039] Update command descriptions PHPBB3-12039 --- phpBB/phpbb/console/command/config/increment.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/console/command/config/increment.php') diff --git a/phpBB/phpbb/console/command/config/increment.php b/phpBB/phpbb/console/command/config/increment.php index 5f5d03b50b..bc6b63c6ff 100644 --- a/phpBB/phpbb/console/command/config/increment.php +++ b/phpBB/phpbb/console/command/config/increment.php @@ -19,7 +19,7 @@ class increment extends command { $this ->setName('config:increment') - ->setDescription("Increment a configuration option's value") + ->setDescription("Increments a configuration option's value") ->addArgument( 'key', InputArgument::REQUIRED, -- cgit v1.2.1