Skip to content

Commit

Permalink
Improved saving strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
Zrnik committed Oct 13, 2021
1 parent 57a46d2 commit f1cca7d
Show file tree
Hide file tree
Showing 3 changed files with 198 additions and 383 deletions.
14 changes: 2 additions & 12 deletions src/Repository/BaseEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -911,11 +911,10 @@ public function setPrimaryKeyValue(mixed $newPrimaryKeyValue): void
}

/**
* @param string[] $savedHashList
* @return BaseEntity[]
* @throws ReflectionFailedException
*/
public function getSubEntities(array $savedHashList = []): array
public function getSubEntities(): array
{
$reflection = self::getReflectionClass(static::class);
$subEntities = [];
Expand All @@ -938,16 +937,7 @@ public function getSubEntities(array $savedHashList = []): array
}
}

$allowedSubEntities = [];
/** @var BaseEntity $possibleSubEntity */
foreach ($subEntities as $possibleSubEntity) {
if (!in_array($possibleSubEntity->hash(), $savedHashList, true)) {
$allowedSubEntities[] = $possibleSubEntity;
$savedHashList[] = $possibleSubEntity->hash();
}
}

return $allowedSubEntities;
return $subEntities;
}

public function hash(): string
Expand Down
Loading

0 comments on commit f1cca7d

Please sign in to comment.