Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从控制器更改TYPO3中的全局变量_Typo3_Typo3 9.x - Fatal编程技术网

从控制器更改TYPO3中的全局变量

从控制器更改TYPO3中的全局变量,typo3,typo3-9.x,Typo3,Typo3 9.x,在TYPO3 CMS中,如果要更改日志的保存位置,则需要更改$GLOBALS['TYPO3\u CONF\u VARS']['LOG']['writerConfiguration'],并添加文件位置。嗯,我正在开发一个扩展,允许用户改变这种行为,但问题是我不能在运行时改变它。我的意思是如果我写: $GLOBALS['TYPO3_CONF_VARS']['LOG']['writerConfiguration'] = "some thing new' 在调试过程中,我可以在$GLOBALS中看到它

在TYPO3 CMS中,如果要更改日志的保存位置,则需要更改
$GLOBALS['TYPO3\u CONF\u VARS']['LOG']['writerConfiguration']
,并添加文件位置。嗯,我正在开发一个扩展,允许用户改变这种行为,但问题是我不能在运行时改变它。我的意思是如果我写:

$GLOBALS['TYPO3_CONF_VARS']['LOG']['writerConfiguration'] = "some thing new'
在调试过程中,我可以在$GLOBALS中看到它发生了更改,但在配置后记中不会发生更改。 我记得那里有一个用于更改/添加新配置的函数,但我找不到它。有人能帮忙吗


我正在使用TYPO3 CMS v9.5.5

我想您正在寻找

TYPO3\CMS\Core\Configuration\ConfigurationManager::updateLocalConfiguration()

它可以按如下方式使用:

<?php
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
$configurationManager = $objectManager->get(ConfigurationManagerInterface::class);
$configurationManager->updateLocalConfiguration('...');

的确,我找到了这个。虽然我没有使用,但请阅读类注释:
*重要:*该类仅用于内部核心用途。*扩展通常应该使用生成的$GLOBALS['TYPO3\u CONF\u VARS']数组,*不要尝试使用扩展修改LocalConfiguration.php中的设置。*@内部
是,但如果修改设置是您真正想要做的。。。?或者,您可以使用扩展名
ext_localconf.php
的localconf,只是为了了解我已经改变了我想要如何继续的整个概念,在经过一段时间的挖掘之后,无论如何,即使在ext_localconf中也不可能这样做,因为我想要更改的确切值是['LOG']['writerConfiguration']正如我提到的,我希望这是通过控制器或服务,以便用户可以通过be扩展来更改。答案是正确的,但CMS/框架不鼓励这样做,这意味着它可能会被一些更新搞砸,或者以后会有一些副作用(目前答案是可以接受的,但以后还不清楚,因此我不会把它作为一个可以接受的答案)
<?php
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
$configurationManager = $objectManager->get(ConfigurationManagerInterface::class);
$configurationManager->updateLocalConfiguration('...');