Skip to content

Commit

Permalink
Introduce an unused function to build terms in reviewed preprint teasers
Browse files Browse the repository at this point in the history
  • Loading branch information
LinaKind committed Dec 6, 2024
1 parent abb6821 commit c6a1e38
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/ViewModel/Converter/ReviewedPreprintTeaserConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

namespace eLife\Journal\ViewModel\Converter;

use eLife\ApiSdk\Model\ElifeAssessment;
use eLife\ApiSdk\Model\ReviewedPreprint;
use eLife\Journal\Helper\ModelName;
use eLife\Patterns\ViewModel;
use eLife\Patterns\ViewModel\TeaserTerms;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;

final class ReviewedPreprintTeaserConverter implements ViewModelConverter
Expand Down Expand Up @@ -50,6 +52,7 @@ public function convert($object, string $viewModel = null, array $context = [])
$object->getThumbnail() ? $this->smallTeaserImage($object) : null,
ViewModel\TeaserFooter::forArticle(
$meta
// $object->getElifeAssessment() ? $this->buildTeaserTerms($object->getElifeAssessment()) : null
)
);
}
Expand All @@ -63,4 +66,22 @@ protected function getViewModelConverter() : ViewModelConverter
{
return $this->viewModelConverter;
}

private function buildTeaserTerms(ElifeAssessment $elifeAssessment)
{
$significance = array_map(
function ($significanceValue) {
return new ViewModel\Term($significanceValue);
},
$elifeAssessment->getSignificance() ?? []
);

$strength = array_map(
function ($strengthValue) {
return new ViewModel\Term($strengthValue);
},
$elifeAssessment->getStrength() ?? []
);
return new TeaserTerms(array_merge($significance, $strength));
}
}

0 comments on commit c6a1e38

Please sign in to comment.