diff --git a/Classes/Backend/Preview.php b/Classes/Backend/Preview.php
index e7bdb43..cf36e22 100644
--- a/Classes/Backend/Preview.php
+++ b/Classes/Backend/Preview.php
@@ -74,7 +74,11 @@ class Preview implements PageLayoutViewDrawItemHookInterface
$skills = GeneralUtility::intExplode(',', $row['skilldisplay_skills'], true);
foreach ($skills as $skillId) {
- $row['skills'][] = $this->skillApi->getById($skillId);
+ try {
+ $row['skills'][] = $this->skillApi->getById($skillId);
+ } catch (\Exception $e) {
+ $row['skills'][]['error'] = $e->getMessage();
+ }
}
return $row;
@@ -85,7 +89,11 @@ class Preview implements PageLayoutViewDrawItemHookInterface
$skillSets = GeneralUtility::intExplode(',', $row['skilldisplay_skillset'], true);
foreach ($skillSets as $skillSetId) {
- $row['skillSets'][] = $this->skillSetApi->getById($skillSetId);
+ try {
+ $row['skillSets'][] = $this->skillSetApi->getById($skillSetId);
+ } catch (\Exception $e) {
+ $row['skillSets'][]['error'] = $e->getMessage();
+ }
}
return $row;
diff --git a/Classes/Frontend/DataProcessing/SkillSets.php b/Classes/Frontend/DataProcessing/SkillSets.php
index 7adc54e..440b978 100644
--- a/Classes/Frontend/DataProcessing/SkillSets.php
+++ b/Classes/Frontend/DataProcessing/SkillSets.php
@@ -54,7 +54,11 @@ class SkillSets implements DataProcessorInterface
$skillSets = [];
foreach ($skillSetIds as $skillSetId) {
- $skillSets[] = $this->skillSetApi->getById($skillSetId);
+ try {
+ $skillSets[] = $this->skillSetApi->getById($skillSetId);
+ } catch (\Exception $e) {
+ continue;
+ }
}
$processedData[$as] = $skillSets;
diff --git a/Classes/Frontend/DataProcessing/Skills.php b/Classes/Frontend/DataProcessing/Skills.php
index 4235c95..6757bbc 100644
--- a/Classes/Frontend/DataProcessing/Skills.php
+++ b/Classes/Frontend/DataProcessing/Skills.php
@@ -54,7 +54,11 @@ class Skills implements DataProcessorInterface
$skills = [];
foreach ($skillIds as $skillId) {
- $skills[] = $this->skillApi->getById($skillId);
+ try {
+ $skills[] = $this->skillApi->getById($skillId);
+ } catch (\Exception $e) {
+ continue;
+ }
}
$processedData[$as] = $skills;
diff --git a/Resources/Private/Templates/Backend/ContentElements/Skills.html b/Resources/Private/Templates/Backend/ContentElements/Skills.html
index eb64f88..e603ab1 100644
--- a/Resources/Private/Templates/Backend/ContentElements/Skills.html
+++ b/Resources/Private/Templates/Backend/ContentElements/Skills.html
@@ -10,8 +10,15 @@
-
- {skill.title}
- {sd:verification.url(skill: skill.id)}
+
+
+ {skill.error}
+
+
+ {skill.title}
+ {sd:verification.url(skill: skill.id)}
+
+
diff --git a/Resources/Private/Templates/Backend/ContentElements/Skillset.html b/Resources/Private/Templates/Backend/ContentElements/Skillset.html
index 0eef70b..d5b44f6 100644
--- a/Resources/Private/Templates/Backend/ContentElements/Skillset.html
+++ b/Resources/Private/Templates/Backend/ContentElements/Skillset.html
@@ -10,7 +10,15 @@
-
- {skillSet.name}
+
+
+ {skillSet.error}
+
+
+ {skillSet.title}
+ {sd:verification.url(skillSet: skillSet.id)}
+
+
diff --git a/Tests/Unit/Backend/PreviewTest.php b/Tests/Unit/Backend/PreviewTest.php
index 9957d24..c08aae1 100644
--- a/Tests/Unit/Backend/PreviewTest.php
+++ b/Tests/Unit/Backend/PreviewTest.php
@@ -188,4 +188,106 @@ class PreviewTest extends TestCase
],
], $row);
}
+
+ /**
+ * @test
+ */
+ public function addsExceptionMessageForSkills(): void
+ {
+ $skillApi = $this->prophesize(Skill::class);
+ $skillSetApi = $this->prophesize(SkillSet::class);
+ $pageLayoutView = $this->prophesize(PageLayoutView::class);
+ $exception = new \Exception('Some helpfull message');
+
+ $skill10 = $this->prophesize(SkillEntity::class);
+ $skillApi->getById(10)->willThrow($exception);
+ $skill20 = $this->prophesize(SkillEntity::class);
+ $skillApi->getById(20)->willReturn($skill20->reveal());
+
+ $subject = new Preview(
+ $skillApi->reveal(),
+ $skillSetApi->reveal()
+ );
+
+ $revealedPageLayoutView = $pageLayoutView->reveal();
+ $drawItem = false;
+ $headerContent = '';
+ $itemContent = '';
+ $row = [
+ 'skilldisplay_skills' => '10, 20,,',
+ 'skilldisplay_skillset' => '0',
+ ];
+
+ $subject->preProcess(
+ $revealedPageLayoutView,
+ $drawItem,
+ $headerContent,
+ $itemContent,
+ $row
+ );
+
+ static::assertFalse($drawItem);
+ static::assertEmpty($headerContent);
+ static::assertEmpty($itemContent);
+ static::assertSame([
+ 'skilldisplay_skills' => '10, 20,,',
+ 'skilldisplay_skillset' => '0',
+ 'skills' => [
+ [
+ 'error' => 'Some helpfull message',
+ ],
+ $skill20->reveal(),
+ ],
+ 'skillSets' => [],
+ ], $row);
+ }
+
+ /**
+ * @test
+ */
+ public function addsExceptionMessageForSkillSets(): void
+ {
+ $skillApi = $this->prophesize(Skill::class);
+ $skillSetApi = $this->prophesize(SkillSet::class);
+ $pageLayoutView = $this->prophesize(PageLayoutView::class);
+ $exception = new \Exception('Some helpfull message');
+
+ $skillSetApi->getById(10)->willThrow($exception);
+
+ $subject = new Preview(
+ $skillApi->reveal(),
+ $skillSetApi->reveal()
+ );
+
+ $revealedPageLayoutView = $pageLayoutView->reveal();
+ $drawItem = false;
+ $headerContent = '';
+ $itemContent = '';
+ $row = [
+ 'skilldisplay_skills' => '',
+ 'skilldisplay_skillset' => '10',
+ ];
+
+ $subject->preProcess(
+ $revealedPageLayoutView,
+ $drawItem,
+ $headerContent,
+ $itemContent,
+ $row
+ );
+
+ static::assertFalse($drawItem);
+ static::assertEmpty($headerContent);
+ static::assertEmpty($itemContent);
+ static::assertSame([
+ 'skilldisplay_skills' => '',
+ 'skilldisplay_skillset' => '10',
+ 'skills' => [],
+ 'skillSets' => [
+ [
+ 'error' => 'Some helpfull message',
+ ],
+ ],
+ ], $row);
+ }
}
diff --git a/Tests/Unit/Frontend/DataProcessing/SkillSetsTest.php b/Tests/Unit/Frontend/DataProcessing/SkillSetsTest.php
index 3d5a2f0..aa945ca 100644
--- a/Tests/Unit/Frontend/DataProcessing/SkillSetsTest.php
+++ b/Tests/Unit/Frontend/DataProcessing/SkillSetsTest.php
@@ -106,4 +106,39 @@ class SkillSetsTest extends TestCase
],
], $processedData);
}
+
+ /**
+ * @test
+ */
+ public function skillsSkillSetInCaseOfException(): void
+ {
+ $skillApi = $this->prophesize(SkillSet::class);
+ $skillSet10 = $this->prophesize(SkillSetEntity::class);
+ $skillApi->getById(10)->willReturn($skillSet10->reveal());
+ $skillSet20 = $this->prophesize(SkillSetEntity::class);
+ $skillApi->getById(20)->willThrow(new \Exception());
+
+ $cObj = $this->prophesize(ContentObjectRenderer::class);
+ $cObj->stdWrapValue('as', [], 'skillSets')->willReturn('skillSets');
+ $cObj->stdWrapValue('skillSets', [], '')->willReturn('10, 20,,');
+
+ $subject = new SkillSets(
+ $skillApi->reveal()
+ );
+
+ $processedData = $subject->process(
+ $cObj->reveal(),
+ [],
+ [],
+ [
+ 'skillSets' => '10, 20,,',
+ ]
+ );
+
+ static::assertEquals([
+ 'skillSets' => [
+ $skillSet10->reveal(),
+ ],
+ ], $processedData);
+ }
}
diff --git a/Tests/Unit/Frontend/DataProcessing/SkillsTest.php b/Tests/Unit/Frontend/DataProcessing/SkillsTest.php
index b75bccd..cb89e14 100644
--- a/Tests/Unit/Frontend/DataProcessing/SkillsTest.php
+++ b/Tests/Unit/Frontend/DataProcessing/SkillsTest.php
@@ -106,4 +106,39 @@ class SkillsTest extends TestCase
],
], $processedData);
}
+
+ /**
+ * @test
+ */
+ public function skillsSkillSetInCaseOfException(): void
+ {
+ $skillApi = $this->prophesize(Skill::class);
+ $skill10 = $this->prophesize(SkillEntity::class);
+ $skillApi->getById(10)->willReturn($skill10->reveal());
+ $skill20 = $this->prophesize(SkillEntity::class);
+ $skillApi->getById(20)->willThrow(new \Exception());
+
+ $cObj = $this->prophesize(ContentObjectRenderer::class);
+ $cObj->stdWrapValue('as', [], 'skills')->willReturn('skills');
+ $cObj->stdWrapValue('skills', [], '')->willReturn('10, 20,,');
+
+ $subject = new Skills(
+ $skillApi->reveal()
+ );
+
+ $processedData = $subject->process(
+ $cObj->reveal(),
+ [],
+ [],
+ [
+ 'skills' => '10, 20,,',
+ ]
+ );
+
+ static::assertEquals([
+ 'skills' => [
+ $skill10->reveal(),
+ ],
+ ], $processedData);
+ }
}