mirror of
https://github.com/slawkens/myaac.git
synced 2025-11-02 00:46:23 +01:00
Rename file name to PluginSetupCommand
This commit is contained in:
41
system/src/Commands/PluginSetupCommand.php
Normal file
41
system/src/Commands/PluginSetupCommand.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace MyAAC\Commands;
|
||||
|
||||
use MyAAC\Plugins;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
|
||||
class PluginSetupCommand extends Command
|
||||
{
|
||||
protected function configure(): void
|
||||
{
|
||||
$this->setName('plugin:setup')
|
||||
->setAliases(['plugin:install:install'])
|
||||
->setDescription('This command executes the "install" part of the plugin')
|
||||
->addArgument('plugin', InputArgument::REQUIRED, 'Plugin name');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
require SYSTEM . 'init.php';
|
||||
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
|
||||
$pluginName = $input->getArgument('plugin');
|
||||
if(!Plugins::executeInstall($pluginName)) {
|
||||
$io->error(Plugins::getError());
|
||||
return 2;
|
||||
}
|
||||
|
||||
foreach(Plugins::getWarnings() as $warning) {
|
||||
$io->warning($warning);
|
||||
}
|
||||
|
||||
$info = Plugins::getPluginJson($pluginName);
|
||||
$io->success('Script for install ' . (isset($info['name']) ? $info['name'] . ' p' : 'P') . 'lugin has been successfully executed.');
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user