Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 24 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
| application | |
0.00% |
0 / 24 |
|
0.00% |
0 / 4 |
72 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| getDefaultInputDefinition | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| register_container_commands | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
20 | |||
| register_global_options | |
0.00% |
0 / 13 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * |
| 4 | * This file is part of the phpBB Forum Software package. |
| 5 | * |
| 6 | * @copyright (c) phpBB Limited <https://www.phpbb.com> |
| 7 | * @license GNU General Public License, version 2 (GPL-2.0) |
| 8 | * |
| 9 | * For full copyright and license information, please see |
| 10 | * the docs/CREDITS.txt file. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | namespace phpbb\console; |
| 15 | |
| 16 | use Symfony\Component\Console\Input\InputDefinition; |
| 17 | use Symfony\Component\Console\Input\InputOption; |
| 18 | |
| 19 | class application extends \Symfony\Component\Console\Application |
| 20 | { |
| 21 | /** |
| 22 | * @var \phpbb\config\config Config object |
| 23 | */ |
| 24 | protected $config; |
| 25 | |
| 26 | /** |
| 27 | * @var \phpbb\language\language Language object |
| 28 | */ |
| 29 | protected $language; |
| 30 | |
| 31 | /** |
| 32 | * @param string $name The name of the application |
| 33 | * @param string $version The version of the application |
| 34 | * @param \phpbb\language\language $language The user which runs the application (used for translation) |
| 35 | * @param \phpbb\config\config $config Config object |
| 36 | */ |
| 37 | public function __construct($name, $version, \phpbb\language\language $language, \phpbb\config\config $config) |
| 38 | { |
| 39 | $this->language = $language; |
| 40 | $this->config = $config; |
| 41 | |
| 42 | parent::__construct($name, $version); |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * {@inheritdoc} |
| 47 | */ |
| 48 | protected function getDefaultInputDefinition(): InputDefinition |
| 49 | { |
| 50 | $input_definition = parent::getDefaultInputDefinition(); |
| 51 | |
| 52 | $this->register_global_options($input_definition); |
| 53 | |
| 54 | return $input_definition; |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Register a set of commands from the container |
| 59 | * |
| 60 | * @param \phpbb\di\service_collection $command_collection The console service collection |
| 61 | */ |
| 62 | public function register_container_commands(\phpbb\di\service_collection $command_collection) |
| 63 | { |
| 64 | $commands_list = array_keys($command_collection->getArrayCopy()); |
| 65 | foreach ($commands_list as $service_command) |
| 66 | { |
| 67 | // config_text DB table does not exist in phpBB prior to 3.1 |
| 68 | // Hence skip cron tasks as they include reparser cron as it uses config_text table |
| 69 | if (phpbb_version_compare($this->config['version'], '3.1.0', '<') && strpos($service_command, 'cron') !== false) |
| 70 | { |
| 71 | continue; |
| 72 | } |
| 73 | $this->add($command_collection[$service_command]); |
| 74 | |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * Register global options |
| 80 | * |
| 81 | * @param InputDefinition $definition An InputDefinition instance |
| 82 | */ |
| 83 | protected function register_global_options(InputDefinition $definition) |
| 84 | { |
| 85 | try |
| 86 | { |
| 87 | $definition->addOption(new InputOption( |
| 88 | 'safe-mode', |
| 89 | null, |
| 90 | InputOption::VALUE_NONE, |
| 91 | $this->language->lang('CLI_DESCRIPTION_OPTION_SAFE_MODE') |
| 92 | )); |
| 93 | |
| 94 | $definition->addOption(new InputOption( |
| 95 | 'env', |
| 96 | 'e', |
| 97 | InputOption::VALUE_REQUIRED, |
| 98 | $this->language->lang('CLI_DESCRIPTION_OPTION_ENV') |
| 99 | )); |
| 100 | } |
| 101 | catch (\LogicException $e) |
| 102 | { |
| 103 | // Do nothing |
| 104 | } |
| 105 | } |
| 106 | } |