由于 TYPO3 本身不支持后端自定义功能切换,因此我想为此构建自己的实现。 我查看了 ConfigurationManager.php,它在顶部的评论中写道: '此类仅供内部核心使用。
但是如果我现在尝试在我的操作中编辑全局变量: $GLOBALS['TYPO3_CONF_VARS']['SYS']['features'][$feature] = !$GLOBALS['TYPO3_CONF_VARS']['SYS']['features'][$feature]; 该值只会在短时间内发生变化,在我重新加载页面后,该值会再次重置。
我是否遗漏了什么,或者还有其他我可以追求的价值吗?
用这个编辑你的打字稿
plugin.tx_myextension {
settings {
enableFeature = 1
}
}
你的文件.php
$featureToggle = $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_myextension.']['settings.']['enableFeature'];
// ext_localconf.php
$featureToggle = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Configuration\ExtensionConfiguration::class)
->get('myextension')['enableFeature'];
if ($featureToggle) {
// Your feature is enabled
} else {
// Your feature is disabled
}