diff --git a/Classes/TcaEnhancer.php b/Classes/TcaEnhancer.php
new file mode 100644
index 0000000..7d3bc4e
--- /dev/null
+++ b/Classes/TcaEnhancer.php
@@ -0,0 +1,28 @@
+getForUser();
+ /** @var Campaign $campaign */
+ foreach ($campaigns as $campaign) {
+ $params['items'][] = [
+ $campaign->getTitle(),
+ $campaign->getId(),
+ ];
+ }
+ }
+}
diff --git a/Classes/ViewHelpers/Verification/ButtonViewHelper.php b/Classes/ViewHelpers/Verification/ButtonViewHelper.php
index d2a44eb..0b644d8 100644
--- a/Classes/ViewHelpers/Verification/ButtonViewHelper.php
+++ b/Classes/ViewHelpers/Verification/ButtonViewHelper.php
@@ -34,7 +34,8 @@ class ButtonViewHelper extends VerificationViewHelper
return $link->getVerificationButton(
$arguments['type'],
static::getId($arguments),
- static::getType($arguments)
+ static::getType($arguments),
+ $arguments['campaign']
);
}
}
diff --git a/Classes/ViewHelpers/Verification/UrlViewHelper.php b/Classes/ViewHelpers/Verification/UrlViewHelper.php
index fb27f82..17e7e98 100644
--- a/Classes/ViewHelpers/Verification/UrlViewHelper.php
+++ b/Classes/ViewHelpers/Verification/UrlViewHelper.php
@@ -34,7 +34,8 @@ class UrlViewHelper extends VerificationViewHelper
return $link->getVerificationLink(
$arguments['type'],
static::getId($arguments),
- static::getType($arguments)
+ static::getType($arguments),
+ $arguments['campaign']
);
}
}
diff --git a/Classes/ViewHelpers/VerificationViewHelper.php b/Classes/ViewHelpers/VerificationViewHelper.php
index 129a4eb..10309cb 100644
--- a/Classes/ViewHelpers/VerificationViewHelper.php
+++ b/Classes/ViewHelpers/VerificationViewHelper.php
@@ -38,6 +38,7 @@ abstract class VerificationViewHelper extends AbstractViewHelper
$this->registerArgument('skill', 'integer', 'ID of the Skill.');
$this->registerArgument('skillSet', 'integer', 'ID of the SkillSet.');
$this->registerArgument('type', 'string', 'Type of verification', false, 'self');
+ $this->registerArgument('campaign', 'int', 'ID of campaign', false, 0);
}
public static function renderStatic(
diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml
index a3a5c41..ec5baba 100644
--- a/Configuration/Services.yaml
+++ b/Configuration/Services.yaml
@@ -28,6 +28,10 @@ services:
arguments:
$settings: '@skilldisplay.settings'
+ SkillDisplay\PHPToolKit\Api\Campaigns:
+ arguments:
+ $settings: '@skilldisplay.settings'
+
SkillDisplay\PHPToolKit\Verification\Link:
public: true
arguments:
diff --git a/Configuration/TCA/Overrides/tt_content.php b/Configuration/TCA/Overrides/tt_content.php
index bb1c043..5911056 100644
--- a/Configuration/TCA/Overrides/tt_content.php
+++ b/Configuration/TCA/Overrides/tt_content.php
@@ -32,6 +32,15 @@
'size' => 10,
],
],
+ 'skilldisplay_campaign' => [
+ 'label' => $languagePath . 'skilldisplay_campaign',
+ 'config' => [
+ 'type' => 'select',
+ 'renderType' => 'selectSingle',
+ 'itemsProcFunc' => \SkillDisplay\Typo3Extension\TcaEnhancer::class . '->' . 'getCampaignsForTCA',
+ 'items' => []
+ ]
+ ],
],
]);
})('skilldisplay', 'tt_content');
diff --git a/Configuration/TCA/Overrides/tt_content_skills.php b/Configuration/TCA/Overrides/tt_content_skills.php
index a5e677f..024970d 100644
--- a/Configuration/TCA/Overrides/tt_content_skills.php
+++ b/Configuration/TCA/Overrides/tt_content_skills.php
@@ -15,6 +15,7 @@
'--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general',
'--palette--;;general',
'skilldisplay_skills',
+ 'skilldisplay_campaign',
'--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.appearance',
'--palette--;;frames',
'--palette--;;appearanceLinks',
diff --git a/Configuration/TCA/Overrides/tt_content_skillset.php b/Configuration/TCA/Overrides/tt_content_skillset.php
index 2f3f516..e462fca 100644
--- a/Configuration/TCA/Overrides/tt_content_skillset.php
+++ b/Configuration/TCA/Overrides/tt_content_skillset.php
@@ -15,6 +15,7 @@
'--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general',
'--palette--;;general',
'skilldisplay_skillset',
+ 'skilldisplay_campaign',
'--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.appearance',
'--palette--;;frames',
'--palette--;;appearanceLinks',
diff --git a/Resources/Private/Templates/Backend/ContentElements/Skills.html b/Resources/Private/Templates/Backend/ContentElements/Skills.html
index e603ab1..66b8adf 100644
--- a/Resources/Private/Templates/Backend/ContentElements/Skills.html
+++ b/Resources/Private/Templates/Backend/ContentElements/Skills.html
@@ -16,7 +16,7 @@
- {sd:verification.url(skill: skill.id)}
+ {sd:verification.url(skill: skill.id, campaign: skilldisplay_campaign)}
- {sd:verification.url(skillSet: skillSet.id)}
+ {sd:verification.url(skillSet: skillSet.id, campaign: skilldisplay_campaign)}
expected HTML
'); + $link->getVerificationButton('self', 10, Link::SKILL, 0)->willReturn('expected HTML
'); GeneralUtility::addInstance(Link::class, $link->reveal()); $result = ButtonViewHelper::renderStatic( [ 'skill' => 10, 'type' => 'self', + 'campaign' => 0, ], function () { }, @@ -101,14 +108,16 @@ class ButtonViewHelperTest extends TestCase public function returnsRenderedButtonForSkillSet(): void { $renderingContext = $this->prophesize(RenderingContextInterface::class); + /** @var Link|ObjectProphecy $link */ $link = $this->prophesize(Link::class); - $link->getVerificationButton('self', 10, Link::SKILL_SET)->willReturn('expected HTML
'); + $link->getVerificationButton('self', 10, Link::SKILL_SET, 0)->willReturn('expected HTML
'); GeneralUtility::addInstance(Link::class, $link->reveal()); $result = ButtonViewHelper::renderStatic( [ 'skillSet' => 10, 'type' => 'self', + 'campaign' => 0, ], function () { }, diff --git a/Tests/Unit/ViewHelpers/Verification/UrlViewHelperTest.php b/Tests/Unit/ViewHelpers/Verification/UrlViewHelperTest.php index 70b198a..a98ea0c 100644 --- a/Tests/Unit/ViewHelpers/Verification/UrlViewHelperTest.php +++ b/Tests/Unit/ViewHelpers/Verification/UrlViewHelperTest.php @@ -21,6 +21,8 @@ namespace SkillDisplay\Typo3Extension\Tests\Unit\ViewHelpers\Verification; * 02110-1301, USA. */ +use Prophecy\PhpUnit\ProphecyTrait; +use Prophecy\Prophecy\ObjectProphecy; use SkillDisplay\PHPToolKit\Verification\Link; use SkillDisplay\Typo3Extension\ViewHelpers\Verification\UrlViewHelper; use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; @@ -33,6 +35,8 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase; */ class UrlViewHelperTest extends TestCase { + use ProphecyTrait; + /** * @test */ @@ -47,6 +51,7 @@ class UrlViewHelperTest extends TestCase [ 'skill' => 10, 'skillSet' => 10, + 'campaign' => 0, ], function () { }, @@ -79,14 +84,17 @@ class UrlViewHelperTest extends TestCase public function returnsRenderedUrlForSkill(): void { $renderingContext = $this->prophesize(RenderingContextInterface::class); + /** @var Link|ObjectProphecy $link */ $link = $this->prophesize(Link::class); - $link->getVerificationLink('self', 10, Link::SKILL)->willReturn('https://example.com/path/to/verification'); + $link->getVerificationLink('self', 10, Link::SKILL, 0) + ->willReturn('https://example.com/path/to/verification'); GeneralUtility::addInstance(Link::class, $link->reveal()); $result = UrlViewHelper::renderStatic( [ 'skill' => 10, 'type' => 'self', + 'campaign' => 0, ], function () { }, @@ -101,14 +109,17 @@ class UrlViewHelperTest extends TestCase public function returnsRenderedUrlForSkillSet(): void { $renderingContext = $this->prophesize(RenderingContextInterface::class); + /** @var Link|ObjectProphecy $link */ $link = $this->prophesize(Link::class); - $link->getVerificationLink('self', 10, Link::SKILL_SET)->willReturn('https://example.com/path/to/verification'); + $link->getVerificationLink('self', 10, Link::SKILL_SET, 0) + ->willReturn('https://example.com/path/to/verification'); GeneralUtility::addInstance(Link::class, $link->reveal()); $result = UrlViewHelper::renderStatic( [ 'skillSet' => 10, 'type' => 'self', + 'campaign' => 0, ], function () { }, diff --git a/composer.json b/composer.json index e0a4de5..a421078 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ "require": { "php": "7.2.* || 7.3.* || 7.4.*", "typo3/cms-core": "^10.4", - "skilldisplay/phptoolkit": "^1.1", + "skilldisplay/phptoolkit": "^1.2", "typo3/cms-backend": "^10.4", "typo3/cms-frontend": "^10.4", "typo3fluid/fluid": "^2.6" @@ -41,6 +41,7 @@ "saschaegerer/phpstan-typo3": "^0.13.1", "sensiolabs/security-checker": "^6.0", "typo3/testing-framework": "^6.4", + "phpspec/prophecy-phpunit": "^2", "jangregor/phpstan-prophecy": "^0.8.0" }, "minimum-stability": "dev", diff --git a/ext_emconf.php b/ext_emconf.php index b0024a4..99e39de 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -14,7 +14,7 @@ $EM_CONF[$_EXTKEY] = [ 'version' => '0.1.0', 'constraints' => [ 'depends' => [ - 'core' => '', + 'typo3' => '10.4.0-10.4.99', ], 'conflicts' => [], 'suggests' => [],