Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion Classes/Service/VariablesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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,
Expand Down