Skip to content

Commit

Permalink
[5.x] Updated the BulkAugmentor to be able to handle iterables that d…
Browse files Browse the repository at this point in the history
…on't have sequential numeric keys (#10512)

Co-authored-by: Simon Geoghegan <[email protected]>
  • Loading branch information
kingsven and simonworkhouse authored Jul 26, 2024
1 parent 4e0c7ca commit fd24694
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions src/Data/BulkAugmentor.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,10 @@ public static function tree($tree)
*/
private function augment($items)
{
$count = count($items);

$referenceKeys = [];
$referenceFields = [];

for ($i = 0; $i < $count; $i++) {
$item = $items[$i];
foreach ($items as $i => $item) {
$reference = $this->getAugmentationReference($item);

if (! $this->isTree) {
Expand All @@ -58,8 +55,7 @@ private function augment($items)
$referenceFields[$reference] = $augmented->blueprintFields();
}

for ($i = 0; $i < $count; $i++) {
$item = $items[$i];
foreach ($items as $i => $item) {
$reference = $this->getAugmentationReference($item);
$fields = $referenceFields[$reference];
$keys = $referenceKeys[$reference];
Expand All @@ -80,9 +76,7 @@ private function augmentTree($tree)

$items = [];

for ($i = 0; $i < count($tree); $i++) {
$item = $tree[$i];

foreach ($tree as $i => $item) {
$items[] = $item['page'];
$this->originalValues[$i] = $item;
}
Expand All @@ -94,8 +88,7 @@ public function map(callable $callable)
{
$items = [];

for ($i = 0; $i < count($this->originalValues); $i++) {
$original = $this->originalValues[$i];
foreach ($this->originalValues as $i => $original) {
$augmented = $this->augmentedValues[$i];

$items[] = call_user_func_array($callable, [$original, $augmented, $i]);
Expand Down

0 comments on commit fd24694

Please sign in to comment.