From 73ea5daf97bf5447b9bb2ff912cce4a9ea21c58e Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 5 Nov 2013 19:42:34 +0100 Subject: [ticket/11998] Add phpBB abstraction for application and command. PHPBB3-11998 --- phpBB/phpbb/console/application.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 phpBB/phpbb/console/application.php (limited to 'phpBB/phpbb/console/application.php') diff --git a/phpBB/phpbb/console/application.php b/phpBB/phpbb/console/application.php new file mode 100644 index 0000000000..fdcd9d42f6 --- /dev/null +++ b/phpBB/phpbb/console/application.php @@ -0,0 +1,23 @@ +findTaggedServiceIds($tag) as $id => $void) + { + $this->add($container->get($id)); + } + } +} -- cgit v1.2.1 From a759704b39fc1c1353f865a633759b1369589b67 Mon Sep 17 00:00:00 2001 From: Yuriy Rusko Date: Tue, 27 May 2014 20:18:06 +0200 Subject: [ticket/12594] Remove @package tags and update file headers PHPBB3-12594 --- phpBB/phpbb/console/application.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb/console/application.php') diff --git a/phpBB/phpbb/console/application.php b/phpBB/phpbb/console/application.php index fdcd9d42f6..da2bfbb49a 100644 --- a/phpBB/phpbb/console/application.php +++ b/phpBB/phpbb/console/application.php @@ -1,9 +1,13 @@ +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. * */ -- cgit v1.2.1 From 5efd55a34883acad2971117d3a7faf20ecd7e08b Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Wed, 4 Jun 2014 14:26:40 +0200 Subject: [ticket/12655] Run the shell when --shell is used PHPBB3-12655 --- phpBB/phpbb/console/application.php | 38 +++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'phpBB/phpbb/console/application.php') diff --git a/phpBB/phpbb/console/application.php b/phpBB/phpbb/console/application.php index da2bfbb49a..00477ee7d7 100644 --- a/phpBB/phpbb/console/application.php +++ b/phpBB/phpbb/console/application.php @@ -13,10 +13,33 @@ namespace phpbb\console; +use Symfony\Component\Console\Shell; +use Symfony\Component\Console\Input\ArrayInput; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\DependencyInjection\TaggedContainerInterface; class application extends \Symfony\Component\Console\Application { + /** + * @param string $name The name of the application + * @param string $version The version of the application + * @param \phpbb\user $user The user which runs the application (used for translation) + */ + public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN', \phpbb\user $user) + { + parent::__construct($name, $version); + + $this->getDefinition()->addOption(new InputOption('--shell', '-s', InputOption::VALUE_NONE, $user->lang('CLI_DESCRIPTION_OPTION_SHELL'))); + } + + /** + * Register a set of commands from the container + * + * @param TaggedContainerInterface $container The container + * @param string $tag The tag used to register the commands + */ function register_container_commands(TaggedContainerInterface $container, $tag = 'console.command') { foreach($container->findTaggedServiceIds($tag) as $id => $void) @@ -24,4 +47,19 @@ class application extends \Symfony\Component\Console\Application $this->add($container->get($id)); } } + + /** + * {@inheritdoc} + */ + public function doRun(InputInterface $input, OutputInterface $output) + { + if ($input->hasParameterOption(array('--shell', '-s')) === true) { + $shell = new Shell($this); + $shell->run(); + + return 0; + } + + parent::doRun($input, $output); + } } -- cgit v1.2.1 From a14d16172c26fd8f849be4d3afcaac93b6dc4086 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Wed, 4 Jun 2014 15:34:11 +0200 Subject: [ticket/12655] Set the arguments of \phpbb\console\application as required PHPBB3-12655 --- phpBB/phpbb/console/application.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/console/application.php') diff --git a/phpBB/phpbb/console/application.php b/phpBB/phpbb/console/application.php index 00477ee7d7..eb8094e65f 100644 --- a/phpBB/phpbb/console/application.php +++ b/phpBB/phpbb/console/application.php @@ -27,7 +27,7 @@ class application extends \Symfony\Component\Console\Application * @param string $version The version of the application * @param \phpbb\user $user The user which runs the application (used for translation) */ - public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN', \phpbb\user $user) + public function __construct($name, $version, \phpbb\user $user) { parent::__construct($name, $version); -- cgit v1.2.1 From 99ebf4b8ddb53c796247fda7993f8999ceb16816 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Wed, 4 Jun 2014 21:08:11 +0200 Subject: [ticket/12655] Fix coding style in \phpbb\console\application PHPBB3-12655 --- phpBB/phpbb/console/application.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'phpBB/phpbb/console/application.php') diff --git a/phpBB/phpbb/console/application.php b/phpBB/phpbb/console/application.php index eb8094e65f..99fb5fbe97 100644 --- a/phpBB/phpbb/console/application.php +++ b/phpBB/phpbb/console/application.php @@ -31,7 +31,12 @@ class application extends \Symfony\Component\Console\Application { parent::__construct($name, $version); - $this->getDefinition()->addOption(new InputOption('--shell', '-s', InputOption::VALUE_NONE, $user->lang('CLI_DESCRIPTION_OPTION_SHELL'))); + $this->getDefinition()->addOption(new InputOption( + '--shell', + '-s', + InputOption::VALUE_NONE, + $user->lang('CLI_DESCRIPTION_OPTION_SHELL') + )); } /** @@ -53,7 +58,8 @@ class application extends \Symfony\Component\Console\Application */ public function doRun(InputInterface $input, OutputInterface $output) { - if ($input->hasParameterOption(array('--shell', '-s')) === true) { + if ($input->hasParameterOption(array('--shell', '-s')) === true) + { $shell = new Shell($this); $shell->run(); -- cgit v1.2.1 From ce104e2c72a00c58d19691f6af6ee5a3935a5fbd Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Wed, 4 Jun 2014 22:33:05 +0200 Subject: [ticket/12655] Make the --shell option available only for phpbbcli.php PHPBB3-12655 --- phpBB/phpbb/console/application.php | 47 ++++++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb/console/application.php') diff --git a/phpBB/phpbb/console/application.php b/phpBB/phpbb/console/application.php index 99fb5fbe97..9750367df0 100644 --- a/phpBB/phpbb/console/application.php +++ b/phpBB/phpbb/console/application.php @@ -13,6 +13,9 @@ namespace phpbb\console; +use Symfony\Component\Console\Input\ArgvInput; +use Symfony\Component\Console\Output\ConsoleOutput; +use Symfony\Component\Console\Output\ConsoleOutputInterface; use Symfony\Component\Console\Shell; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Input\InputInterface; @@ -22,6 +25,11 @@ use Symfony\Component\DependencyInjection\TaggedContainerInterface; class application extends \Symfony\Component\Console\Application { + /** + * @var bool Indicates whether or not we are in a shell + */ + protected $in_shell = false; + /** * @param string $name The name of the application * @param string $version The version of the application @@ -31,12 +39,42 @@ class application extends \Symfony\Component\Console\Application { parent::__construct($name, $version); + $this->user = $user; + } + + /** + * Gets the help message. + * + * It's a hack of the default help message to display the --shell + * option only for the application and not for all the commands. + * + * @return string A help message. + */ + public function getHelp() + { + // If we are already in a shell + // we do not want to have the --shell option available + if($this->in_shell) + { + return parent::getHelp(); + } + + // We store the definition to restore it later. + // Otherwise, in the shell mode the --shell option + // will be available for all command. + $definition_backup = $this->getDefinition(); + $this->getDefinition()->addOption(new InputOption( '--shell', '-s', InputOption::VALUE_NONE, - $user->lang('CLI_DESCRIPTION_OPTION_SHELL') + $this->user->lang('CLI_DESCRIPTION_OPTION_SHELL') )); + + $help_message = parent::getHelp(); + $this->setDefinition($definition_backup); + + return $help_message; } /** @@ -58,14 +96,17 @@ class application extends \Symfony\Component\Console\Application */ public function doRun(InputInterface $input, OutputInterface $output) { - if ($input->hasParameterOption(array('--shell', '-s')) === true) + // Run a shell if the --shell (or -s) option is set and if any command name is specified + // Also, we do not want to have the --shell option available if we are already in a shell + if (!$this->in_shell && $this->getCommandName($input) === null && $input->hasParameterOption(array('--shell', '-s')) === true) { $shell = new Shell($this); + $this->in_shell = true; $shell->run(); return 0; } - parent::doRun($input, $output); + return parent::doRun($input, $output); } } -- cgit v1.2.1 From 012702307b1503005f1b5b6c20e654dc8d23e8a0 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Thu, 5 Jun 2014 00:21:53 +0200 Subject: [ticket/12655] Fix coding style PHPBB3-12655 --- phpBB/phpbb/console/application.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'phpBB/phpbb/console/application.php') diff --git a/phpBB/phpbb/console/application.php b/phpBB/phpbb/console/application.php index 9750367df0..ff90a76a92 100644 --- a/phpBB/phpbb/console/application.php +++ b/phpBB/phpbb/console/application.php @@ -13,11 +13,7 @@ namespace phpbb\console; -use Symfony\Component\Console\Input\ArgvInput; -use Symfony\Component\Console\Output\ConsoleOutput; -use Symfony\Component\Console\Output\ConsoleOutputInterface; use Symfony\Component\Console\Shell; -use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; @@ -30,6 +26,11 @@ class application extends \Symfony\Component\Console\Application */ protected $in_shell = false; + /** + * @var \phpbb\user User object + */ + protected $user; + /** * @param string $name The name of the application * @param string $version The version of the application @@ -54,7 +55,7 @@ class application extends \Symfony\Component\Console\Application { // If we are already in a shell // we do not want to have the --shell option available - if($this->in_shell) + if ($this->in_shell) { return parent::getHelp(); } @@ -96,9 +97,9 @@ class application extends \Symfony\Component\Console\Application */ public function doRun(InputInterface $input, OutputInterface $output) { - // Run a shell if the --shell (or -s) option is set and if any command name is specified + // Run a shell if the --shell (or -s) option is set and if no command name is specified // Also, we do not want to have the --shell option available if we are already in a shell - if (!$this->in_shell && $this->getCommandName($input) === null && $input->hasParameterOption(array('--shell', '-s')) === true) + if (!$this->in_shell && $this->getCommandName($input) === null && $input->hasParameterOption(array('--shell', '-s'))) { $shell = new Shell($this); $this->in_shell = true; -- cgit v1.2.1 From 5e9c8a0ceaabb84a679bd56e7165a9e29fc3da71 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Thu, 5 Jun 2014 01:00:33 +0200 Subject: [ticket/12655] Don't try to restore the definition in the help PHPBB3-12655 --- phpBB/phpbb/console/application.php | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'phpBB/phpbb/console/application.php') diff --git a/phpBB/phpbb/console/application.php b/phpBB/phpbb/console/application.php index ff90a76a92..91d95b9a7b 100644 --- a/phpBB/phpbb/console/application.php +++ b/phpBB/phpbb/console/application.php @@ -13,6 +13,9 @@ namespace phpbb\console; +use Symfony\Component\Console\Input\ArgvInput; +use Symfony\Component\Console\Output\ConsoleOutput; +use Symfony\Component\Console\Output\ConsoleOutputInterface; use Symfony\Component\Console\Shell; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -60,11 +63,6 @@ class application extends \Symfony\Component\Console\Application return parent::getHelp(); } - // We store the definition to restore it later. - // Otherwise, in the shell mode the --shell option - // will be available for all command. - $definition_backup = $this->getDefinition(); - $this->getDefinition()->addOption(new InputOption( '--shell', '-s', @@ -72,10 +70,7 @@ class application extends \Symfony\Component\Console\Application $this->user->lang('CLI_DESCRIPTION_OPTION_SHELL') )); - $help_message = parent::getHelp(); - $this->setDefinition($definition_backup); - - return $help_message; + return parent::getHelp(); } /** -- cgit v1.2.1 From 5b51acf245fc1fbd454d394e8b44bf73d6439248 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Thu, 5 Jun 2014 01:03:16 +0200 Subject: [ticket/12655] Set register_container_commands as public PHPBB3-12655 --- phpBB/phpbb/console/application.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'phpBB/phpbb/console/application.php') diff --git a/phpBB/phpbb/console/application.php b/phpBB/phpbb/console/application.php index 91d95b9a7b..b1f0635913 100644 --- a/phpBB/phpbb/console/application.php +++ b/phpBB/phpbb/console/application.php @@ -13,9 +13,6 @@ namespace phpbb\console; -use Symfony\Component\Console\Input\ArgvInput; -use Symfony\Component\Console\Output\ConsoleOutput; -use Symfony\Component\Console\Output\ConsoleOutputInterface; use Symfony\Component\Console\Shell; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -79,7 +76,7 @@ class application extends \Symfony\Component\Console\Application * @param TaggedContainerInterface $container The container * @param string $tag The tag used to register the commands */ - function register_container_commands(TaggedContainerInterface $container, $tag = 'console.command') + public function register_container_commands(TaggedContainerInterface $container, $tag = 'console.command') { foreach($container->findTaggedServiceIds($tag) as $id => $void) { -- cgit v1.2.1 From b95ab440280ca5e5e94fe1f96f4f947734e37da3 Mon Sep 17 00:00:00 2001 From: Carlo Date: Sat, 12 Jul 2014 17:19:43 +0200 Subject: [ticket/12685] Add console collection and fixing CLI Added a commands service collection and removed CLI container PHPBB3-12685 --- phpBB/phpbb/console/application.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'phpBB/phpbb/console/application.php') diff --git a/phpBB/phpbb/console/application.php b/phpBB/phpbb/console/application.php index b1f0635913..72fcee5cfa 100644 --- a/phpBB/phpbb/console/application.php +++ b/phpBB/phpbb/console/application.php @@ -17,7 +17,7 @@ use Symfony\Component\Console\Shell; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\DependencyInjection\TaggedContainerInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; class application extends \Symfony\Component\Console\Application { @@ -73,14 +73,13 @@ class application extends \Symfony\Component\Console\Application /** * Register a set of commands from the container * - * @param TaggedContainerInterface $container The container - * @param string $tag The tag used to register the commands + * @param ContainerInterface $container The container */ - public function register_container_commands(TaggedContainerInterface $container, $tag = 'console.command') + public function register_container_commands(ContainerInterface $container) { - foreach($container->findTaggedServiceIds($tag) as $id => $void) + foreach($container->get('console.command_collection') as $service_command) { - $this->add($container->get($id)); + $this->add($service_command); } } -- cgit v1.2.1 From 1125fb3cabf7a69dc4cac852efd655ce2afcd7a0 Mon Sep 17 00:00:00 2001 From: Carlo Date: Fri, 20 Jun 2014 09:58:51 +0000 Subject: [ticket/12685] Add space after foreach PHPBB3-12685 --- phpBB/phpbb/console/application.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/console/application.php') diff --git a/phpBB/phpbb/console/application.php b/phpBB/phpbb/console/application.php index 72fcee5cfa..2aef48c93b 100644 --- a/phpBB/phpbb/console/application.php +++ b/phpBB/phpbb/console/application.php @@ -77,7 +77,7 @@ class application extends \Symfony\Component\Console\Application */ public function register_container_commands(ContainerInterface $container) { - foreach($container->get('console.command_collection') as $service_command) + foreach ($container->get('console.command_collection') as $service_command) { $this->add($service_command); } -- cgit v1.2.1 From 2ec50c0ff15837489f36b014a2e36470b1672508 Mon Sep 17 00:00:00 2001 From: Carlo Date: Tue, 15 Jul 2014 00:38:07 +0200 Subject: [ticket/12685] Add --safe-mode PHPBB3-12685 --- phpBB/phpbb/console/application.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'phpBB/phpbb/console/application.php') diff --git a/phpBB/phpbb/console/application.php b/phpBB/phpbb/console/application.php index 2aef48c93b..eac8dbea2d 100644 --- a/phpBB/phpbb/console/application.php +++ b/phpBB/phpbb/console/application.php @@ -67,6 +67,13 @@ class application extends \Symfony\Component\Console\Application $this->user->lang('CLI_DESCRIPTION_OPTION_SHELL') )); + $this->getDefinition()->addOption(new InputOption( + '--safe-mode', + null, + InputOption::VALUE_NONE, + $this->user->lang('CLI_DESCRIPTION_OPTION_SAFE_MODE') + )); + return parent::getHelp(); } -- cgit v1.2.1 From 0f41a8fc31ba6af38fc90f47b742ffe35815fd3b Mon Sep 17 00:00:00 2001 From: Carlo Date: Tue, 15 Jul 2014 10:21:23 +0200 Subject: [ticket/12685] Removed spaces PHPBB3-12685 --- phpBB/phpbb/console/application.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/phpbb/console/application.php') diff --git a/phpBB/phpbb/console/application.php b/phpBB/phpbb/console/application.php index eac8dbea2d..5cda90208a 100644 --- a/phpBB/phpbb/console/application.php +++ b/phpBB/phpbb/console/application.php @@ -72,7 +72,7 @@ class application extends \Symfony\Component\Console\Application null, InputOption::VALUE_NONE, $this->user->lang('CLI_DESCRIPTION_OPTION_SAFE_MODE') - )); + )); return parent::getHelp(); } -- cgit v1.2.1 From 15136e4f8e36ca972f6b1b0bb7a4867967698335 Mon Sep 17 00:00:00 2001 From: Carlo Date: Tue, 15 Jul 2014 11:36:51 +0200 Subject: [ticket/12685] Inject console.command_collection instead of the container PHPBB3-12685 --- phpBB/phpbb/console/application.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/phpbb/console/application.php') diff --git a/phpBB/phpbb/console/application.php b/phpBB/phpbb/console/application.php index 5cda90208a..5202a1fbaf 100644 --- a/phpBB/phpbb/console/application.php +++ b/phpBB/phpbb/console/application.php @@ -80,11 +80,11 @@ class application extends \Symfony\Component\Console\Application /** * Register a set of commands from the container * - * @param ContainerInterface $container The container + * @param \phpbb\di\service_collection $command_collection The console service collection */ - public function register_container_commands(ContainerInterface $container) + public function register_container_commands(\phpbb\di\service_collection $command_collection) { - foreach ($container->get('console.command_collection') as $service_command) + foreach ($command_collection as $service_command) { $this->add($service_command); } -- cgit v1.2.1 From 3eafeeb88d173bc4f2b082ee5f09f85bef931ec9 Mon Sep 17 00:00:00 2001 From: Carlo Date: Tue, 15 Jul 2014 13:31:34 +0200 Subject: [ticket/12685] Removed unused USE statement PHPBB3-12685 --- phpBB/phpbb/console/application.php | 1 - 1 file changed, 1 deletion(-) (limited to 'phpBB/phpbb/console/application.php') diff --git a/phpBB/phpbb/console/application.php b/phpBB/phpbb/console/application.php index 5202a1fbaf..b08346b8fa 100644 --- a/phpBB/phpbb/console/application.php +++ b/phpBB/phpbb/console/application.php @@ -17,7 +17,6 @@ use Symfony\Component\Console\Shell; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; class application extends \Symfony\Component\Console\Application { -- cgit v1.2.1 From 7cffedf5e310e0cde9bfd541ca835a4fedf26ef3 Mon Sep 17 00:00:00 2001 From: Carlo Date: Tue, 15 Jul 2014 16:07:52 +0200 Subject: [ticket/12685] Override getDefaultInputDefinition() PHPBB3-12685 --- phpBB/phpbb/console/application.php | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'phpBB/phpbb/console/application.php') diff --git a/phpBB/phpbb/console/application.php b/phpBB/phpbb/console/application.php index b08346b8fa..bc4897af18 100644 --- a/phpBB/phpbb/console/application.php +++ b/phpBB/phpbb/console/application.php @@ -37,9 +37,26 @@ class application extends \Symfony\Component\Console\Application */ public function __construct($name, $version, \phpbb\user $user) { + $this->user = $user; + parent::__construct($name, $version); + } - $this->user = $user; + /** + * {@inheritdoc} + */ + protected function getDefaultInputDefinition() + { + $input_definition = parent::getDefaultInputDefinition(); + + $input_definition->addOption(new InputOption( + 'safe-mode', + null, + InputOption::VALUE_NONE, + $this->user->lang('CLI_DESCRIPTION_OPTION_SAFE_MODE') + )); + + return $input_definition; } /** @@ -66,13 +83,6 @@ class application extends \Symfony\Component\Console\Application $this->user->lang('CLI_DESCRIPTION_OPTION_SHELL') )); - $this->getDefinition()->addOption(new InputOption( - '--safe-mode', - null, - InputOption::VALUE_NONE, - $this->user->lang('CLI_DESCRIPTION_OPTION_SAFE_MODE') - )); - return parent::getHelp(); } -- cgit v1.2.1