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