From 8e46c143ce137b8aacd3e827c573ea58b6450b34 Mon Sep 17 00:00:00 2001 From: Markus Klein Date: Fri, 29 Jan 2021 16:40:15 +0100 Subject: [PATCH] [BUGFIX] Cope with negative PID when adding new CEs Resolves: #11 --- Classes/TcaEnhancer.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/Classes/TcaEnhancer.php b/Classes/TcaEnhancer.php index 76302f2..8de0175 100644 --- a/Classes/TcaEnhancer.php +++ b/Classes/TcaEnhancer.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace SkillDisplay\SkilldisplayContent; use SkillDisplay\PHPToolKit\Entity\Campaign; +use TYPO3\CMS\Backend\Utility\BackendUtility; class TcaEnhancer { @@ -25,15 +26,16 @@ class TcaEnhancer ['', 0], ]; - $campaigns = $this->campaignsFactory - ->createFromPageUid($params['row']['pid']) - ->getForUser(); - /** @var Campaign $campaign */ - foreach ($campaigns as $campaign) { - $params['items'][] = [ - $campaign->getTitle(), - $campaign->getId(), - ]; + $pid = BackendUtility::getTSconfig_pidValue('tt_content', $params['row']['uid'], $params['row']['pid']); + if ($pid > 0) { + $campaigns = $this->campaignsFactory->createFromPageUid($pid)->getForUser(); + /** @var Campaign $campaign */ + foreach ($campaigns as $campaign) { + $params['items'][] = [ + $campaign->getTitle(), + $campaign->getId(), + ]; + } } } }