drop support for php 7.4 (#5740)
[openemr.git] / src / Common / Command / ZfcModule.php
blob463b620532c3b369a0641ef44f72954e8193ec0d
1 <?php
3 /**
4 * ZfcModule class.
6 * @package OpenEMR
7 * @link https://www.open-emr.org
8 * @author Brady Miller <brady.g.miller@gmail.com>
9 * @copyright Copyright (c) 2022 Brady Miller <brady.g.miller@gmail.com>
10 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
13 namespace OpenEMR\Common\Command;
15 use Installer\Controller\InstallerController;
16 use Installer\Model\InstModuleTable;
17 use Symfony\Component\Console\Command\Command;
18 use Symfony\Component\Console\Input\InputDefinition;
19 use Symfony\Component\Console\Input\InputInterface;
20 use Symfony\Component\Console\Input\InputOption;
21 use Symfony\Component\Console\Output\OutputInterface;
23 class ZfcModule extends Command
25 protected function configure(): void
27 $this
28 ->setName('openemr:zfc-module')
29 ->setDescription('Module maintenance (install_sql, install_acl, upgrade_acl, upgrade_sql, install, enable, disable, unregister)')
30 ->addUsage('--site=default --modname=Multipledb --modaction=install')
31 ->setDefinition(
32 new InputDefinition([
33 new InputOption('modname', null, InputOption::VALUE_REQUIRED, 'Name of module'),
34 new InputOption('modaction', null, InputOption::VALUE_REQUIRED, 'Available actions: install_sql, install_acl, upgrade_acl, upgrade_sql, install, enable, disable, unregister'),
35 new InputOption('site', null, InputOption::VALUE_REQUIRED, 'Name of site', 'default'),
41 protected function execute(InputInterface $input, OutputInterface $output): int
43 if (empty($input->getOption('modname'))) {
44 $output->writeln('modname parameter is missing (required), so exiting');
45 return 2;
47 if (empty($input->getOption('modaction'))) {
48 $output->writeln('modaction parameter is missing (required), so exiting');
49 return 2;
52 $modname = $input->getOption('modname');
53 $modaction = $input->getOption('modaction');
54 (new InstallerController($GLOBALS['modules_application']->getServiceManager()->build(InstModuleTable::class)))->commandInstallModuleAction($modname, $modaction);
55 return 0;