Merge pull request #3 from SkillDisplay/feature/campaign-integration

Integrate campaign selection for verification tracking
This commit is contained in:
Markus Klein 2020-12-01 13:42:10 +01:00 committed by GitHub
commit ce53a9ab6e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 91 additions and 12 deletions

28
Classes/TcaEnhancer.php Normal file
View file

@ -0,0 +1,28 @@
<?php
declare(strict_types=1);
namespace SkillDisplay\Typo3Extension;
use SkillDisplay\PHPToolKit\Api\Campaigns;
use SkillDisplay\PHPToolKit\Entity\Campaign;
use TYPO3\CMS\Core\Utility\GeneralUtility;
class TcaEnhancer
{
public function getCampaignsForTCA(array $params): void
{
$params['items'] = [
['', 0],
];
$campaigns = GeneralUtility::makeInstance(Campaigns::class)->getForUser();
/** @var Campaign $campaign */
foreach ($campaigns as $campaign) {
$params['items'][] = [
$campaign->getTitle(),
$campaign->getId(),
];
}
}
}

View file

@ -34,7 +34,8 @@ class ButtonViewHelper extends VerificationViewHelper
return $link->getVerificationButton( return $link->getVerificationButton(
$arguments['type'], $arguments['type'],
static::getId($arguments), static::getId($arguments),
static::getType($arguments) static::getType($arguments),
$arguments['campaign']
); );
} }
} }

View file

@ -34,7 +34,8 @@ class UrlViewHelper extends VerificationViewHelper
return $link->getVerificationLink( return $link->getVerificationLink(
$arguments['type'], $arguments['type'],
static::getId($arguments), static::getId($arguments),
static::getType($arguments) static::getType($arguments),
$arguments['campaign']
); );
} }
} }

View file

@ -38,6 +38,7 @@ abstract class VerificationViewHelper extends AbstractViewHelper
$this->registerArgument('skill', 'integer', 'ID of the Skill.'); $this->registerArgument('skill', 'integer', 'ID of the Skill.');
$this->registerArgument('skillSet', 'integer', 'ID of the SkillSet.'); $this->registerArgument('skillSet', 'integer', 'ID of the SkillSet.');
$this->registerArgument('type', 'string', 'Type of verification', false, 'self'); $this->registerArgument('type', 'string', 'Type of verification', false, 'self');
$this->registerArgument('campaign', 'int', 'ID of campaign', false, 0);
} }
public static function renderStatic( public static function renderStatic(

View file

@ -28,6 +28,10 @@ services:
arguments: arguments:
$settings: '@skilldisplay.settings' $settings: '@skilldisplay.settings'
SkillDisplay\PHPToolKit\Api\Campaigns:
arguments:
$settings: '@skilldisplay.settings'
SkillDisplay\PHPToolKit\Verification\Link: SkillDisplay\PHPToolKit\Verification\Link:
public: true public: true
arguments: arguments:

View file

@ -32,6 +32,15 @@
'size' => 10, 'size' => 10,
], ],
], ],
'skilldisplay_campaign' => [
'label' => $languagePath . 'skilldisplay_campaign',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'itemsProcFunc' => \SkillDisplay\Typo3Extension\TcaEnhancer::class . '->' . 'getCampaignsForTCA',
'items' => []
]
],
], ],
]); ]);
})('skilldisplay', 'tt_content'); })('skilldisplay', 'tt_content');

View file

@ -15,6 +15,7 @@
'--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general', '--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general',
'--palette--;;general', '--palette--;;general',
'skilldisplay_skills', 'skilldisplay_skills',
'skilldisplay_campaign',
'--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.appearance', '--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.appearance',
'--palette--;;frames', '--palette--;;frames',
'--palette--;;appearanceLinks', '--palette--;;appearanceLinks',

View file

@ -15,6 +15,7 @@
'--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general', '--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general',
'--palette--;;general', '--palette--;;general',
'skilldisplay_skillset', 'skilldisplay_skillset',
'skilldisplay_campaign',
'--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.appearance', '--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.appearance',
'--palette--;;frames', '--palette--;;frames',
'--palette--;;appearanceLinks', '--palette--;;appearanceLinks',

View file

