Skip to content

Commit

Permalink
fix: combine update
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolocarpignoli committed Jul 3, 2024
1 parent 5a79577 commit e289658
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Model/ObjectsLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Cake\ORM\Table;
use Cake\Utility\Hash;
use Cake\Utility\Inflector;
use InvalidArgumentException;
use Iterator;

/**
Expand Down Expand Up @@ -403,8 +404,8 @@ protected function toConcreteTypes(iterable $objects, int $depth): CollectionInt
$sortedIds = $objects->extract('id')->toList();

return $objects
->combine('id', fn (Entity $object): Entity => $object, 'type')
->unfold(function (iterable $items, string $type) use ($depth): Iterator {
->combine('id', fn (Entity $object): Entity => $object, fn (Entity $object): string|null => $object->type ?? (string)$object->id)
->unfold(function (iterable $items, string|int $type) use ($depth): Iterator {
if (!$type) {
yield from $items;

Expand Down Expand Up @@ -517,6 +518,7 @@ protected function autoHydrateAssociations(iterable $objects, int $depth, array|
}

$related = $object->get($prop);

if ($related instanceof ObjectEntity) {
$original = $related;

Expand Down

0 comments on commit e289658

Please sign in to comment.