From 1aa75b7a3dd93f25501086ec3bf91dcada6ab81b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20L=C3=B6rtscher?= Date: Wed, 12 Mar 2025 15:01:02 +0100 Subject: [PATCH 1/2] feat: Allow submission of storagePids --- Classes/Service/VariablesService.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Classes/Service/VariablesService.php b/Classes/Service/VariablesService.php index e7cb415..aca14c4 100644 --- a/Classes/Service/VariablesService.php +++ b/Classes/Service/VariablesService.php @@ -21,6 +21,8 @@ class VariablesService protected Set $cacheTags; protected array $usedMarkerKeys = []; + protected array $variablesStoragePids = []; + protected ?ExtensionConfiguration $extensionConfiguration = null; protected ?TypoScriptFrontendController $typoScriptFrontendController = null; protected ?MarkerCollection $markerCollection = null; @@ -35,6 +37,7 @@ public function __construct() public function initialize( ExtensionConfiguration $extensionConfiguration = null, TypoScriptFrontendController $typoScriptFrontendController = null, + $variablesStoragePids = [], ): void { if (!$typoScriptFrontendController instanceof \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController) { $typoScriptFrontendController = $this->getTypoScriptFrontendController(); @@ -44,6 +47,11 @@ public function initialize( $extensionConfiguration = GeneralUtility::makeInstance(ExtensionConfiguration::class); } + // Define the location of the variable records (useful in APIs) + if (count($variablesStoragePids) > 0) { + $this->variablesStoragePids = $variablesStoragePids; + } + $this->extensionConfiguration = $extensionConfiguration; $this->typoScriptFrontendController = $typoScriptFrontendController; $this->markerCollection = $this->getMarkers(); @@ -140,6 +148,8 @@ protected function getMarkers(): MarkerCollection $pids[] = (int)$GLOBALS['TYPO3_REQUEST']->getAttribute('frontend.typoscript')->getSetupArray()['plugin.']['tx_variables.']['persistence.']['storagePid']; } + $pids = array_unique(array_merge($pids, $this->variablesStoragePids)); + $table = 'tx_variables_marker'; $rows = $this->typoScriptFrontendController->cObj->getRecords( $table, From 496d817dacf2db8881fb9adb6796fbbd8fc63b5e Mon Sep 17 00:00:00 2001 From: Daniel Huf Date: Wed, 7 May 2025 18:08:09 +0200 Subject: [PATCH 2/2] fix: empty request --- Classes/Service/VariablesService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Classes/Service/VariablesService.php b/Classes/Service/VariablesService.php index aca14c4..34ce3fe 100644 --- a/Classes/Service/VariablesService.php +++ b/Classes/Service/VariablesService.php @@ -144,7 +144,7 @@ protected function getMarkers(): MarkerCollection return $page['uid']; }, $this->typoScriptFrontendController->rootLine); - if (!empty($GLOBALS['TYPO3_REQUEST']->getAttribute('frontend.typoscript')->getSetupArray()['plugin.']['tx_variables.']['persistence.']['storagePid'])) { + if (!empty($GLOBALS['TYPO3_REQUEST']->getAttribute('frontend.typoscript')?->getSetupArray()['plugin.']['tx_variables.']['persistence.']['storagePid'])) { $pids[] = (int)$GLOBALS['TYPO3_REQUEST']->getAttribute('frontend.typoscript')->getSetupArray()['plugin.']['tx_variables.']['persistence.']['storagePid']; }