diff --git a/Classes/Service/VariablesService.php b/Classes/Service/VariablesService.php index e7cb415..34ce3fe 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(); @@ -136,10 +144,12 @@ 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']; } + $pids = array_unique(array_merge($pids, $this->variablesStoragePids)); + $table = 'tx_variables_marker'; $rows = $this->typoScriptFrontendController->cObj->getRecords( $table,