TYPO3 Extbase的storagePid

4
我需要获取实际的“通用记录存储页面ID”。我找到了以下代码片段,但变量为空,即使页面上设置了storagePid。
$config = $this->configurationManager->getConfiguration(Tx_Extbase_Configuration_ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
var_dump($config['persistence']['storagePid']);

任何帮助都将不胜感激。

1个回答

10

我不太确定你想要什么。你提供的代码片段可以在扩展中使用常量设置storagePid,与setup.txt中的代码相同:

plugin.tx_yourext {
    persistence {
        storagePid = {$plugin.tx_yourext.persistence.storagePid}
    }
}

如果你在使用提供的代码片段获取 storagePid 时遇到问题,也可以修改你的setup.txt文件,并确保该值也会传播到settings范围:

plugin.tx_yourext {
    persistence {
        storagePid = {$plugin.tx_yourext.persistence.storagePid}
    }
    settings {
        storagePid = {$plugin.tx_yourext.persistence.storagePid}
    }
}

然后在你的控制器中,你可以使用更简单的代码捕获它:

$myStoragePid = $this->settings['storagePid'];

如果它对你无效,那意味着你没有在Constants中为YourExt设置正确的值和/或没有清除BE中的缓存。

顺便说一下:也许如果你更具体地说明问题,我可以给出更好的答案。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接