Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
27 / 27 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
set | |
100.00% |
27 / 27 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
configure | |
100.00% |
20 / 20 |
|
100.00% |
1 / 1 |
1 | |||
execute | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
1 |
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\Input\InputOption; |
19 | use Symfony\Component\Console\Output\OutputInterface; |
20 | use Symfony\Component\Console\Style\SymfonyStyle; |
21 | |
22 | class set extends command |
23 | { |
24 | /** |
25 | * {@inheritdoc} |
26 | */ |
27 | protected function configure() |
28 | { |
29 | $this |
30 | ->setName('config:set') |
31 | ->setDescription($this->user->lang('CLI_DESCRIPTION_SET_CONFIG')) |
32 | ->addArgument( |
33 | 'key', |
34 | InputArgument::REQUIRED, |
35 | $this->user->lang('CLI_CONFIG_OPTION_NAME') |
36 | ) |
37 | ->addArgument( |
38 | 'value', |
39 | InputArgument::REQUIRED, |
40 | $this->user->lang('CLI_CONFIG_NEW') |
41 | ) |
42 | ->addOption( |
43 | 'dynamic', |
44 | 'd', |
45 | InputOption::VALUE_NONE, |
46 | $this->user->lang('CLI_CONFIG_CANNOT_CACHED') |
47 | ) |
48 | ; |
49 | } |
50 | |
51 | /** |
52 | * Executes the command config:set. |
53 | * |
54 | * Sets a configuration option's value. |
55 | * |
56 | * @param InputInterface $input An InputInterface instance |
57 | * @param OutputInterface $output An OutputInterface instance |
58 | * |
59 | * @return int |
60 | * @see \phpbb\config\config::set() |
61 | */ |
62 | protected function execute(InputInterface $input, OutputInterface $output) |
63 | { |
64 | $io = new SymfonyStyle($input, $output); |
65 | |
66 | $key = $input->getArgument('key'); |
67 | $value = $input->getArgument('value'); |
68 | $use_cache = !$input->getOption('dynamic'); |
69 | |
70 | $this->config->set($key, $value, $use_cache); |
71 | |
72 | $io->success($this->user->lang('CLI_CONFIG_SET_SUCCESS', $key)); |
73 | |
74 | return symfony_command::SUCCESS; |
75 | } |
76 | } |