blob: 1277f4f15d0fd73aefbe037f67fcb411f7f0254c (
plain)
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
|
<?php
namespace Studip\Cli\Commands\Plugins;
use Studip\Cli\Commands\AbstractPluginCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class PluginInstall extends AbstractPluginCommand
{
protected static $defaultName = 'plugin:install';
protected function configure(): void
{
$this->setDescription('Install a plugin.');
$this->setHelp('This command installs a plugin from a ZIP file.');
$this->addArgument('zipfile', InputArgument::REQUIRED, 'path to the ZIP file');
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$zipfile = $input->getArgument('zipfile');
try {
$plugin_admin = new \PluginAdministration();
if (parse_url($zipfile, \PHP_URL_SCHEME)) {
$plugin_admin->installPluginFromURL($zipfile);
} else {
$plugin_admin->installPlugin($zipfile);
}
$output->writeln('The plugin was installed successfully.');
} catch (\PluginInstallationException $ex) {
$output->writeln('<error>' . $ex->getMessage() . '</error>');
return Command::FAILURE;
}
return Command::SUCCESS;
}
}
|