Skip to content

Commit 4fc6692

Browse files
authored
app-plugin:uninstall
1 parent 403034c commit 4fc6692

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
namespace Webman\Console\Commands;
4+
5+
use Symfony\Component\Console\Command\Command;
6+
use Symfony\Component\Console\Input\InputArgument;
7+
use Symfony\Component\Console\Input\InputInterface;
8+
use Symfony\Component\Console\Output\OutputInterface;
9+
use Symfony\Component\Console\Input\InputOption;
10+
use Webman\Console\Util;
11+
12+
class AppPluginUninstallCommand extends Command
13+
{
14+
protected static $defaultName = 'app-plugin:uninstall';
15+
protected static $defaultDescription = 'App Plugin Uninstall';
16+
17+
/**
18+
* @return void
19+
*/
20+
protected function configure()
21+
{
22+
$this->addArgument('name', InputArgument::REQUIRED, 'App plugin name');
23+
}
24+
25+
/**
26+
* @param InputInterface $input
27+
* @param OutputInterface $output
28+
* @return int
29+
*/
30+
protected function execute(InputInterface $input, OutputInterface $output): int
31+
{
32+
$name = $input->getArgument('name');
33+
$output->writeln("Uninstall App Plugin $name");
34+
$class = "\\plugin\\$name\\api\\Install";
35+
if (!method_exists($class, 'uninstall')) {
36+
throw new \RuntimeException("Method $class::uninstall not exists");
37+
}
38+
call_user_func([$class, 'uninstall'], config("plugin.$name.app.version"));
39+
return self::SUCCESS;
40+
}
41+
42+
}

0 commit comments

Comments
 (0)