Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
17 / 17 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
delete | |
100.00% |
17 / 17 |
|
100.00% |
2 / 2 |
3 | |
100.00% |
1 / 1 |
configure | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
1 | |||
execute | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
2 |
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 | namespace phpbb\console\command\config; |
14 | |
15 | use Symfony\Component\Console\Command\Command as symfony_command; |
16 | use Symfony\Component\Console\Input\InputArgument; |
17 | use Symfony\Component\Console\Input\InputInterface; |
18 | use Symfony\Component\Console\Output\OutputInterface; |
19 | use Symfony\Component\Console\Style\SymfonyStyle; |
20 | |
21 | class delete extends command |
22 | { |
23 | /** |
24 | * {@inheritdoc} |
25 | */ |
26 | protected function configure() |
27 | { |
28 | $this |
29 | ->setName('config:delete') |
30 | ->setDescription($this->user->lang('CLI_DESCRIPTION_DELETE_CONFIG')) |
31 | ->addArgument( |
32 | 'key', |
33 | InputArgument::REQUIRED, |
34 | $this->user->lang('CLI_CONFIG_OPTION_NAME') |
35 | ) |
36 | ; |
37 | } |
38 | |
39 | /** |
40 | * Executes the command config:delete. |
41 | * |
42 | * Removes a configuration option |
43 | * |
44 | * @param InputInterface $input An InputInterface instance |
45 | * @param OutputInterface $output An OutputInterface instance |
46 | * |
47 | * @return int |
48 | * @see \phpbb\config\config::delete() |
49 | */ |
50 | protected function execute(InputInterface $input, OutputInterface $output) |
51 | { |
52 | $io = new SymfonyStyle($input, $output); |
53 | |
54 | $key = $input->getArgument('key'); |
55 | |
56 | if (isset($this->config[$key])) |
57 | { |
58 | $this->config->delete($key); |
59 | |
60 | $io->success($this->user->lang('CLI_CONFIG_DELETE_SUCCESS', $key)); |
61 | |
62 | return symfony_command::SUCCESS; |
63 | } |
64 | else |
65 | { |
66 | $io->error($this->user->lang('CLI_CONFIG_NOT_EXISTS', $key)); |
67 | return symfony_command::FAILURE; |
68 | } |
69 | } |
70 | } |