Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 29 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
remove | |
0.00% |
0 / 29 |
|
0.00% |
0 / 3 |
30 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
configure | |
0.00% |
0 / 13 |
|
0.00% |
0 / 1 |
2 | |||
execute | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
12 |
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\command\extension; |
15 | |
16 | use phpbb\composer\extension_manager; |
17 | use phpbb\composer\io\console_io; |
18 | use phpbb\language\language; |
19 | use Symfony\Component\Console\Command\Command as symfony_command; |
20 | use Symfony\Component\Console\Formatter\OutputFormatterStyle; |
21 | use Symfony\Component\Console\Input\InputArgument; |
22 | use Symfony\Component\Console\Input\InputInterface; |
23 | use Symfony\Component\Console\Input\InputOption; |
24 | use Symfony\Component\Console\Output\OutputInterface; |
25 | use Symfony\Component\Console\Style\SymfonyStyle; |
26 | |
27 | class remove extends \phpbb\console\command\command |
28 | { |
29 | /** |
30 | * @var extension_manager Composer extensions manager |
31 | */ |
32 | protected $manager; |
33 | |
34 | /** |
35 | * @var language |
36 | */ |
37 | protected $language; |
38 | |
39 | public function __construct(\phpbb\user $user, extension_manager $manager, language $language) |
40 | { |
41 | $this->manager = $manager; |
42 | $this->language = $language; |
43 | |
44 | $language->add_lang('acp/extensions'); |
45 | |
46 | parent::__construct($user); |
47 | } |
48 | |
49 | /** |
50 | * Sets the command name and description |
51 | * |
52 | * @return void |
53 | */ |
54 | protected function configure() |
55 | { |
56 | $this |
57 | ->setName('extension:remove') |
58 | ->setDescription($this->language->lang('CLI_DESCRIPTION_EXTENSION_REMOVE')) |
59 | ->addOption( |
60 | 'purge', |
61 | null, |
62 | InputOption::VALUE_NONE, |
63 | $this->language->lang('CLI_DESCRIPTION_EXTENSION_REMOVE_OPTION_PURGE')) |
64 | ->addArgument( |
65 | 'extensions', |
66 | InputArgument::IS_ARRAY | InputArgument::REQUIRED, |
67 | $this->language->lang('CLI_DESCRIPTION_EXTENSION_REMOVE_ARGUMENT')) |
68 | ; |
69 | } |
70 | |
71 | /** |
72 | * Executes the command extension:install |
73 | * |
74 | * @param InputInterface $input |
75 | * @param OutputInterface $output |
76 | * @return integer |
77 | */ |
78 | protected function execute(InputInterface $input, OutputInterface $output) |
79 | { |
80 | $output->getFormatter()->setStyle('warning', new OutputFormatterStyle('black', 'yellow')); |
81 | |
82 | $io = new SymfonyStyle($input, $output); |
83 | |
84 | if (!$this->manager->check_requirements()) |
85 | { |
86 | $io->error($this->language->lang('EXTENSIONS_COMPOSER_NOT_WRITABLE')); |
87 | return symfony_command::FAILURE; |
88 | } |
89 | |
90 | $composer_io = new console_io($input, $output, $this->getHelperSet(), $this->language); |
91 | $extensions = $input->getArgument('extensions'); |
92 | |
93 | if ($input->getOption('purge')) |
94 | { |
95 | $this->manager->set_purge_on_remove(true); |
96 | } |
97 | |
98 | $this->manager->remove($extensions, $composer_io); |
99 | |
100 | $io->success($this->language->lang('EXTENSIONS_REMOVED')); |
101 | |
102 | return symfony_command::SUCCESS; |
103 | } |
104 | } |