@@ -38,104 +38,104 @@ |
||
| 38 | 38 | use Symfony\Component\Console\Output\OutputInterface; |
| 39 | 39 | |
| 40 | 40 | class ShowConfig extends Base { |
| 41 | - /** @var \OCA\User_LDAP\Helper */ |
|
| 42 | - protected $helper; |
|
| 41 | + /** @var \OCA\User_LDAP\Helper */ |
|
| 42 | + protected $helper; |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * @param Helper $helper |
|
| 46 | - */ |
|
| 47 | - public function __construct(Helper $helper) { |
|
| 48 | - $this->helper = $helper; |
|
| 49 | - parent::__construct(); |
|
| 50 | - } |
|
| 44 | + /** |
|
| 45 | + * @param Helper $helper |
|
| 46 | + */ |
|
| 47 | + public function __construct(Helper $helper) { |
|
| 48 | + $this->helper = $helper; |
|
| 49 | + parent::__construct(); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - protected function configure() { |
|
| 53 | - $this |
|
| 54 | - ->setName('ldap:show-config') |
|
| 55 | - ->setDescription('shows the LDAP configuration') |
|
| 56 | - ->addArgument( |
|
| 57 | - 'configID', |
|
| 58 | - InputArgument::OPTIONAL, |
|
| 59 | - 'will show the configuration of the specified id' |
|
| 60 | - ) |
|
| 61 | - ->addOption( |
|
| 62 | - 'show-password', |
|
| 63 | - null, |
|
| 64 | - InputOption::VALUE_NONE, |
|
| 65 | - 'show ldap bind password' |
|
| 66 | - ) |
|
| 67 | - ->addOption( |
|
| 68 | - 'output', |
|
| 69 | - null, |
|
| 70 | - InputOption::VALUE_OPTIONAL, |
|
| 71 | - 'Output format (table, plain, json or json_pretty, default is table)', |
|
| 72 | - 'table' |
|
| 73 | - ) |
|
| 74 | - ; |
|
| 75 | - } |
|
| 52 | + protected function configure() { |
|
| 53 | + $this |
|
| 54 | + ->setName('ldap:show-config') |
|
| 55 | + ->setDescription('shows the LDAP configuration') |
|
| 56 | + ->addArgument( |
|
| 57 | + 'configID', |
|
| 58 | + InputArgument::OPTIONAL, |
|
| 59 | + 'will show the configuration of the specified id' |
|
| 60 | + ) |
|
| 61 | + ->addOption( |
|
| 62 | + 'show-password', |
|
| 63 | + null, |
|
| 64 | + InputOption::VALUE_NONE, |
|
| 65 | + 'show ldap bind password' |
|
| 66 | + ) |
|
| 67 | + ->addOption( |
|
| 68 | + 'output', |
|
| 69 | + null, |
|
| 70 | + InputOption::VALUE_OPTIONAL, |
|
| 71 | + 'Output format (table, plain, json or json_pretty, default is table)', |
|
| 72 | + 'table' |
|
| 73 | + ) |
|
| 74 | + ; |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
| 78 | - $availableConfigs = $this->helper->getServerConfigurationPrefixes(); |
|
| 79 | - $configID = $input->getArgument('configID'); |
|
| 80 | - if (!is_null($configID)) { |
|
| 81 | - $configIDs[] = $configID; |
|
| 82 | - if (!in_array($configIDs[0], $availableConfigs)) { |
|
| 83 | - $output->writeln("Invalid configID"); |
|
| 84 | - return 1; |
|
| 85 | - } |
|
| 86 | - } else { |
|
| 87 | - $configIDs = $availableConfigs; |
|
| 88 | - } |
|
| 77 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
| 78 | + $availableConfigs = $this->helper->getServerConfigurationPrefixes(); |
|
| 79 | + $configID = $input->getArgument('configID'); |
|
| 80 | + if (!is_null($configID)) { |
|
| 81 | + $configIDs[] = $configID; |
|
| 82 | + if (!in_array($configIDs[0], $availableConfigs)) { |
|
| 83 | + $output->writeln("Invalid configID"); |
|
| 84 | + return 1; |
|
| 85 | + } |
|
| 86 | + } else { |
|
| 87 | + $configIDs = $availableConfigs; |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - $this->renderConfigs($configIDs, $input, $output); |
|
| 91 | - return 0; |
|
| 92 | - } |
|
| 90 | + $this->renderConfigs($configIDs, $input, $output); |
|
| 91 | + return 0; |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * prints the LDAP configuration(s) |
|
| 96 | - * @param string[] configID(s) |
|
| 97 | - * @param InputInterface $input |
|
| 98 | - * @param OutputInterface $output |
|
| 99 | - */ |
|
| 100 | - protected function renderConfigs($configIDs, $input, $output) { |
|
| 101 | - $renderTable = $input->getOption('output') === 'table' or $input->getOption('output') === null; |
|
| 102 | - $showPassword = $input->getOption('show-password'); |
|
| 94 | + /** |
|
| 95 | + * prints the LDAP configuration(s) |
|
| 96 | + * @param string[] configID(s) |
|
| 97 | + * @param InputInterface $input |
|
| 98 | + * @param OutputInterface $output |
|
| 99 | + */ |
|
| 100 | + protected function renderConfigs($configIDs, $input, $output) { |
|
| 101 | + $renderTable = $input->getOption('output') === 'table' or $input->getOption('output') === null; |
|
| 102 | + $showPassword = $input->getOption('show-password'); |
|
| 103 | 103 | |
| 104 | - $configs = []; |
|
| 105 | - foreach ($configIDs as $id) { |
|
| 106 | - $configHolder = new Configuration($id); |
|
| 107 | - $configuration = $configHolder->getConfiguration(); |
|
| 108 | - ksort($configuration); |
|
| 104 | + $configs = []; |
|
| 105 | + foreach ($configIDs as $id) { |
|
| 106 | + $configHolder = new Configuration($id); |
|
| 107 | + $configuration = $configHolder->getConfiguration(); |
|
| 108 | + ksort($configuration); |
|
| 109 | 109 | |
| 110 | - $rows = []; |
|
| 111 | - if ($renderTable) { |
|
| 112 | - foreach ($configuration as $key => $value) { |
|
| 113 | - if (is_array($value)) { |
|
| 114 | - $value = implode(';', $value); |
|
| 115 | - } |
|
| 116 | - if ($key === 'ldapAgentPassword' && !$showPassword) { |
|
| 117 | - $rows[] = [$key, '***']; |
|
| 118 | - } else { |
|
| 119 | - $rows[] = [$key, $value]; |
|
| 120 | - } |
|
| 121 | - } |
|
| 122 | - $table = new Table($output); |
|
| 123 | - $table->setHeaders(['Configuration', $id]); |
|
| 124 | - $table->setRows($rows); |
|
| 125 | - $table->render(); |
|
| 126 | - } else { |
|
| 127 | - foreach ($configuration as $key => $value) { |
|
| 128 | - if ($key === 'ldapAgentPassword' && !$showPassword) { |
|
| 129 | - $rows[$key] = '***'; |
|
| 130 | - } else { |
|
| 131 | - $rows[$key] = $value; |
|
| 132 | - } |
|
| 133 | - } |
|
| 134 | - $configs[$id] = $rows; |
|
| 135 | - } |
|
| 136 | - } |
|
| 137 | - if (!$renderTable) { |
|
| 138 | - $this->writeArrayInOutputFormat($input, $output, $configs); |
|
| 139 | - } |
|
| 140 | - } |
|
| 110 | + $rows = []; |
|
| 111 | + if ($renderTable) { |
|
| 112 | + foreach ($configuration as $key => $value) { |
|
| 113 | + if (is_array($value)) { |
|
| 114 | + $value = implode(';', $value); |
|
| 115 | + } |
|
| 116 | + if ($key === 'ldapAgentPassword' && !$showPassword) { |
|
| 117 | + $rows[] = [$key, '***']; |
|
| 118 | + } else { |
|
| 119 | + $rows[] = [$key, $value]; |
|
| 120 | + } |
|
| 121 | + } |
|
| 122 | + $table = new Table($output); |
|
| 123 | + $table->setHeaders(['Configuration', $id]); |
|
| 124 | + $table->setRows($rows); |
|
| 125 | + $table->render(); |
|
| 126 | + } else { |
|
| 127 | + foreach ($configuration as $key => $value) { |
|
| 128 | + if ($key === 'ldapAgentPassword' && !$showPassword) { |
|
| 129 | + $rows[$key] = '***'; |
|
| 130 | + } else { |
|
| 131 | + $rows[$key] = $value; |
|
| 132 | + } |
|
| 133 | + } |
|
| 134 | + $configs[$id] = $rows; |
|
| 135 | + } |
|
| 136 | + } |
|
| 137 | + if (!$renderTable) { |
|
| 138 | + $this->writeArrayInOutputFormat($input, $output, $configs); |
|
| 139 | + } |
|
| 140 | + } |
|
| 141 | 141 | } |