Skip to content

Commit 94e5c72

Browse files
author
Joanis ROUANET
committed
Fixed collection normalization
1 parent 7844e2d commit 94e5c72

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/Normalizer/CollectionNormalizer.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,27 +38,26 @@ public function normalize($collection, $format = null, array $context = []): arr
3838
$recordId = $record->getId();
3939

4040
if (!$recordId) {
41+
if($record instanceof GhostObjectInterface && !$record->isProxyInitialized()) {
42+
continue;
43+
}
44+
4145
$commands[] = $this->expressionBuilder->createRecord($this->getRecordData($record));
4246
continue;
4347
}
4448

4549
$newStoredIds[] = $recordId;
4650

47-
if (!($record instanceof GhostObjectInterface)) {
48-
if (in_array($recordId, $storedIds, true)) {
49-
$commands[] = $this->expressionBuilder->updateRecord($recordId, $this->getRecordData($record));
51+
if (in_array($recordId, $storedIds, true)) {
52+
if($record instanceof GhostObjectInterface && !$record->isProxyInitialized()) {
5053
continue;
5154
}
5255

53-
$commands[] = $this->expressionBuilder->addRecord($recordId);
54-
continue;
55-
}
56-
57-
if (!$record->isProxyInitialized()) {
56+
$commands[] = $this->expressionBuilder->updateRecord($recordId, $this->getRecordData($record));
5857
continue;
5958
}
6059

61-
$commands[] = $this->expressionBuilder->updateRecord($recordId, $this->getRecordData($record));
60+
$commands[] = $this->expressionBuilder->addRecord($recordId);
6261
}
6362

6463
foreach ($storedIds as $storedRecordId) {

0 commit comments

Comments
 (0)