Skip to content

Commit 19884cc

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

File tree

4 files changed

+34
-4
lines changed

4 files changed

+34
-4
lines changed

lib/Command/Status.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ protected function execute(InputInterface $input, OutputInterface $output) {
3131
$isConfigured = $gateway->isComplete();
3232
$settings = $gateway->getSettings();
3333
$output->writeln($settings->name . ': ' . ($isConfigured ? 'configured' : 'not configured'));
34+
$output->write(print_r($gateway->getConfiguration(), true), true, OutputInterface::VERBOSITY_VERBOSE);
3435
}
3536
return 0;
3637
}

lib/Provider/Gateway/AGateway.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,29 @@ public function isComplete(?Settings $settings = null): bool {
4141
$providerId = $settings->id ?? $this->getProviderId();
4242
$fields = [];
4343
foreach ($settings->fields as $field) {
44-
$fields[] = $providerId . '_' . $field->field;
44+
$fields[] = self::keyFromFieldName($providerId, $field->field);
4545
}
4646
$intersect = array_intersect($fields, $savedKeys);
4747
return count($intersect) === count($fields);
4848
}
4949

50+
#[\Override]
51+
public function getConfiguration(?Settings $settings = null): array {
52+
if (!is_object($settings)) {
53+
$settings = $this->getSettings();
54+
}
55+
$providerId = $this->getProviderId();
56+
$config = [];
57+
foreach ($settings->fields as $field) {
58+
$config[$f['field']] = $this->appConfig->getValueString(
59+
Application::APP_ID,
60+
self::keyFromFieldName($providerId, $field->field),
61+
$field->default,
62+
);
63+
}
64+
return $config;
65+
}
66+
5067
#[\Override]
5168
public function getSettings(): Settings {
5269
if ($this->settings !== null) {

lib/Provider/Gateway/IGateway.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ public function createSettings(): Settings;
3232

3333
public function getSettings(): Settings;
3434

35+
public function getConfiguration(): array;
36+
3537
public function cliConfigure(InputInterface $input, OutputInterface $output): int;
3638

3739
public function remove(?Settings $settings = null): void;

lib/Provider/Gateway/TConfigurable.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,25 @@ public function __call(string $name, array $args) {
4444
throw new ConfigurationException('Invalid operation ' . $matches['operation']);
4545
}
4646

47+
/**
48+
* @return string
49+
*/
50+
private static function keyFromFieldName(string $id, string $fieldName):string {
51+
return $id . '_' . $fieldName;
52+
}
53+
4754
/**
4855
* @throws ConfigurationException
4956
*/
50-
private function keyFromField(string $fieldName): string {
51-
$settings = $this->getSettings();
57+
private function keyFromField(string $fieldName, ?Settings $settings = null): string {
58+
if (!is_object($settings)) {
59+
$settings = $this->getSettings();
60+
}
61+
$providerId = $settings->id ?? $this->getProviderId();
5262
$fields = $settings->fields;
5363
foreach ($fields as $field) {
5464
if ($field->field === $fieldName) {
55-
return $settings->id . '_' . $fieldName;
65+
static::keyFromFieldName($providerId, $fieldName);
5666
}
5767
}
5868
throw new ConfigurationException('Invalid configuration field: ' . $fieldName . ', check SCHEMA at ' . static::class);

0 commit comments

Comments
 (0)