[英]Typo3 7.2 add file reference to extension model
我正在使用Typo 7.2,正在寻找以下问题的答案:
如何以编程方式将生成的文件作为FileReference添加到扩展模型?
首先是有关我的成就/尝试的一些信息。
完成命令控制器在文件夹上运行,查找特定图像,然后通过GraphicFunctions创建模糊文件。 生成的文件作为独立的简单文件添加到存储,并显示在sys_file表中。
$fileObject = $posterStorage->addFile(
$convertResult[3],
$posterStorage->getFolder($blurFolderName),
$newFileName);
部分完成。 现在,我需要将生成的文件添加为对模型的文件引用。 问题是,我能够做到这一点,但是只能通过侵入内核来实现,这是不可接受的,并且无法以正确的方式做到这一点。 模型说:
public function addPosterWebBlur(
\TYPO3\CMS\Extbase\Domain\Model\FileReference $posterWebBlur
) {
$this->posterWebBlur->attach($posterWebBlur);
}
因此,我成功扩展了FileReference类:
class FileReference extends \TYPO3\CMS\Extbase\Domain\Model\FileReference {
public function setFile(\TYPO3\CMS\Core\Resource\File $falFile) {
$this->$uidLocal = (int)$falFile->getUid();
}
}
该参考未建立,我在后端仅得到以下错误:
Table 'db_name.tx_ext_name_domain_model_filereference' doesn't exist.
更新将来自Frans的数据集成到ext_typoscript_setup.txt中后,可以保存模型,创建sys_file_reference条目,并且在后端运行良好。 但是,有几点可以满足所有需求:
您必须告诉extbase持久层使用正确的表。 例如参见以下示例https://github.com/helhum/upload_example/blob/master/ext_typoscript_setup.txt
gr。 弗兰斯
尝试回答1)参见https://github.com/helhum/upload_example/blob/master/Configuration/TCA/tx_uploadexample_domain_model_example.php#L128您可能应该检查posterWebBlur字段的TCA定义。 getFileFieldTCAConfig()TT的第二个参数
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.