From 40e322485e0cd5e2ee1ec8d44088c4aac577cc52 Mon Sep 17 00:00:00 2001 From: Markus Klein Date: Fri, 27 Nov 2020 22:54:07 +0100 Subject: [PATCH 1/2] [FEATURE] Add campaign to viewhelpers --- Classes/ViewHelpers/Verification/ButtonViewHelper.php | 3 ++- Classes/ViewHelpers/Verification/UrlViewHelper.php | 3 ++- Classes/ViewHelpers/VerificationViewHelper.php | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) 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( From 5d5c502794196267e00176037ad5c26a5250df8b Mon Sep 17 00:00:00 2001 From: Markus Klein Date: Fri, 27 Nov 2020 23:10:46 +0100 Subject: [PATCH 2/2] [FEATURE] Add campaign selection to content elements --- Classes/TcaEnhancer.php | 28 +++++++++++++++++++ Configuration/Services.yaml | 4 +++ Configuration/TCA/Overrides/tt_content.php | 9 ++++++ .../TCA/Overrides/tt_content_skills.php | 1 + .../TCA/Overrides/tt_content_skillset.php | 1 + .../Backend/ContentElements/Skills.html | 2 +- .../Backend/ContentElements/Skillset.html | 2 +- .../ContentElements/SkillDisplaySkillSet.html | 2 +- .../ContentElements/SkillDisplaySkills.html | 2 +- Tests/Unit/Backend/PreviewTest.php | 3 ++ .../Frontend/DataProcessing/SkillSetsTest.php | 3 ++ .../Frontend/DataProcessing/SkillsTest.php | 3 ++ Tests/Unit/SettingsFactoryTest.php | 3 ++ .../Verification/ButtonViewHelperTest.php | 13 +++++++-- .../Verification/UrlViewHelperTest.php | 15 ++++++++-- composer.json | 3 +- ext_emconf.php | 2 +- 17 files changed, 86 insertions(+), 10 deletions(-) create mode 100644 Classes/TcaEnhancer.php 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/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 @@ {skill.title}
- {sd:verification.url(skill: skill.id)} + {sd:verification.url(skill: skill.id, campaign: skilldisplay_campaign)}
diff --git a/Resources/Private/Templates/Backend/ContentElements/Skillset.html b/Resources/Private/Templates/Backend/ContentElements/Skillset.html index d5b44f6..b8da6e0 100644 --- a/Resources/Private/Templates/Backend/ContentElements/Skillset.html +++ b/Resources/Private/Templates/Backend/ContentElements/Skillset.html @@ -16,7 +16,7 @@ {skillSet.title}
- {sd:verification.url(skillSet: skillSet.id)} + {sd:verification.url(skillSet: skillSet.id, campaign: skilldisplay_campaign)}
diff --git a/Resources/Private/Templates/ContentElements/SkillDisplaySkillSet.html b/Resources/Private/Templates/ContentElements/SkillDisplaySkillSet.html index be17c61..1bf4430 100644 --- a/Resources/Private/Templates/ContentElements/SkillDisplaySkillSet.html +++ b/Resources/Private/Templates/ContentElements/SkillDisplaySkillSet.html @@ -7,7 +7,7 @@ count: '{skillSet.skills -> f:count()}', detailUrl: 'https://my.skilldisplay.eu/skillset/{skillSet.id}', brandLogoUrl: skillSet.brand.logoPublicUrl, - verificationUrl: '{sd:verification.url(skillSet: skillSet.id)}', + verificationUrl: '{sd:verification.url(skillSet: skillSet.id, campaign: data.skilldisplay_campaign)}', description: skillSet.description })} diff --git a/Resources/Private/Templates/ContentElements/SkillDisplaySkills.html b/Resources/Private/Templates/ContentElements/SkillDisplaySkills.html index b8fcdb5..fc91724 100644 --- a/Resources/Private/Templates/ContentElements/SkillDisplaySkills.html +++ b/Resources/Private/Templates/ContentElements/SkillDisplaySkills.html @@ -6,7 +6,7 @@ title: skill.title, detailUrl: 'https://my.skilldisplay.eu/skill/{skill.id}/0', brandLogoUrl: skill.brands.0.logoPublicUrl, - verificationUrl: '{sd:verification.url(skill: skill.id)}', + verificationUrl: '{sd:verification.url(skill: skill.id, campaign: data.skilldisplay_campaign)}', description: skill.description })} diff --git a/Tests/Unit/Backend/PreviewTest.php b/Tests/Unit/Backend/PreviewTest.php index c08aae1..f4b6d7e 100644 --- a/Tests/Unit/Backend/PreviewTest.php +++ b/Tests/Unit/Backend/PreviewTest.php @@ -21,6 +21,7 @@ namespace SkillDisplay\Typo3Extension\Tests\Unit\Backend; * 02110-1301, USA. */ +use Prophecy\PhpUnit\ProphecyTrait; use SkillDisplay\PHPToolKit\Api\Skill; use SkillDisplay\PHPToolKit\Api\SkillSet; use SkillDisplay\PHPToolKit\Entity\Skill as SkillEntity; @@ -34,6 +35,8 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase; */ class PreviewTest extends TestCase { + use ProphecyTrait; + /** * @test */ diff --git a/Tests/Unit/Frontend/DataProcessing/SkillSetsTest.php b/Tests/Unit/Frontend/DataProcessing/SkillSetsTest.php index aa945ca..b3c4b92 100644 --- a/Tests/Unit/Frontend/DataProcessing/SkillSetsTest.php +++ b/Tests/Unit/Frontend/DataProcessing/SkillSetsTest.php @@ -21,6 +21,7 @@ namespace SkillDisplay\Typo3Extension\Tests\Unit\Frontend\DataProcessing; * 02110-1301, USA. */ +use Prophecy\PhpUnit\ProphecyTrait; use SkillDisplay\PHPToolKit\Api\SkillSet; use SkillDisplay\PHPToolKit\Entity\SkillSet as SkillSetEntity; use SkillDisplay\Typo3Extension\Frontend\DataProcessing\SkillSets; @@ -32,6 +33,8 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase; */ class SkillSetsTest extends TestCase { + use ProphecyTrait; + /** * @test */ diff --git a/Tests/Unit/Frontend/DataProcessing/SkillsTest.php b/Tests/Unit/Frontend/DataProcessing/SkillsTest.php index cb89e14..dcdc0b7 100644 --- a/Tests/Unit/Frontend/DataProcessing/SkillsTest.php +++ b/Tests/Unit/Frontend/DataProcessing/SkillsTest.php @@ -21,6 +21,7 @@ namespace SkillDisplay\Typo3Extension\Tests\Unit\Frontend\DataProcessing; * 02110-1301, USA. */ +use Prophecy\PhpUnit\ProphecyTrait; use SkillDisplay\PHPToolKit\Api\Skill; use SkillDisplay\PHPToolKit\Entity\Skill as SkillEntity; use SkillDisplay\Typo3Extension\Frontend\DataProcessing\Skills; @@ -32,6 +33,8 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase; */ class SkillsTest extends TestCase { + use ProphecyTrait; + /** * @test */ diff --git a/Tests/Unit/SettingsFactoryTest.php b/Tests/Unit/SettingsFactoryTest.php index 7fed8cc..1422692 100644 --- a/Tests/Unit/SettingsFactoryTest.php +++ b/Tests/Unit/SettingsFactoryTest.php @@ -21,6 +21,7 @@ namespace SkillDisplay\Typo3Extension\Tests\Unit; * 02110-1301, USA. */ +use Prophecy\PhpUnit\ProphecyTrait; use SkillDisplay\PHPToolKit\Configuration\Settings; use SkillDisplay\Typo3Extension\SettingsFactory; use TYPO3\CMS\Core\Http\ServerRequest; @@ -32,6 +33,8 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase; */ class SettingsFactoryTest extends TestCase { + use ProphecyTrait; + /** * @test */ diff --git a/Tests/Unit/ViewHelpers/Verification/ButtonViewHelperTest.php b/Tests/Unit/ViewHelpers/Verification/ButtonViewHelperTest.php index e92c712..1d3b49d 100644 --- a/Tests/Unit/ViewHelpers/Verification/ButtonViewHelperTest.php +++ b/Tests/Unit/ViewHelpers/Verification/ButtonViewHelperTest.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\ButtonViewHelper; use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; @@ -33,6 +35,8 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase; */ class ButtonViewHelperTest extends TestCase { + use ProphecyTrait; + /** * @test */ @@ -47,6 +51,7 @@ class ButtonViewHelperTest extends TestCase [ 'skill' => 10, 'skillSet' => 10, + 'campaign' => 0, ], function () { }, @@ -79,14 +84,16 @@ class ButtonViewHelperTest extends TestCase public function returnsRenderedButtonForSkill(): void { $renderingContext = $this->prophesize(RenderingContextInterface::class); + /** @var Link|ObjectProphecy $link */ $link = $this->prophesize(Link::class); - $link->getVerificationButton('self', 10, Link::SKILL)->willReturn('

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' => [],