settings = $settings; $this->logger = $logger; $this->translator = $translator; $this->extmgr = $extmgr; parent::__construct(); } protected function configure() { $this->setName('ext:package') ->setDescription('Package extension as a zip file. If --output-dir is given, the zip file will be placed into this directory otherwise it will be saved in the current directory. The name of the zip file will be -.zip. If such a file already exists, it will be deleted and recreated.') ->setHelp('Creates a zip file of an extension, which can be uploaded into SeedDMS.') ->addOption('name', '', InputOption::VALUE_REQUIRED, 'Name of extension.', null) ->addOption('output-dir', '', InputOption::VALUE_REQUIRED, 'Name of directory where the zip file is saved.', null) ; } protected function execute(InputInterface $input, OutputInterface $output) : int { $settings = $this->settings; $logger = $this->logger; $translator = $this->translator; $extmgr = $this->extmgr; $output->writeln("Using configuration from '".$settings->_configFilePath."'.", OutputInterface::VERBOSITY_VERBOSE); $extconf = $extmgr->getExtensionConfiguration(); $extname = $input->getOption('name'); if (!isset($extconf[$extname])) { $output->writeln(sprintf("No such extension '%s'", $extname)); return Command::FAILURE; } $outputdir = $input->getOption('output-dir'); if(!$outputdir) $outputdir = '.'; /* If the $outputdir is not passed to createArchive(), the cache * dir of SeedDMS will be used, which requires to run this script * with sufficient access rights on that directory. */ $filename = $extmgr->createArchive($extname, $extmgr->getExtensionConfiguration()[$extname]['version'], $outputdir); $output->writeln(sprintf("Extension saved as '%s'", $filename)); return Command::SUCCESS; } } // vim: ts=4 sw=4 expandtab