@ -16,7 +16,7 @@
</f:then> </f:then>
<f:else> <f:else>
<strong>{skill.title}</strong><br> <strong>{skill.title}</strong><br>
{sd:verification.url(skill: skill.id)} {sd:verification.url(skill: skill.id, campaign: skilldisplay_campaign)}
</f:else> </f:else>
</f:if> </f:if>
</li> </li>

View file

@ -16,7 +16,7 @@
</f:then> </f:then>
<f:else> <f:else>
<strong>{skillSet.title}</strong><br> <strong>{skillSet.title}</strong><br>
{sd:verification.url(skillSet: skillSet.id)} {sd:verification.url(skillSet: skillSet.id, campaign: skilldisplay_campaign)}
</f:else> </f:else>
</f:if> </f:if>
</li> </li>

View file

@ -7,7 +7,7 @@
count: '{skillSet.skills -> f:count()}', count: '{skillSet.skills -> f:count()}',
detailUrl: 'https://my.skilldisplay.eu/skillset/{skillSet.id}', detailUrl: 'https://my.skilldisplay.eu/skillset/{skillSet.id}',
brandLogoUrl: skillSet.brand.logoPublicUrl, 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 description: skillSet.description
})} })}
</f:for> </f:for>

View file

@ -6,7 +6,7 @@
title: skill.title, title: skill.title,
detailUrl: 'https://my.skilldisplay.eu/skill/{skill.id}/0', detailUrl: 'https://my.skilldisplay.eu/skill/{skill.id}/0',
brandLogoUrl: skill.brands.0.logoPublicUrl, 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 description: skill.description
})} })}
</f:for> </f:for>

View file

