Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/Command/Status.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ protected function execute(InputInterface $input, OutputInterface $output) {
$isConfigured = $gateway->isComplete();
$settings = $gateway->getSettings();
$output->writeln($settings->name . ': ' . ($isConfigured ? 'configured' : 'not configured'));
$output->write(print_r($gateway->getConfiguration(), true), true, OutputInterface::VERBOSITY_VERBOSE);
}
return 0;
}
Expand Down
19 changes: 18 additions & 1 deletion lib/Provider/Gateway/AGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,29 @@ public function isComplete(?Settings $settings = null): bool {
$providerId = $settings->id ?? $this->getProviderId();
$fields = [];
foreach ($settings->fields as $field) {
$fields[] = $providerId . '_' . $field->field;
$fields[] = self::keyFromFieldName($providerId, $field->field);
}
$intersect = array_intersect($fields, $savedKeys);
return count($intersect) === count($fields);
}

#[\Override]
public function getConfiguration(?Settings $settings = null): array {
if (!is_object($settings)) {
$settings = $this->getSettings();
}
$providerId = $settings->id ?? $this->getProviderId();
$config = [];
foreach ($settings->fields as $field) {
$config[$field->field] = $this->appConfig->getValueString(
Application::APP_ID,
self::keyFromFieldName($providerId, $field->field),
$field->default,
);
}
return $config;
}

#[\Override]
public function getSettings(): Settings {
if ($this->settings !== null) {
Expand Down
2 changes: 2 additions & 0 deletions lib/Provider/Gateway/IGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public function createSettings(): Settings;

public function getSettings(): Settings;

public function getConfiguration(): array;

public function cliConfigure(InputInterface $input, OutputInterface $output): int;

public function remove(?Settings $settings = null): void;
Expand Down
9 changes: 8 additions & 1 deletion lib/Provider/Gateway/TConfigurable.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ public function __call(string $name, array $args) {
throw new ConfigurationException('Invalid operation ' . $matches['operation']);
}

/**
* @return string
*/
private static function keyFromFieldName(string $id, string $fieldName):string {
return $id . '_' . $fieldName;
}

/**
* @throws ConfigurationException
*/
Expand All @@ -52,7 +59,7 @@ private function keyFromField(string $fieldName): string {
$fields = $settings->fields;
foreach ($fields as $field) {
if ($field->field === $fieldName) {
return $settings->id . '_' . $fieldName;
return static::keyFromFieldName($settings->id, $fieldName);
}
}
throw new ConfigurationException('Invalid configuration field: ' . $fieldName . ', check SCHEMA at ' . static::class);
Expand Down
Loading