【发布时间】:2016-10-04 15:51:40
【问题描述】:
这是我的控制器动作:
public function jsonAction()
{
$this->view->setVariablesToRender(array('produkte'));
$this->view->setConfiguration(
array(
'produkte' => array(
'_descendAll' => array(
'only' => array('titel', 'beschreibung', 'bild', 'download', 'categories'),
'_descend' => array(
'bild' => array(),
'download' => array(),
'categories' => array(),
)
)
)
)
);
$this->view->assign('produkte', $this->produktRepository->findAll());
}
我得到了一个非常好的 JSON 字符串。不幸的是,我只得到包含文件的 PID 和 UID (FAL)。如何获取完整对象或至少包含文件的路径?
/**
* Returns the bild
*
* @return \TYPO3\CMS\Extbase\Domain\Model\FileReference $bild
*/
public function getBild()
{
return $this->bild;
}
/**
* Returns the download
*
* @return \TYPO3\CMS\Extbase\Domain\Model\FileReference $download
*/
public function getDownload()
{
return $this->download;
}
【问题讨论】:
-
能分享一下Produkt的相关模型零件吗?
-
好的,在上面编辑。希望这是正确的部分。
-
我怀疑这与文件和文件引用对象的属性不是真正的对象属性,而是存储为延迟加载的关联数组(我认为名为@987654324@)有关。
JsonView只处理它可以通过调用get_object_vars(通过调用getGettablePropertyNames())获得的那些,它使用get_object_vars。尝试输出属性properties,也许有帮助?不确定这是否正确。
标签: json controller typo3 extbase