From ac78a7689d82805413b9cee2092f921c1a0449b4 Mon Sep 17 00:00:00 2001 From: LinaKind Date: Thu, 19 Dec 2024 11:02:37 +0000 Subject: [PATCH] Improve the safety of a check for the existence of an elifeArticleAssessment https://github.com/elifesciences/issues/issues/9034 --- src/Serializer/ArticleVoRNormalizer.php | 14 +++++++------- test/Serializer/ArticleVoRNormalizerTest.php | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Serializer/ArticleVoRNormalizer.php b/src/Serializer/ArticleVoRNormalizer.php index 2238411a..80940d37 100644 --- a/src/Serializer/ArticleVoRNormalizer.php +++ b/src/Serializer/ArticleVoRNormalizer.php @@ -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(), ]; } @@ -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'])) { diff --git a/test/Serializer/ArticleVoRNormalizerTest.php b/test/Serializer/ArticleVoRNormalizerTest.php index 2990db28..cff73f78 100644 --- a/test/Serializer/ArticleVoRNormalizerTest.php +++ b/test/Serializer/ArticleVoRNormalizerTest.php @@ -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'], ]