aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb
diff options
context:
space:
mode:
authorTristan Darricau <github@nicofuma.fr>2014-06-04 22:33:05 +0200
committerTristan Darricau <github@nicofuma.fr>2014-06-04 22:33:05 +0200
commitce104e2c72a00c58d19691f6af6ee5a3935a5fbd (patch)
tree647bc46a2fda8d50eface7bd9a936afa1e3d3e6a /phpBB/phpbb
parent99ebf4b8ddb53c796247fda7993f8999ceb16816 (diff)
downloadforums-ce104e2c72a00c58d19691f6af6ee5a3935a5fbd.tar
forums-ce104e2c72a00c58d19691f6af6ee5a3935a5fbd.tar.gz
forums-ce104e2c72a00c58d19691f6af6ee5a3935a5fbd.tar.bz2
forums-ce104e2c72a00c58d19691f6af6ee5a3935a5fbd.tar.xz
forums-ce104e2c72a00c58d19691f6af6ee5a3935a5fbd.zip
[ticket/12655] Make the --shell option available only for phpbbcli.php
PHPBB3-12655
Diffstat (limited to 'phpBB/phpbb')
-rw-r--r--phpBB/phpbb/console/application.php47
1 files changed, 44 insertions, 3 deletions
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;
@@ -23,6 +26,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
* @param \phpbb\user $user The user which runs the application (used for translation)
@@ -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);
}
}