Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

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.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

application.php

Zuletzt modifiziert: 09.10.2024, 12:52 - Dateigröße: 3.49 KiB


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\Input\InputDefinition;
017  use Symfony\Component\Console\Shell;
018  use Symfony\Component\Console\Input\InputInterface;
019  use Symfony\Component\Console\Input\InputOption;
020  use Symfony\Component\Console\Output\OutputInterface;
021   
022  class application extends \Symfony\Component\Console\Application
023  {
024      /**
025      * @var bool Indicates whether or not we are in a shell
026      */
027      protected $in_shell = false;
028   
029      /**
030      * @var \phpbb\language\language User object
031      */
032      protected $language;
033   
034      /**
035      * @param string                        $name        The name of the application
036      * @param string                        $version    The version of the application
037      * @param \phpbb\language\language    $language    The user which runs the application (used for translation)
038      */
039      public function __construct($name, $version, \phpbb\language\language $language)
040      {
041          $this->language = $language;
042   
043          parent::__construct($name, $version);
044      }
045   
046      /**
047      * {@inheritdoc}
048      */
049      protected function getDefaultInputDefinition()
050      {
051          $input_definition = parent::getDefaultInputDefinition();
052   
053          $this->register_global_options($input_definition);
054   
055          return $input_definition;
056      }
057   
058      /**
059      * Gets the help message.
060      *
061      * It's a hack of the default help message to display the --shell
062      * option only for the application and not for all the commands.
063      *
064      * @return string A help message.
065      */
066      public function getHelp()
067      {
068          // If we are already in a shell
069          // we do not want to have the --shell option available
070          if ($this->in_shell)
071          {
072              return parent::getHelp();
073          }
074   
075          try
076          {
077              $definition = $this->getDefinition();
078              $definition->addOption(new InputOption(
079                  '--shell',
080                  '-s',
081                  InputOption::VALUE_NONE,
082                  $this->language->lang('CLI_DESCRIPTION_OPTION_SHELL')
083              ));
084          }
085          catch (\LogicException $e)
086          {
087              // Do nothing
088          }
089   
090          return parent::getHelp();
091      }
092   
093      /**
094      * Register a set of commands from the container
095      *
096      * @param \phpbb\di\service_collection    $command_collection    The console service collection
097      */
098      public function register_container_commands(\phpbb\di\service_collection $command_collection)
099      {
100          foreach ($command_collection as $service_command)
101          {
102              $this->add($service_command);
103          }
104      }
105   
106      /**
107      * {@inheritdoc}
108      */
109      public function doRun(InputInterface $input, OutputInterface $output)
110      {
111          // Run a shell if the --shell (or -s) option is set and if no command name is specified
112          // Also, we do not want to have the --shell option available if we are already in a shell
113          if (!$this->in_shell && $this->getCommandName($input) === null && $input->hasParameterOption(array('--shell', '-s')))
114          {
115              $shell = new Shell($this);
116              $this->in_shell = true;
117              $shell->run();
118   
119              return 0;
120          }
121   
122          return parent::doRun($input, $output);
123      }
124   
125      /**
126       * Register global options
127       *
128       * @param InputDefinition $definition An InputDefinition instance
129       */
130      protected function register_global_options(InputDefinition $definition)
131      {
132          try
133          {
134              $definition->addOption(new InputOption(
135                  'safe-mode',
136                  null,
137                  InputOption::VALUE_NONE,
138                  $this->language->lang('CLI_DESCRIPTION_OPTION_SAFE_MODE')
139              ));
140   
141              $definition->addOption(new InputOption(
142                  'env',
143                  'e',
144                  InputOption::VALUE_REQUIRED,
145                  $this->language->lang('CLI_DESCRIPTION_OPTION_ENV')
146              ));
147          }
148          catch (\LogicException $e)
149          {
150              // Do nothing
151          }
152      }
153  }
154