From b223f352dbe42bb816ba89681d230c3957c60ad4 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Tue, 22 Mar 2022 16:33:29 +0100 Subject: [PATCH 1/2] fix: Add another parser for array to string Refs: ELSSHOP-23 --- Command/ConfigSynchronizeCommand.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Command/ConfigSynchronizeCommand.php b/Command/ConfigSynchronizeCommand.php index e97ef49..fabc369 100644 --- a/Command/ConfigSynchronizeCommand.php +++ b/Command/ConfigSynchronizeCommand.php @@ -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)); + $strValue = $this->valueToString($value); + $strCurrentValue = $this->valueToString($currentValue); + $this->output->writeln(sprintf('Current value: "%s" for key: "%s"', $strCurrentValue, $key)); // using string comparison for all values (array|bool|float|int|string|null) simplified - if ((string) $currentValue !== (string) $value) { + if ($strCurrentValue !== $strValue) { $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"', $strValue, $key)); } else { $this->output->writeln(sprintf('Did not changed the value for key: "%s"', $key)); } @@ -134,4 +136,13 @@ private function getSalesChannels(): array return $salesChannels; } + + private function valueToString($value): string + { + if (is_array($value)) { + return implode(', ', $value); + } + + return (string) $value; + } } From 8e04d1b454d6b2a816e8191fc759e1b80169041a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Meyer?= Date: Tue, 22 Mar 2022 17:30:24 +0100 Subject: [PATCH 2/2] rename variables --- Command/ConfigSynchronizeCommand.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Command/ConfigSynchronizeCommand.php b/Command/ConfigSynchronizeCommand.php index fabc369..b84d8b5 100644 --- a/Command/ConfigSynchronizeCommand.php +++ b/Command/ConfigSynchronizeCommand.php @@ -83,13 +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); - $strValue = $this->valueToString($value); - $strCurrentValue = $this->valueToString($currentValue); - $this->output->writeln(sprintf('Current value: "%s" for key: "%s"', $strCurrentValue, $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 ($strCurrentValue !== $strValue) { + if ($currentValueAsString !== $valueAsString) { $this->systemConfigService->set($key, $value, $salesChannelId); - $this->output->writeln(sprintf('Changed value to: "%s" for key: "%s"', $strValue, $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)); }