mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-11-28 02:20:41 +00:00
78 lines
2.5 KiB
PHP
78 lines
2.5 KiB
PHP
<?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
|