1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
namespace phpbb\console\command\extension;
use phpbb\composer\extension_manager;
use phpbb\composer\io\console_io;
use phpbb\language\language;
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
class remove extends \phpbb\console\command\command
{
/**
* @var extension_manager Composer extensions manager
*/
protected $manager;
/**
* @var \phpbb\language\language
*/
protected $language;
public function __construct(\phpbb\user $user, extension_manager $manager, language $language)
{
$this->manager = $manager;
$this->language = $language;
$language->add_lang('acp/extensions');
parent::__construct($user);
}
/**
* Sets the command name and description
*
* @return null
*/
protected function configure()
{
$this
->setName('extension:remove')
->setDescription($this->language->lang('CLI_DESCRIPTION_EXTENSION_REMOVE'))
->addOption(
'purge',
null,
InputOption::VALUE_NONE,
$this->language->lang('CLI_DESCRIPTION_EXTENSION_REMOVE_OPTION_PURGE'))
->addArgument(
'extensions',
InputArgument::IS_ARRAY | InputArgument::REQUIRED,
$this->language->lang('CLI_DESCRIPTION_EXTENSION_REMOVE_ARGUMENT'))
;
}
/**
* Executes the command extension:install
*
* @param InputInterface $input
* @param OutputInterface $output
* @return integer
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$output->getFormatter()->setStyle('warning', new OutputFormatterStyle('black', 'yellow'));
$io = new SymfonyStyle($input, $output);
if (!$this->manager->check_requirements())
{
$io->error($this->language->lang('EXTENSIONS_COMPOSER_NOT_WRITABLE'));
return 1;
}
$composer_io = new console_io($input, $output, $this->getHelperSet(), $this->language);
$extensions = $input->getArgument('extensions');
if ($input->getOption('purge'))
{
$this->manager->set_purge_on_remove(true);
}
$this->manager->remove($extensions, $composer_io);
$io->success($this->language->lang('EXTENSIONS_REMOVED'));
return 0;
}
}
|