hyd*_*cus 2 json controller typo3 extbase
这是我的控制器动作:
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());
}
Run Code Online (Sandbox Code Playgroud)
我得到了一个非常不错的JSON-String。不幸的是,我仅获得包含文件(FAL)的PID和UID。如何获取完整对象或至少包含文件的路径?
/**
* 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;
}
Run Code Online (Sandbox Code Playgroud)
尝试下降到originalResource的FileReference并公开publicUrl:
$this->view->setConfiguration(
array(
'produkte' => array(
'_descendAll' => array(
'only' => array('titel', 'beschreibung', 'bild', 'download', 'categories'),
'_descend' => array(
'download' => array(
'_descendAll' => array(
'_only' => array('originalResource');
'_descend' => array(
'originalResource' => array(
'_only' => array('publicUrl');
);
);
);
),
)
)
)
)
);
Run Code Online (Sandbox Code Playgroud)