@ -21,6 +21,7 @@ namespace SkillDisplay\Typo3Extension\Tests\Unit\Backend;
* 02110-1301, USA. * 02110-1301, USA.
*/ */
use Prophecy\PhpUnit\ProphecyTrait;
use SkillDisplay\PHPToolKit\Api\Skill; use SkillDisplay\PHPToolKit\Api\Skill;
use SkillDisplay\PHPToolKit\Api\SkillSet; use SkillDisplay\PHPToolKit\Api\SkillSet;
use SkillDisplay\PHPToolKit\Entity\Skill as SkillEntity; use SkillDisplay\PHPToolKit\Entity\Skill as SkillEntity;
@ -34,6 +35,8 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase;
*/ */
class PreviewTest extends TestCase class PreviewTest extends TestCase
{ {
use ProphecyTrait;
/** /**
* @test * @test
*/ */

View file

@ -21,6 +21,7 @@ namespace SkillDisplay\Typo3Extension\Tests\Unit\Frontend\DataProcessing;
* 02110-1301, USA. * 02110-1301, USA.
*/ */
use Prophecy\PhpUnit\ProphecyTrait;
use SkillDisplay\PHPToolKit\Api\SkillSet; use SkillDisplay\PHPToolKit\Api\SkillSet;
use SkillDisplay\PHPToolKit\Entity\SkillSet as SkillSetEntity; use SkillDisplay\PHPToolKit\Entity\SkillSet as SkillSetEntity;
use SkillDisplay\Typo3Extension\Frontend\DataProcessing\SkillSets; use SkillDisplay\Typo3Extension\Frontend\DataProcessing\SkillSets;
@ -32,6 +33,8 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase;
*/ */
class SkillSetsTest extends TestCase class SkillSetsTest extends TestCase
{ {
use ProphecyTrait;
/** /**
* @test * @test
*/ */

View file

@ -21,6 +21,7 @@ namespace SkillDisplay\Typo3Extension\Tests\Unit\Frontend\DataProcessing;
* 02110-1301, USA. * 02110-1301, USA.
*/ */
use Prophecy\PhpUnit\ProphecyTrait;
use SkillDisplay\PHPToolKit\Api\Skill; use SkillDisplay\PHPToolKit\Api\Skill;
use SkillDisplay\PHPToolKit\Entity\Skill as SkillEntity; use SkillDisplay\PHPToolKit\Entity\Skill as SkillEntity;
use SkillDisplay\Typo3Extension\Frontend\DataProcessing\Skills; use SkillDisplay\Typo3Extension\Frontend\DataProcessing\Skills;
@ -32,6 +33,8 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase;
*/ */
class SkillsTest extends TestCase class SkillsTest extends TestCase
{ {
use ProphecyTrait;
/** /**
* @test * @test
*/ */

View file

@ -21,6 +21,7 @@ namespace SkillDisplay\Typo3Extension\Tests\Unit;
* 02110-1301, USA. * 02110-1301, USA.
*/ */
use Prophecy\PhpUnit\ProphecyTrait;
use SkillDisplay\PHPToolKit\Configuration\Settings; use SkillDisplay\PHPToolKit\Configuration\Settings;
use SkillDisplay\Typo3Extension\SettingsFactory; use SkillDisplay\Typo3Extension\SettingsFactory;
use TYPO3\CMS\Core\Http\ServerRequest; use TYPO3\CMS\Core\Http\ServerRequest;
@ -32,6 +33,8 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase;
*/ */
class SettingsFactoryTest extends TestCase class SettingsFactoryTest extends TestCase
{ {
use ProphecyTrait;
/** /**
* @test * @test
*/ */

View file

@ -21,6 +21,8 @@ namespace SkillDisplay\Typo3Extension\Tests\Unit\ViewHelpers\Verification;
* 02110-1301, USA. * 02110-1301, USA.
*/ */
use Prophecy\PhpUnit\ProphecyTrait;
use Prophecy\Prophecy\ObjectProphecy;
use SkillDisplay\PHPToolKit\Verification\Link; use SkillDisplay\PHPToolKit\Verification\Link;
use SkillDisplay\Typo3Extension\ViewHelpers\Verification\ButtonViewHelper; use SkillDisplay\Typo3Extension\ViewHelpers\Verification\ButtonViewHelper;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
@ -33,6 +35,8 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase;
*/ */
class ButtonViewHelperTest extends TestCase class ButtonViewHelperTest extends TestCase
{ {
use ProphecyTrait;
/** /**
* @test * @test
*/ */
@ -47,6 +51,7 @@ class ButtonViewHelperTest extends TestCase
[ [
'skill' => 10, 'skill' => 10,
'skillSet' => 10, 'skillSet' => 10,
'campaign' => 0,
], ],
function () { function () {
}, },
@ -79,14 +84,16 @@ class ButtonViewHelperTest extends TestCase
public function returnsRenderedButtonForSkill(): void public function returnsRenderedButtonForSkill(): void
{ {
$renderingContext = $this->prophesize(RenderingContextInterface::class); $renderingContext = $this->prophesize(RenderingContextInterface::class);
/** @var Link|ObjectProphecy $link */
$link = $this->prophesize(Link::class); $link = $this->prophesize(Link::class);
$link->getVerificationButton('self', 10, Link::SKILL)->willReturn('<p>expected HTML</p>'); $link->getVerificationButton('self', 10, Link::SKILL, 0)->willReturn('<p>expected HTML</p>');
GeneralUtility::addInstance(Link::class, $link->reveal()); GeneralUtility::addInstance(Link::class, $link->reveal());
$result = ButtonViewHelper::renderStatic( $result = ButtonViewHelper::renderStatic(
[ [
'skill' => 10, 'skill' => 10,
'type' => 'self', 'type' => 'self',
'campaign' => 0,
], ],
function () { function () {
}, },
@ -101,14 +108,16 @@ class ButtonViewHelperTest extends TestCase
public function returnsRenderedButtonForSkillSet(): void public function returnsRenderedButtonForSkillSet(): void
{ {
$renderingContext = $this->prophesize(RenderingContextInterface::class); $renderingContext = $this->prophesize(RenderingContextInterface::class);
/** @var Link|ObjectProphecy $link */
$link = $this->prophesize(Link::class); $link = $this->prophesize(Link::class);
$link->getVerificationButton('self', 10, Link::SKILL_SET)->willReturn('<p>expected HTML</p>'); $link->getVerificationButton('self', 10, Link::SKILL_SET, 0)->willReturn('<p>expected HTML</p>');
GeneralUtility::addInstance(Link::class, $link->reveal()); GeneralUtility::addInstance(Link::class, $link->reveal());
$result = ButtonViewHelper::renderStatic( $result = ButtonViewHelper::renderStatic(
[ [
'skillSet' => 10, 'skillSet' => 10,
'type' => 'self', 'type' => 'self',
'campaign' => 0,
], ],
function () { function () {
}, },

View file

@ -21,6 +21,8 @@ namespace SkillDisplay\Typo3Extension\Tests\Unit\ViewHelpers\Verification;
* 02110-1301, USA. * 02110-1301, USA.
*/ */
use Prophecy\PhpUnit\ProphecyTrait;
use Prophecy\Prophecy\ObjectProphecy;
use SkillDisplay\PHPToolKit\Verification\Link; use SkillDisplay\PHPToolKit\Verification\Link;
use SkillDisplay\Typo3Extension\ViewHelpers\Verification\UrlViewHelper; use SkillDisplay\Typo3Extension\ViewHelpers\Verification\UrlViewHelper;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
@ -33,6 +35,8 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase as TestCase;
*/ */
class UrlViewHelperTest extends TestCase class UrlViewHelperTest extends TestCase
{ {
use ProphecyTrait;
/** /**
* @test * @test
*/ */
@ -47,6 +51,7 @@ class UrlViewHelperTest extends TestCase
[ [
'skill' => 10, 'skill' => 10,
'skillSet' => 10, 'skillSet' => 10,
'campaign' => 0,
], ],
function () { function () {
}, },
@ -79,14 +84,17 @@ class UrlViewHelperTest extends TestCase
public function returnsRenderedUrlForSkill(): void public function returnsRenderedUrlForSkill(): void
{ {
$renderingContext = $this->prophesize(RenderingContextInterface::class); $renderingContext = $this->prophesize(RenderingContextInterface::class);
/** @var Link|ObjectProphecy $link */
$link = $this->prophesize(Link::class); $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()); GeneralUtility::addInstance(Link::class, $link->reveal());
$result = UrlViewHelper::renderStatic( $result = UrlViewHelper::renderStatic(
[ [
'skill' => 10, 'skill' => 10,
'type' => 'self', 'type' => 'self',
'campaign' => 0,
], ],
function () { function () {
}, },
@ -101,14 +109,17 @@ class UrlViewHelperTest extends TestCase
public function returnsRenderedUrlForSkillSet(): void public function returnsRenderedUrlForSkillSet(): void
{ {
$renderingContext = $this->prophesize(RenderingContextInterface::class); $renderingContext = $this->prophesize(RenderingContextInterface::class);
/** @var Link|ObjectProphecy $link */
$link = $this->prophesize(Link::class); $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()); GeneralUtility::addInstance(Link::class, $link->reveal());
$result = UrlViewHelper::renderStatic( $result = UrlViewHelper::renderStatic(
[ [
'skillSet' => 10, 'skillSet' => 10,
'type' => 'self', 'type' => 'self',
'campaign' => 0,
], ],
function () { function () {
}, },

View file

@ -28,7 +28,7 @@
"require": { "require": {
"php": "7.2.* || 7.3.* || 7.4.*", "php": "7.2.* || 7.3.* || 7.4.*",
"typo3/cms-core": "^10.4", "typo3/cms-core": "^10.4",
"skilldisplay/phptoolkit": "^1.1", "skilldisplay/phptoolkit": "^1.2",
"typo3/cms-backend": "^10.4", "typo3/cms-backend": "^10.4",
"typo3/cms-frontend": "^10.4", "typo3/cms-frontend": "^10.4",
"typo3fluid/fluid": "^2.6" "typo3fluid/fluid": "^2.6"
@ -41,6 +41,7 @@
"saschaegerer/phpstan-typo3": "^0.13.1", "saschaegerer/phpstan-typo3": "^0.13.1",
"sensiolabs/security-checker": "^6.0", "sensiolabs/security-checker": "^6.0",
"typo3/testing-framework": "^6.4", "typo3/testing-framework": "^6.4",
"phpspec/prophecy-phpunit": "^2",
"jangregor/phpstan-prophecy": "^0.8.0" "jangregor/phpstan-prophecy": "^0.8.0"
}, },
"minimum-stability": "dev", "minimum-stability": "dev",

View file

@ -14,7 +14,7 @@ $EM_CONF[$_EXTKEY] = [
'version' => '0.1.0', 'version' => '0.1.0',
'constraints' => [ 'constraints' => [
'depends' => [ 'depends' => [
'core' => '', 'typo3' => '10.4.0-10.4.99',
], ],
'conflicts' => [], 'conflicts' => [],
'suggests' => [], 'suggests' => [],