mirror of
https://github.com/SkillDisplay/TYPO3ContentElements.git
synced 2024-11-24 20:06:10 +01:00
Daniel Siepmann
01d25e4c49
Content elements could not be created, since they needed campaigns. In order to retrieve campaigns, the API needs to be created. The API needs settings from current site, which is not available in that context. Therefore the factory is extended to also fetch site and their settings based on page uid. The page uid is available in the context. Since we now interact with guzzle, we add the dependency. Wouldn't be necessary if SDK would have PSR compatible type hints. Also tests were added for code, to keep code coverage. Fixes: #5
39 lines
843 B
PHP
39 lines
843 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace SkillDisplay\Typo3Extension;
|
|
|
|
use SkillDisplay\PHPToolKit\Entity\Campaign;
|
|
|
|
class TcaEnhancer
|
|
{
|
|
/**
|
|
* @var CampaignsFactory
|
|
*/
|
|
private $campaignsFactory;
|
|
|
|
public function __construct(
|
|
CampaignsFactory $campaignsFactory
|
|
) {
|
|
$this->campaignsFactory = $campaignsFactory;
|
|
}
|
|
|
|
public function getCampaignsForTCA(array &$params): void
|
|
{
|
|
$params['items'] = [
|
|
['', 0],
|
|
];
|
|
|
|
$campaigns = $this->campaignsFactory
|
|
->createFromPageUid($params['row']['pid'])
|
|
->getForUser();
|
|
/** @var Campaign $campaign */
|
|
foreach ($campaigns as $campaign) {
|
|
$params['items'][] = [
|
|
$campaign->getTitle(),
|
|
$campaign->getId(),
|
|
];
|
|
}
|
|
}
|
|
}
|