Skip to content

Commit 5121921

Browse files
bugfix(61581): [FrameworkBundle] [Config] Update workflow config places callback
1 parent 25dfa7a commit 5121921

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -473,27 +473,34 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode): void
473473
throw new InvalidConfigurationException('The "places" option must be an array in workflow configuration.');
474474
}
475475

476-
// It's an indexed array of shape ['place1', 'place2']
477-
if (isset($places[0]) && \is_string($places[0])) {
478-
return array_map(function (string $place) {
479-
return ['name' => $place];
480-
}, $places);
481-
}
476+
$normalizedPlaces = [];
477+
foreach ($places as $key => $value) {
478+
if (\is_int($key)) {
479+
if (\is_string($value)) {
480+
$normalizedPlaces[] = ['name' => $value];
481+
continue;
482+
}
483+
484+
if (\is_array($value)) {
485+
$normalizedPlaces[] = $value;
486+
continue;
487+
}
488+
}
482489

483-
// It's an indexed array, we let the validation occur
484-
if (isset($places[0]) && \is_array($places[0])) {
485-
return $places;
486-
}
490+
if (\is_array($value)) {
491+
if (\array_key_exists('name', $value)) {
492+
$normalizedPlaces[] = $value;
493+
continue;
494+
}
487495

488-
foreach ($places as $name => $place) {
489-
if (\is_array($place) && \array_key_exists('name', $place)) {
496+
$normalizedPlaces[] = array_merge(['name' => $key], $value);
490497
continue;
498+
} elseif (null === $value) {
499+
$normalizedPlaces[] = ['name' => $key];
491500
}
492-
$place['name'] = $name;
493-
$places[$name] = $place;
494501
}
495502

496-
return array_values($places);
503+
return array_values($normalizedPlaces);
497504
})
498505
->end()
499506
->isRequired()

0 commit comments

Comments
 (0)