drop support for php 7.4 (#5740)
[openemr.git] / src / Common / Command / Register.php
blobaf3a142dd97044305be4099a3a19c4a0d057f94e
1 <?php
3 /**
4 * Register 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\Model\InstModuleTable;
16 use Symfony\Component\Console\Command\Command;
17 use Symfony\Component\Console\Input\InputDefinition;
18 use Symfony\Component\Console\Input\InputInterface;
19 use Symfony\Component\Console\Input\InputOption;
20 use Symfony\Component\Console\Output\OutputInterface;
22 class Register extends Command
24 protected function configure(): void
26 $this
27 ->setName('openemr:register')
28 ->setDescription('Register a zend module')
29 ->addUsage('--site=default --mtype=zend --modname=Multipledb')
30 ->setDefinition(
31 new InputDefinition([
32 new InputOption('mtype', null, InputOption::VALUE_REQUIRED, 'Only "zend" is supported'),
33 new InputOption('modname', null, InputOption::VALUE_REQUIRED, 'Zend module name'),
34 new InputOption('site', null, InputOption::VALUE_REQUIRED, 'Name of site', 'default'),
40 protected function execute(InputInterface $input, OutputInterface $output): int
42 if (empty($input->getOption('mtype'))) {
43 $output->writeln('mtype parameter is missing (required), so exiting');
44 return 2;
46 if (empty($input->getOption('modname'))) {
47 $output->writeln('modname parameter is missing (required), so exiting');
48 return 2;
51 if ($input->getOption('mtype') != 'zend') {
52 $output->writeln('mtype parameter that is not "zend" is not supported');
53 return 1;
57 $moduleName = $input->getOption('modname');
58 $rel_path = "public/" . $moduleName . "/";
60 if ($GLOBALS['modules_application']->getServiceManager()->build(InstModuleTable::class)->register($moduleName, $rel_path, 0, $GLOBALS['zendModDir'])) {
61 $output->writeln('Success');
62 return 0;
63 } else {
64 $output->writeln('Failure');
65 return 1;