我有TYPO3 7.6.18
这是我的代码:
$newVideo = new \Istar\Fefiles\Domain\Model\Video();
$videoName = $video['name'];
$videoTmpName = $video['tmp_name'];
$resourceFactory = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance();
$storage = $resourceFactory->getDefaultStorage();
$folder = $storage->getFolder("user_upload/");
$movedFile = $storage->addFile($videoTmpName, $folder, $videoName);
$newFileReference = $this->objectManager$this->objectManager->get('TYPO3\\CMS\\Extbase\\Domain\\Model\\FileReference');
$newFileReference->setFile($movedFile);
$newVideo->setVideo($newFileReference);
$this->videoRepository->add($newVideo);
$persistenceManager = $this->objectManager->get("TYPO3\\CMS\\Extbase\\Persistence\\Generic\\PersistenceManager");
$persistenceManager->persistAll();
问题是它为现场视频文件引用添加了两个文件。这非常真实!第二个文件是不一样的,它是不同的文件。我确定,我发送一个文件。哪里可能有问题?
我有模特照片,并且有野外图像
'image' => [
'exclude' => 0,
'label' => 'LLL:EXT:fefiles/Resources/Private/Language/locallang_db.xlf:image',
'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig('image', [
'appearance' => [
'createNewRelationLinkTitle' => 'LLL:EXT:cms/locallang_ttc.xlf:images.addFileReference'
],
'maxitems' => 1,
], $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'])
],
Anf我看到当我从BE创建照片并上传图片时 - 这会添加第二张图片,该图片会提前上传到网站上。这很奇怪!怎么了 ?
我的视频模型:
<?php
namespace Istar\Fefiles\Domain\Model;
class Video extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
{
/**
* @var bool
*/
public $allow_for_user = true;
/**
* Title
*
* @var string
* @validate NotEmpty
*/
protected $title = '';
/**
* Description
*
* @var string
*/
protected $description = '';
/**
* rulesDescription
*
* @var string
*/
protected $rulesDescription = '';
/**
* User
*
* @var \Fhk\Feusersplus\Domain\Model\User>
*/
protected $user;
/**
* Videocategory
*
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Istar\Fefiles\Domain\Model\Videocategory>
*/
protected $videocategory;
/**
* Videocomment
*
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Istar\Fefiles\Domain\Model\Videocomment>
* @cascade remove
*/
protected $comment;
/**
* Allow
*
* @var int
*/
protected $allow = 0;
/**
* fskcheck
*
* @var int
*/
protected $fskcheck = 0;
/**
* private
*
* @var int
*/
protected $private = 0;
/**
* Video
* @validate NotEmpty
* @var \TYPO3\CMS\Extbase\Domain\Model\FileReference
* @cascade remove
*/
protected $video;
/**
* preview
*
* @var \TYPO3\CMS\Extbase\Domain\Model\FileReference
* @cascade remove
*/
protected $preview = null;
/**
* blurred
*
* @var \TYPO3\CMS\Extbase\Domain\Model\FileReference
* @cascade remove
*/
protected $blurred = null;
/**
* Crdate
*
* @var int
* @validate NotEmpty
*/
protected $crdate = 0;
/**
* Returns the title
*
* @return string $title
*/
public function getTitle()
{
return $this->title;
}
/**
* Sets the title
*
* @param string $title
* @return void
*/
public function setTitle($title)
{
$this->title = $title;
}
/**
* Returns the description
*
* @return string $description
*/
public function getDescription()
{
return $this->description;
}
/**
* Sets the description
*
* @param string $description
* @return void
*/
public function setDescription($description)
{
$this->description = $description;
}
/**
* Returns the rulesDescription
*
* @return string $rulesDescription
*/
public function getRulesDescription()
{
return $this->rulesDescription;
}
/**
* Sets the rulesDescription
*
* @param string $rulesDescription
* @return void
*/
public function setRulesDescription($rulesDescription)
{
$this->rulesDescription = $rulesDescription;
}
/**
* Returns the video
*
* @return \TYPO3\CMS\Extbase\Domain\Model\FileReference $video
*/
public function getVideo()
{
return $this->video;
}
/**
* Returns the videocategory
*
* @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Istar\Fefiles\Domain\Model\Videocategory> $videocategory
*/
public function getVideocategory()
{
return $this->videocategory;
}
/**
* Sets the videocategory
*
* @return void
*/
public function setVideocategory($videocategory)
{
$this->videocategory = $videocategory;
}
/**
* Returns the comment
*
* @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Istar\Fefiles\Domain\Model\Videocomment> $comment
*/
public function getComment()
{
return $this->comment;
}
/**
* Sets the comment
*
* @return void
*/
public function setComment($comment)
{
$this->comment = $comment;
}
/**
* Adds a comments to the video
*
* @param \Istar\Fefiles\Domain\Model\Videocomment $comment
* @return void
* @api
*/
public function addComment(\Istar\Fefiles\Domain\Model\Videocomment $comment)
{
$this->comment->attach($comment);
}
/**
* Removes a comment from the video
*
* @param \Istar\Fefiles\Domain\Model\Videocomment $comment
* @return void
* @api
*/
public function removeComment(\Istar\Fefiles\Domain\Model\Videocomment $comment)
{
$this->comment->detach($comment);
}
/**
* Returns the user
*
* @return \Fhk\Feusersplus\Domain\Model\User> $user
*/
public function getUser()
{
return $this->user;
}
/**
* Sets the user
*
* @return void
*/
public function setUser($user)
{
$this->user = $user;
}
/**
* Returns the allow
*
* @return int
*/
public function getAllow()
{
return $this->allow;
}
/**
* Sets the video
*
* @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $video
* @return void
*/
public function setVideo($video)
{
$this->video = $video;
}
/**
* Returns the preview
*
* @return \TYPO3\CMS\Extbase\Domain\Model\FileReference $preview
*/
public function getPreview()
{
return $this->preview;
}
/**
* Sets the preview
*
* @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $preview
*
* @return void
*/
public function setPreview($preview)
{
$this->preview = $preview;
}
/**
* Returns the blurred
*
* @return \TYPO3\CMS\Extbase\Domain\Model\FileReference $blurred
*/
public function getBlurred()
{
return $this->blurred;
}
/**
* Sets the blurred
*
* @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $blurred
*
* @return void
*/
public function setBlurred($blurred)
{
$this->blurred = $blurred;
}
/**
* Returns the fskcheck
*
* @return int
*/
public function getFskcheck()
{
return $this->fskcheck;
}
/**
* Sets the fskcheck
*
* @return void
*/
public function setFskcheck($fskcheck)
{
$this->fskcheck = $fskcheck;
}
/**
* Returns the Private
*
* @return int
*/
public function getPrivate()
{
return $this->private;
}
/**
* Sets the private
*
* @return void
*/
public function setPrivate($private)
{
$this->private = $private;
}
/**
* Returns the crdate
* @return int $crdate
*/
public function getCrdate()
{
return $this->crdate;
}
/**
* Sets the crdate
*
* @param int $crdate
* @return void
*/
public function setCrdate($crdate)
{
$this->crdate = $crdate;
}
}
答案 0 :(得分:0)
在后端创建新记录之前和之后查看sys_file_reference
表。是否添加了新记录?保存现有记录后,您不会添加随机图像/视频吗?
答案 1 :(得分:0)
解决方案:
'foreign_match_fields' => array(
'fieldname' => 'image',
'tablenames' => 'tx_fefiles_domain_model_photo',
'table_local' => 'sys_file_reference',
),