Skip to content

Commit

Permalink
NEW Use custom list for eagerloaded relations
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed Jul 19, 2023
1 parent 10fba6e commit 956bd99
Show file tree
Hide file tree
Showing 8 changed files with 2,816 additions and 197 deletions.
17 changes: 17 additions & 0 deletions src/ORM/ArrayLib.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,4 +274,21 @@ public static function iterateVolatile(array &$list)
}
}
}

/**
* Similar to shuffle, but retains the existing keys.
* Shuffles the array in place.
*/
public static function shuffleAssociative(array &$array): void
{
$shuffledArray = [];
$keys = array_keys($array);
shuffle($keys);

foreach ($keys as $key) {
$shuffledArray[$key] = $array[$key];
}

$array = $shuffledArray;
}
}
404 changes: 209 additions & 195 deletions src/ORM/DataList.php

Large diffs are not rendered by default.

Loading

0 comments on commit 956bd99

Please sign in to comment.