Typo3 类型3对象存储添加现有项
我有打字错误37.6.18。我需要将现有项添加到对象存储中。我看到它没有添加项目Typo3 类型3对象存储添加现有项,typo3,Typo3,我有打字错误37.6.18。我需要将现有项添加到对象存储中。我看到它没有添加项目 $editUser = $this->userRepository->findByUid($userUid); $newSmile = $this->serviceRepository->findByUid($smileUid); if ($editUser && $newSmile) { $smileUid = $newSmile->getUid();
$editUser = $this->userRepository->findByUid($userUid);
$newSmile = $this->serviceRepository->findByUid($smileUid);
if ($editUser && $newSmile) {
$smileUid = $newSmile->getUid();
$editUser->addSmile($newSmile);
$this->userRepository->update($editUser);
$persistenceManager->persistAll();
}
请帮帮我。
模型用户,所有触摸微笑对象存储。我添加了我的用户模型。对不起,我必须写点东西。我必须多写点
/**
* smiles
*
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Fhk\Feusersplus\Domain\Model\Service>
*/
protected $smile = '';
/**
* Returns the smiles
*
* @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Fhk\Feusersplus\Domain\Model\Service> $smile
*/
public function getSmile()
{
return $this->smile;
}
/**
* Sets the smile
*
* @return void
*/
public function setSmile($smile)
{
$this->smile = $smile;
}
/**
* Adds a smile to the smile
*
* @param \Fhk\Feusersplus\Domain\Model\Service $smile
* @return void
* @api
*/
public function addSmile(\Fhk\Feusersplus\Domain\Model\Service $smile)
{
$this->smile->attach($smile);
}
/**
* Removes a smile from the smile
*
* @param \Fhk\Feusersplus\Domain\Model\Service $smile
* @return void
* @api
*/
public function removeSmile(\Fhk\Feusersplus\Domain\Model\Service $smile)
{
$this->smile->detach($smile);
}
/**
*微笑
*
*@var\TYPO3\CMS\Extbase\Persistence\ObjectStorage
*/
受保护$smile='';
/**
*报以微笑
*
*@return\TYPO3\CMS\Extbase\Persistence\ObjectStorage$smile
*/
公共函数getSmile()
{
返回$this->smile;
}
/**
*笑一笑
*
*@返回无效
*/
公共功能(微笑)
{
$this->smile=$smile;
}
/**
*在微笑中添加微笑
*
*@param\Fhk\feuser\Domain\Model\Service$smile
*@返回无效
*@api
*/
公共函数addSmile(\Fhk\feuersplus\Domain\Model\Service$smile)
{
$this->smile->attach($smile);
}
/**
*从微笑中删除微笑
*
*@param\Fhk\feuser\Domain\Model\Service$smile
*@返回无效
*@api
*/
公共函数removeSmile(\Fhk\feuersplus\Domain\Model\Service$smile)
{
$this->smile->detach($smile);
}
表tx的TCA\U feusersplus\U domain\U model\U usersmile
<?php
return [
'ctrl' => [
'title' => 'LLL:EXT:feusersplus/Resources/Private/Language/locallang_db.xlf:userSmile',
'label' => 'uid_local',
'tstamp' => 'tstamp',
'crdate' => 'crdate',
'cruser_id' => 'cruser_id',
'sortby' => 'sorting',
'hideTable' => true,
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l10n_parent',
'transOrigDiffSourceField' => 'l10n_diffsource',
'iconfile' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('feusersplus') . 'Resources/Public/Icons/tx_feusersplus_domain_model_hut.gif'
],
'interface' => [
'showRecordFieldList' => 'uid_local,uid_foreign'
],
'types' => [
'1' => ['showitem' => 'sys_language_uid;;;;1-1-1, l10n_parent, l10n_diffsource;;1, uid_local, uid_foreign,--div--;LLL:EXT:cms/locallang_ttc.xlf:tabs.access'],
],
'palettes' => [
'1' => ['showitem' => ''],
],
'columns' => [
'sys_language_uid' => [
'exclude' => 1,
'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.language',
'config' => [
'type' => 'select',
'foreign_table' => 'sys_language',
'foreign_table_where' => 'ORDER BY sys_language.title',
'items' => [
['LLL:EXT:lang/locallang_general.xlf:LGL.allLanguages', -1],
['LLL:EXT:lang/locallang_general.xlf:LGL.default_value', 0]
],
],
],
'l10n_parent' => [
'displayCond' => 'FIELD:sys_language_uid:>:0',
'exclude' => 1,
'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.l18n_parent',
'config' => [
'type' => 'select',
'items' => [
['', 0],
],
'foreign_table' => 'tx_fefiles_domain_model_photo',
'foreign_table_where' => 'AND tx_fefiles_domain_model_photo.pid=###CURRENT_PID### AND tx_fefiles_domain_model_photo.sys_language_uid IN (-1,0)',
],
],
'l10n_diffsource' => [
'config' => [
'type' => 'passthrough',
],
],
't3ver_label' => [
'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.versionLabel',
'config' => [
'type' => 'input',
'size' => 30,
'max' => 255,
]
],
'uid_local' => [
'exclude' => 1,
'label' => 'LLL:EXT:feusersplus/Resources/Private/Language/locallang_db.xlf:user',
'config' => [
'type' => 'select',
'foreign_table' => 'fe_users',
'minitems' => 1,
'maxitems' => 1,
]
],
'uid_foreign' => [
'exclude' => 1,
'label' => 'LLL:EXT:feusersplus/Resources/Private/Language/locallang_db.xlf:smile',
'config' => [
'type' => 'select',
'foreign_table' => 'tx_feusersplus_domain_model_service',
// 'foreign_field' => 'uid',
// 'foreign_table_where' => 'AND tx_feusersplus_domain_model_service.sys_language_uid=###REC_FIELD_sys_language_uid### ',
'foreign_match_fields' => [
'type' => 1
],
'minitems' => 1,
'maxitems' => 1,
]
],
'crdate' => array(
'exclude' => 0,
'label' => 'LLL:EXT:feusersplus/Resources/Private/Language/locallang_db.xlf:crdate',
'config' => array(
'type' => 'input',
'size' => 10,
'max' => 20,
'eval' => 'date',
'checkbox' => '0',
'default' => ''
)
),
],
];
您需要通过以下方式初始化模型中的每个对象存储:
public function __construct()
{
$this->smile = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
}
你能发布用户模型吗?我添加了用户模型。希望得到您的帮助)尝试添加项目时是否没有错误消息?不,我没有看到错误,它只是没有添加请添加插入PersistenceManager的代码段或者我清除所有缓存并重试,但它仍然没有添加相同的对象。TCA中可能有问题吗?我添加了TCA),当我通过objectStorage将项添加到此表中时,它没有设置crdate,为什么?这似乎是一个MM表。mm表不需要TCA。模型具有字段uid
,pid
,等等。我需要TCA,因为我需要解决方案,我必须知道时间,当项目添加到对象存储中时我发现一个德国示例,可能它有助于您理解模型与MM之间的关系: