Skip to content

Commit ec6d121

Browse files
committed
Display the current configuration with the occ "status" command if --verbose.
Signed-off-by: Claus-Justus Heine <[email protected]>
1 parent dd13f30 commit ec6d121

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

lib/Command/Status.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
use OCA\TwoFactorGateway\Provider\Gateway\AGateway;
1313
use OCA\TwoFactorGateway\Provider\Gateway\Factory;
14+
use OCA\TwoFactorGateway\Exception\InvalidProviderException;
1415
use Symfony\Component\Console\Command\Command;
1516
use Symfony\Component\Console\Input\InputInterface;
1617
use Symfony\Component\Console\Output\OutputInterface;
@@ -31,6 +32,7 @@ protected function execute(InputInterface $input, OutputInterface $output) {
3132
$isConfigured = $gateway->isComplete();
3233
$settings = $gateway->getSettings();
3334
$output->writeln($settings['name'] . ': ' . ($isConfigured ? 'configured' : 'not configured'));
35+
$output->write(print_r($gateway->getConfiguration(), true), true, OutputInterface::VERBOSITY_VERBOSE);
3436
}
3537
return 0;
3638
}

lib/Provider/Gateway/AGateway.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,23 @@ public function isComplete(array $schema = []): bool {
4242
return count($intersect) === count($fields);
4343
}
4444

45+
#[\Override]
46+
public function getConfiguration(array $schema = []): array {
47+
if (empty($schema)) {
48+
$schema = static::SCHEMA;
49+
}
50+
$providerId = $this->getProviderId();
51+
$config = [];
52+
foreach ($schema['fields'] as $f) {
53+
$config[$f['field']] = $this->appConfig->getValueString(
54+
Application::APP_ID,
55+
$providerId . '_' . $f['field'],
56+
$f['default'] ?? '',
57+
);
58+
}
59+
return $config;
60+
}
61+
4562
#[\Override]
4663
public function getSettings(): array {
4764
$settings = [];

lib/Provider/Gateway/IGateway.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ public function isComplete(array $schema = []): bool;
2929

3030
public function getSettings(): array;
3131

32+
public function getConfiguration(): array;
33+
3234
public function cliConfigure(InputInterface $input, OutputInterface $output): int;
3335

3436
public function remove(array $schema = []): void;

0 commit comments

Comments
 (0)