Verzeichnisstruktur phpBB-3.1.0
- Veröffentlicht
- 27.10.2014
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
application.php
001 <?php
002 /**
003 *
004 * This file is part of the phpBB Forum Software package.
005 *
006 * @copyright (c) phpBB Limited <https://www.phpbb.com>
007 * @license GNU General Public License, version 2 (GPL-2.0)
008 *
009 * For full copyright and license information, please see
010 * the docs/CREDITS.txt file.
011 *
012 */
013
014 namespace phpbb\console;
015
016 use Symfony\Component\Console\Shell;
017 use Symfony\Component\Console\Input\InputInterface;
018 use Symfony\Component\Console\Input\InputOption;
019 use Symfony\Component\Console\Output\OutputInterface;
020
021 class application extends \Symfony\Component\Console\Application
022 {
023 /**
024 * @var bool Indicates whether or not we are in a shell
025 */
026 protected $in_shell = false;
027
028 /**
029 * @var \phpbb\user User object
030 */
031 protected $user;
032
033 /**
034 * @param string $name The name of the application
035 * @param string $version The version of the application
036 * @param \phpbb\user $user The user which runs the application (used for translation)
037 */
038 public function __construct($name, $version, \phpbb\user $user)
039 {
040 $this->user = $user;
041
042 parent::__construct($name, $version);
043 }
044
045 /**
046 * {@inheritdoc}
047 */
048 protected function getDefaultInputDefinition()
049 {
050 $input_definition = parent::getDefaultInputDefinition();
051
052 $input_definition->addOption(new InputOption(
053 'safe-mode',
054 null,
055 InputOption::VALUE_NONE,
056 $this->user->lang('CLI_DESCRIPTION_OPTION_SAFE_MODE')
057 ));
058
059 return $input_definition;
060 }
061
062 /**
063 * Gets the help message.
064 *
065 * It's a hack of the default help message to display the --shell
066 * option only for the application and not for all the commands.
067 *
068 * @return string A help message.
069 */
070 public function getHelp()
071 {
072 // If we are already in a shell
073 // we do not want to have the --shell option available
074 if ($this->in_shell)
075 {
076 return parent::getHelp();
077 }
078
079 $this->getDefinition()->addOption(new InputOption(
080 '--shell',
081 '-s',
082 InputOption::VALUE_NONE,
083 $this->user->lang('CLI_DESCRIPTION_OPTION_SHELL')
084 ));
085
086 return parent::getHelp();
087 }
088
089 /**
090 * Register a set of commands from the container
091 *
092 * @param \phpbb\di\service_collection $command_collection The console service collection
093 */
094 public function register_container_commands(\phpbb\di\service_collection $command_collection)
095 {
096 foreach ($command_collection as $service_command)
097 {
098 $this->add($service_command);
099 }
100 }
101
102 /**
103 * {@inheritdoc}
104 */
105 public function doRun(InputInterface $input, OutputInterface $output)
106 {
107 // Run a shell if the --shell (or -s) option is set and if no command name is specified
108 // Also, we do not want to have the --shell option available if we are already in a shell
109 if (!$this->in_shell && $this->getCommandName($input) === null && $input->hasParameterOption(array('--shell', '-s')))
110 {
111 $shell = new Shell($this);
112 $this->in_shell = true;
113 $shell->run();
114
115 return 0;
116 }
117
118 return parent::doRun($input, $output);
119 }
120 }
121