mirror of
https://github.com/SkillDisplay/TYPO3ContentElements.git
synced 2024-12-22 06:16:09 +01:00
Merge pull request #3 from SkillDisplay/feature/campaign-integration
Integrate campaign selection for verification tracking
This commit is contained in:
commit
ce53a9ab6e
20 changed files with 91 additions and 12 deletions
28
Classes/TcaEnhancer.php
Normal file
28
Classes/TcaEnhancer.php
Normal 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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
|
@ -34,7 +34,8 @@ class ButtonViewHelper extends VerificationViewHelper
|
|||
return $link->getVerificationButton(
|
||||
$arguments['type'],
|
||||
static::getId($arguments),
|
||||
static::getType($arguments)
|
||||
static::getType($arguments),
|
||||
$arguments['campaign']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,8 @@ class UrlViewHelper extends VerificationViewHelper
|
|||
return $link->getVerificationLink(
|
||||
$arguments['type'],
|
||||
static::getId($arguments),
|
||||
static::getType($arguments)
|
||||
static::getType($arguments),
|
||||
$arguments['campaign']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -28,6 +28,10 @@ services:
|
|||
arguments:
|
||||
$settings: '@skilldisplay.settings'
|
||||
|
||||
SkillDisplay\PHPToolKit\Api\Campaigns:
|
||||
arguments:
|
||||
$settings: '@skilldisplay.settings'
|
||||
|
||||
SkillDisplay\PHPToolKit\Verification\Link:
|
||||
public: true
|
||||
arguments:
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
</f:then>
|
||||
<f:else>
|
||||
<strong>{skill.title}</strong><br>
|
||||
{sd:verification.url(skill: skill.id)}
|
||||
{sd:verification.url(skill: skill.id, campaign: skilldisplay_campaign)}
|
||||
</f:else>
|
||||
</f:if>
|
||||
</li>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
</f:then>
|
||||
<f:else>
|
||||
<strong>{skillSet.title}</strong><br>
|
||||
{sd:verification.url(skillSet: skillSet.id)}
|
||||
{sd:verification.url(skillSet: skillSet.id, campaign: skilldisplay_campaign)}
|
||||
</f:else>
|
||||
</f:if>
|
||||
</li>
|
||||
|
|
|
@ -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
|
||||
})}
|
||||
</f:for>
|
||||
|
|
|
@ -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
|
||||
})}
|
||||
</f:for>
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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('<p>expected HTML</p>');
|
||||
$link->getVerificationButton('self', 10, Link::SKILL, 0)->willReturn('<p>expected HTML</p>');
|
||||
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('<p>expected HTML</p>');
|
||||
$link->getVerificationButton('self', 10, Link::SKILL_SET, 0)->willReturn('<p>expected HTML</p>');
|
||||
GeneralUtility::addInstance(Link::class, $link->reveal());
|
||||
|
||||
$result = ButtonViewHelper::renderStatic(
|
||||
[
|
||||
'skillSet' => 10,
|
||||
'type' => 'self',
|
||||
'campaign' => 0,
|
||||
],
|
||||
function () {
|
||||
},
|
||||
|
|
|
@ -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 () {
|
||||
},
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -14,7 +14,7 @@ $EM_CONF[$_EXTKEY] = [
|
|||
'version' => '0.1.0',
|
||||
'constraints' => [
|
||||
'depends' => [
|
||||
'core' => '',
|
||||
'typo3' => '10.4.0-10.4.99',
|
||||
],
|
||||
'conflicts' => [],
|
||||
'suggests' => [],
|
||||
|
|
Loading…
Reference in a new issue