Php 如何使用已解析的打字脚本覆盖表单默认值

Php 如何使用已解析的打字脚本覆盖表单默认值,php,forms,typo3,hook,typoscript,Php,Forms,Typo3,Hook,Typoscript,我创建了一个钩子(在BuildingFinished之后使用一个函数),它获取一个字符串并将其解析为打字脚本。 现在我想用这个打字脚本覆盖表单(yaml)的默认值。我不明白如何“处理”打字稿。比如,我在分析打字稿后错过了这一步 这是我代码的一部分: public function afterBuildingFinished(RenderableInterface $renderable): void { #some code here ... #My parsing code :

我创建了一个钩子(在BuildingFinished之后使用一个函数
),它获取一个字符串并将其解析为打字脚本。
现在我想用这个打字脚本覆盖表单(yaml)的默认值。我不明白如何“处理”打字稿。比如,我在分析打字稿后错过了这一步

这是我代码的一部分:

public function afterBuildingFinished(RenderableInterface $renderable): void {

   #some code here ...

   #My parsing code :
   $parseObj = GeneralUtility::makeInstance(TypoScriptParser::class);
   $parseObj->parse($stringToParse);
   $TSparse = $parseObj->setup; #this is use to access the parse typoscript

   #Now, what do I do after?
}
我的目的是通过打字脚本字符串,用用户信息预先填充表单的可渲染部分


谢谢。

我弄明白了,需要修改一下代码

这是新的:

public function afterBuildingFinished(RenderableInterface $renderable): void {

   #some code here ...

   #My parsing code :
   $parseObj = GeneralUtility::makeInstance(TypoScriptParser::class);
   $parseObj->parse($stringToParse);

   #This process the typoscript
   #$value stock user info for a X renderable
   $cObject =  GeneralUtility::makeInstance(ObjectManager::class)->get(ContentObjectRenderer::class);
   $value = $cObject->cObjGet($parseObj->setup);

   #Some code to set the default value of the renderable
}

回答我的问题:在解析代码后,我需要使用经典的setDefaultValue()函数处理打字脚本,然后设置可渲染文件的默认值。

我找到了答案,需要对代码进行一些更改

这是新的:

public function afterBuildingFinished(RenderableInterface $renderable): void {

   #some code here ...

   #My parsing code :
   $parseObj = GeneralUtility::makeInstance(TypoScriptParser::class);
   $parseObj->parse($stringToParse);

   #This process the typoscript
   #$value stock user info for a X renderable
   $cObject =  GeneralUtility::makeInstance(ObjectManager::class)->get(ContentObjectRenderer::class);
   $value = $cObject->cObjGet($parseObj->setup);

   #Some code to set the default value of the renderable
}
回答我的问题:在解析代码之后,我需要使用经典的setDefaultValue()函数处理打字脚本,然后设置renderable的默认值