Skip to content

Commit 54c6ee8

Browse files
author
Enno Woortmann
committed
Change documentation for loop controls to not modify the looped value
1 parent d6ede34 commit 54c6ee8

1 file changed

Lines changed: 3 additions & 8 deletions

File tree

README.md

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -402,19 +402,14 @@ class SongLoop implements \PHPWorkflow\Step\LoopControl {
402402
\PHPWorkflow\WorkflowControl $control,
403403
\PHPWorkflow\State\WorkflowContainer $container
404404
): bool {
405-
$songs = $container->get('songs');
406-
407-
// no songs in container - end the loop
408-
if (empty($songs)) {
405+
// all songs handled - end the loop
406+
if ($iteration === count($container->get('songs'))) {
409407
return false;
410408
}
411409

412410
// add the current song to the container so the steps
413411
// of the loop can access the entry
414-
$container->set('currentSong', array_shift($songs));
415-
416-
// update the songs entry to handle the songs step by step
417-
$container->set('songs', $songs);
412+
$container->set('currentSong', $container->get('songs')[$iteration]);
418413

419414
return true;
420415
}

0 commit comments

Comments
 (0)