[英]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.