Skip to content

Commit e24826c

Browse files
fix: change method for mapping in OtlStrategy (#446)
1 parent c656ab7 commit e24826c

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

app/Audit/AuditLogOtlpStrategy.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,21 @@ private function buildAuditLogData($entity, $subject, array $change_set, string
187187

188188
private function getCollectionType(PersistentCollection $collection): string
189189
{
190-
if (empty($collection) && empty($collection->getSnapshot())) {
190+
try {
191+
if (!method_exists($collection, 'getMapping')) {
192+
return 'unknown';
193+
}
194+
195+
$mapping = $collection->getMapping();
196+
197+
if (!isset($mapping['targetEntity']) || empty($mapping['targetEntity'])) {
198+
return 'unknown';
199+
}
200+
201+
return class_basename($mapping['targetEntity']);
202+
} catch (\Exception $ex) {
191203
return 'unknown';
192204
}
193-
194-
$item = !empty($collection) ? $collection->first() : $collection->getSnapshot()[0];
195-
return class_basename($item);
196205
}
197206

198207
private function getCollectionChanges(PersistentCollection $collection, array $change_set): array

0 commit comments

Comments
 (0)