add command to upload extension

This commit is contained in:
Uwe Steinmann 2025-11-13 22:20:16 +01:00
parent cb3d5b6379
commit 73e266bab7
2 changed files with 79 additions and 0 deletions

View File

@ -0,0 +1,77 @@
<?php
namespace Seeddms\Console\Commands;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
use Seeddms\Seeddms\Settings;
use Seeddms\Seeddms\Translator;
use SeedDMS_Core_File;
use SeedDMS_View_Common;
use SeedDMS_Extension_Mgr;
use Log_file;
class UploadextensionCommand extends Command
{
protected $settings;
protected $logger;
protected $translator;
protected $extmgr;
public function __construct(Settings $settings, Log_file $logger, Translator $translator, SeedDMS_Extension_Mgr $extmgr)
{
$this->settings = $settings;
$this->logger = $logger;
$this->translator = $translator;
$this->extmgr = $extmgr;
parent::__construct();
}
protected function configure()
{
$this->setName('ext:upload')
->setDescription('Upload extension')
->setHelp('Uploads an extensions, which replaces an exiting extension or inserts a new extension.')
->addOption('file', '', InputOption::VALUE_REQUIRED, 'Filename of zipped extension.', null)
;
}
protected function execute(InputInterface $input, OutputInterface $output) : int
{
$settings = $this->settings;
$logger = $this->logger;
$translator = $this->translator;
$extmgr = $this->extmgr;
$output->writeln("<comment>Using configuration from '".$settings->_configFilePath."'.</comment>", OutputInterface::VERBOSITY_VERBOSE);
if (!is_writable($settings->_configFilePath)) {
$output->writeln(sprintf("<error>The configuration file '%s' is not writable by the system user running this script.</error>", $settings->_configFilePath));
return Command::FAILURE;
}
if (!is_writable($settings->_cacheDir)) {
$output->writeln(sprintf("<error>The cache dir '%s' is not writable for the system user running this script.</error>", $settings->_cacheDir));
return Command::FAILURE;
}
if (!$extmgr->updateExtension($filename)) {
foreach ($extmgr->getErrorMsgs() as $msg) {
$output->writeln(sprintf("<error>%s</error>", $msg));
}
return Command::FAILURE;
}
return Command::SUCCESS;
}
}
// vim: ts=4 sw=4 expandtab

View File

@ -16,6 +16,7 @@ use Seeddms\Console\Commands\ClearcacheCommand;
use Seeddms\Console\Commands\ListcacheCommand;
use Seeddms\Console\Commands\ListextensionCommand;
use Seeddms\Console\Commands\ConfigureextensionCommand;
use Seeddms\Console\Commands\UploadextensionCommand;
use Seeddms\Console\Commands\PackageextensionCommand;
use Seeddms\Console\Commands\ReloadextensionCommand;
use Seeddms\Seeddms\Settings;
@ -42,6 +43,7 @@ $application->add(new ClearcacheCommand($settings, $logger, $translator));
$application->add(new ListcacheCommand($settings, $logger, $translator));
$application->add(new ListextensionCommand($settings, $logger, $translator, $extmgr));
$application->add(new ConfigureextensionCommand($settings, $logger, $translator, $extmgr));
$application->add(new UploadextensionCommand($settings, $logger, $translator, $extmgr));
$application->add(new PackageextensionCommand($settings, $logger, $translator, $extmgr));
$application->add(new ReloadextensionCommand($settings, $logger, $translator, $extmgr));