Skip to content

Commit

Permalink
Fix Bug if no creators exists
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-sc committed Jan 15, 2025
1 parent 2586601 commit 21c52c2
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions Classes/Processing/BibEntryProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,21 @@ public static function buildNestedField(
{
return Collection::wrap($fieldConfig)->
map(function ($field) use ($bibliographyItem) {
return self::buildListingEntry($field, $bibliographyItem);
$entry = self::buildListingEntry($field, $bibliographyItem);

// buildListingEntry can return null if no field creators exist
if ($entry === null) {
// ignore or return empty array ?
return []; //
}

if (!is_array($entry)) {
throw new \UnexpectedValueException(
'Expected array from buildListingEntry, but got: ' . gettype($entry)
);
}

return $entry;
})->
flatMap(function (array $item): Collection {
//if (is_array($item)) { -> @Thomas do we need this?
Expand Down Expand Up @@ -134,7 +148,9 @@ private static function buildListingEntry(array $field, array $bibliographyItem)
isset($field['field']) &&
!isset($bibliographyItem[$field['field']]) ||
isset($field['compound']['field']) &&
!isset($bibliographyItem[$field['compound']['field']])
!isset($bibliographyItem[$field['compound']['field']]) ||
isset($field['compoundArray']['field']) &&
!isset($bibliographyItem[$field['compoundArray']['field']])
) {
return null;
}
Expand Down

0 comments on commit 21c52c2

Please sign in to comment.