Skip to content

Commit

Permalink
Fixed normalisation for expression fields
Browse files Browse the repository at this point in the history
  • Loading branch information
sebprt committed Jun 28, 2024
1 parent 1e738f2 commit 8a35000
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 12 deletions.
17 changes: 13 additions & 4 deletions src/Cloud/Pipeline.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,20 @@ public static function fromLegacyConfiguration(array $configuration): DTO\Pipeli
$code = $stepConfig['code'] ?? sprintf('step%d', $order);
unset($stepConfig['name'], $stepConfig['code']);

array_walk_recursive($stepConfig, function (&$value): void {
if ($value instanceof Expression) {
$value = '@='.$value;
array_walk_recursive(
$stepConfig,
function (&$value, $key) {
if ($value instanceof Expression && $key === 'expression') {
$value = (string) $value;
}

if ($value instanceof Expression) {
$value = '@=' . $value;
}

return $value;
}
});
);

return new DTO\Step(
$name,
Expand Down
34 changes: 26 additions & 8 deletions src/Cloud/Workflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,20 @@ function (array $config, int $order) {
$code = $config['pipeline']['code'] ?? sprintf('pipeline%d', $order);
unset($config['pipeline']['name'], $config['pipeline']['code']);

array_walk_recursive($config, function (&$value): void {
if ($value instanceof Expression) {
$value = '@='.$value;
array_walk_recursive(
$config,
function (&$value, $key) {
if ($value instanceof Expression && $key === 'expression') {
$value = (string) $value;
}

if ($value instanceof Expression) {
$value = '@=' . $value;
}

return $value;
}
});
);

return new DTO\Workflow\Pipeline(
$name,
Expand All @@ -70,11 +79,20 @@ function (array $config, int $order) {
$code = $config['action']['code'] ?? sprintf('action%d', $order);
unset($config['action']['name'], $config['action']['code']);

array_walk_recursive($config, function (&$value): void {
if ($value instanceof Expression) {
$value = '@='.$value;
array_walk_recursive(
$config,
function (&$value, $key) {
if ($value instanceof Expression && $key === 'expression') {
$value = (string) $value;
}

if ($value instanceof Expression) {
$value = '@=' . $value;
}

return $value;
}
});
);

$configuration = $config['action'];
unset($config['action']);
Expand Down

0 comments on commit 8a35000

Please sign in to comment.