@@ 24-61 (lines=38) @@ | ||
21 | /** |
|
22 | * Plugin install command class. |
|
23 | */ |
|
24 | class PluginInstallCommand extends BaseCommand |
|
25 | { |
|
26 | /** |
|
27 | * Configure the console command. |
|
28 | * |
|
29 | * @return void |
|
30 | */ |
|
31 | protected function configure() |
|
32 | { |
|
33 | $this |
|
34 | ->setName('plugin:install') |
|
35 | ->setDescription('Install a plugin from a remote Zip archive') |
|
36 | ->addArgument('url', InputArgument::REQUIRED, 'Archive URL'); |
|
37 | } |
|
38 | ||
39 | /** |
|
40 | * Execute the console command. |
|
41 | * |
|
42 | * @param InputInterface $output |
|
43 | * @param OutputInterface $output |
|
44 | * |
|
45 | * @return void |
|
46 | */ |
|
47 | protected function execute(InputInterface $input, OutputInterface $output) |
|
48 | { |
|
49 | if (!Installer::isConfigured()) { |
|
50 | throw new LogicException('Jitamin is not configured to install plugins itself'); |
|
51 | } |
|
52 | ||
53 | try { |
|
54 | $installer = new Installer($this->container); |
|
55 | $installer->install($input->getArgument('url')); |
|
56 | $output->writeln('<info>Plugin installed successfully</info>'); |
|
57 | } catch (PluginInstallerException $e) { |
|
58 | $output->writeln('<error>'.$e->getMessage().'</error>'); |
|
59 | } |
|
60 | } |
|
61 | } |
|
62 |
@@ 24-61 (lines=38) @@ | ||
21 | /** |
|
22 | * Plugin uninstall command class. |
|
23 | */ |
|
24 | class PluginUninstallCommand extends BaseCommand |
|
25 | { |
|
26 | /** |
|
27 | * Configure the console command. |
|
28 | * |
|
29 | * @return void |
|
30 | */ |
|
31 | protected function configure() |
|
32 | { |
|
33 | $this |
|
34 | ->setName('plugin:uninstall') |
|
35 | ->setDescription('Remove a plugin') |
|
36 | ->addArgument('pluginId', InputArgument::REQUIRED, 'Plugin directory name'); |
|
37 | } |
|
38 | ||
39 | /** |
|
40 | * Execute the console command. |
|
41 | * |
|
42 | * @param InputInterface $output |
|
43 | * @param OutputInterface $output |
|
44 | * |
|
45 | * @return void |
|
46 | */ |
|
47 | protected function execute(InputInterface $input, OutputInterface $output) |
|
48 | { |
|
49 | if (!Installer::isConfigured()) { |
|
50 | throw new LogicException('Jitamin is not configured to install plugins itself'); |
|
51 | } |
|
52 | ||
53 | try { |
|
54 | $installer = new Installer($this->container); |
|
55 | $installer->uninstall($input->getArgument('pluginId')); |
|
56 | $output->writeln('<info>Plugin removed successfully</info>'); |
|
57 | } catch (PluginInstallerException $e) { |
|
58 | $output->writeln('<error>'.$e->getMessage().'</error>'); |
|
59 | } |
|
60 | } |
|
61 | } |
|
62 |