Skip to content

Commit

Permalink
Merge pull request #4 from flagbit/feature/ELSSHOP-23
Browse files Browse the repository at this point in the history
fix: Add another parser for array to string
  • Loading branch information
Antonio Mansilla authored Mar 22, 2022
2 parents 54d8577 + 8e04d1b commit 2e33025
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions Command/ConfigSynchronizeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,13 @@ private function executeConfigSet(array $config, string $name, ?string $salesCha
$this->output->writeln('---------------------------------------');
foreach ($config as $key => $value) {
$currentValue = $this->systemConfigService->get($key, $salesChannelId);
$this->output->writeln(sprintf('Current value: "%s" for key: "%s"', $currentValue, $key));
$currentValueAsString = $this->valueToString($currentValue);
$valueAsString = $this->valueToString($value);
$this->output->writeln(sprintf('Current value: "%s" for key: "%s"', $currentValueAsString, $key));
// using string comparison for all values (array|bool|float|int|string|null) simplified
if ((string) $currentValue !== (string) $value) {
if ($currentValueAsString !== $valueAsString) {
$this->systemConfigService->set($key, $value, $salesChannelId);
$this->output->writeln(sprintf('Changed value to: "%s" for key: "%s"', $value, $key));
$this->output->writeln(sprintf('Changed value to: "%s" for key: "%s"', $valueAsString, $key));
} else {
$this->output->writeln(sprintf('Did not changed the value for key: "%s"', $key));
}
Expand Down Expand Up @@ -133,4 +135,13 @@ private function getSalesChannels(): array

return $salesChannels;
}

private function valueToString($value): string
{
if (is_array($value)) {
return implode(', ', $value);
}

return (string) $value;
}
}

0 comments on commit 2e33025

Please sign in to comment.