Skip to content

Commit

Permalink
Improve the safety of a check for the existence of an elifeArticleAss…
Browse files Browse the repository at this point in the history
  • Loading branch information
LinaKind committed Dec 19, 2024
1 parent 75e746a commit ac78a76
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions src/Serializer/ArticleVoRNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -456,13 +456,6 @@ protected function normalizeArticle(
if ($article->getElifeAssessmentTitle()) {
$data['elifeAssessment'] = [
'title' => $article->getElifeAssessmentTitle(),
'content' => $article->getElifeAssessmentArticleSection()->getContent()
->map(function (Block $block) use (
$format,
$context
) {
return $this->normalizer->normalize($block, $format, $context);
})->toArray(),
];
}

Expand All @@ -473,6 +466,13 @@ protected function normalizeArticle(
if ($article->getElifeAssessmentArticleSection()) {
$data['elifeAssessment']['doi'] = $article->getElifeAssessmentArticleSection()->getDoi();
$data['elifeAssessment']['id'] = $article->getElifeAssessmentArticleSection()->getId();
$data['elifeAssessment']['content'] = $article->getElifeAssessmentArticleSection()->getContent()
->map(function (Block $block) use (
$format,
$context
) {
return $this->normalizer->normalize($block, $format, $context);
})->toArray();
}

if (empty($context['snippet'])) {
Expand Down
6 changes: 3 additions & 3 deletions test/Serializer/ArticleVoRNormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -657,15 +657,15 @@ function ($test) {
'impactStatement' => 'A new hominin species has been unearthed in the Dinaledi Chamber of the Rising Star cave system in the largest assemblage of a single species of hominins yet discovered in Africa.',
'elifeAssessment' => [
'title' => 'eLife assessment',
'scietyUri' => 'https://elife-assessment-09560.com',
'doi' => '10.7554/eLife.09560elifeAssessment',
'id' => 'elife-assessment-id',
'content' => [
[
'type' => 'paragraph',
'text' => 'Article 09560 elife assessment text',
],
],
'scietyUri' => 'https://elife-assessment-09560.com',
'doi' => '10.7554/eLife.09560elifeAssessment',
'id' => 'elife-assessment-id',
// 'significance' => ['landmark'],
// 'strength' => ['solid'],
]
Expand Down

0 comments on commit ac78a76

Please sign in to comment.