Skip to content

Commit

Permalink
Better account for the eLife assessment in the normalization/denormal…
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcmoulton committed Dec 5, 2024
1 parent 41b04e6 commit 8b5674c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Model/ReviewedPreprint.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function __construct(
Image $thumbnail = null,
PromiseInterface $indexContent,
int $version = null,
$elifeAssessment = null
ElifeAssessment $elifeAssessment = null
)
{
$this->id = $id;
Expand Down
11 changes: 10 additions & 1 deletion src/Serializer/ReviewedPreprintNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ public function denormalize($data, $class, $format = null, array $context = []):
$data['image']['thumbnail'] = $this->denormalizer->denormalize($data['image']['thumbnail'], Image::class, $format, $context);
}

if (isset($data['elifeAssessment'])) {
if (!isset($data['elifeAssessment']['significance'])) {
$data['elifeAssessment']['significance'] = [];
}
if (!isset($data['elifeAssessment']['strength'])) {
$data['elifeAssessment']['strength'] = [];
}
}

return new ReviewedPreprint(
$data['id'],
$data['stage'],
Expand Down Expand Up @@ -204,7 +213,7 @@ public function normalize($object, $format = null, array $context = []): array
$data['version'] = $object->getVersion();
}

if ($object->getElifeAssessment()) {
if (!empty($object->getElifeAssessment())) {
$data['elifeAssessment'] = $object->getElifeAssessment();
}

Expand Down

0 comments on commit 8b5674c

Please sign in to comment.