TYPO3 Extbase fe_user UID在自己的模型中 [英] TYPO3 Extbase fe_user UID in own model
本文介绍了TYPO3 Extbase fe_user UID在自己的模型中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在TYPO3 6.2中创建了一个extbase插件.在一个表中,我有一个字段"fuid",我想在其中存储fe_users uid,以了解哪个用户可以编辑此记录.
I create a extbase Plugin in TYPO3 6.2. In one table i have a field "fuid" where i want to store the fe_users uid, to know which user can edit this record.
我在createAction中设置了"fuid":
I set the "fuid" in createAction:
$newLocation->setFuID((int) $GLOBALS['TSFE']->fe_user->user['uid']);
这项工作.在数据库中是正确的UID.
This work. In the Database is the right UID.
但是在editAction中:
But in the editAction:
$location->getFuID()
returns null
为什么?
TCA:
fu_i_d' => array(
'exclude' => 1,
'label' => 'LLL:EXT:pitss24/Resources/Private/Language/locallang_db.xlf:tx_pitss24_domain_model_location.fu_i_d',
'config' => array(
'type' => 'select',
'items' => array (
array('',0),
),
'foreign_table' => 'fe_users',
'foreign_class' => '\TYPO3\CMS\Extbase\Domain\Model\FrontendUser',
'minitems' => 0,
'maxitems' => 1,
'size' => 10,
'appearance' => array(
'collapseAll' => 0,
'levelLinksPosition' => 'top',
'showSynchronizationLink' => 1,
'showPossibleLocalizationRecords' => 1,
'showAllLocalizationLink' => 1
),
),
),
在后端/TYPO3一切正常!
In the Backend / TYPO3 is all OK!
推荐答案
我发现了错误! extensionBuilder在模型中写入错误的数据:
i found the Error! The extensionBuilder writes wrong Data in the Model:
正确的值是:
型号:
/*
*
* @var TYPO3\CMS\Extbase\Domain\Model\FrontendUser
*/
protected $fuID = NULL;
...
...
...
/**
* Returns the fuID
*
* @return TYPO3\CMS\Extbase\Domain\Model\FrontendUser fuID
*/
public function getFuID() {
return $this->fuID;
}
/*
* Sets the fuID
*
* @param string $fuID
* @return TYPO3\CMS\Extbase\Domain\Model\FrontendUser fuID
*/
public function setFuID(TYPO3\CMS\Extbase\Domain\Model\FrontendUser $fuID) {
$this->fuID = $fuID;
}
控制器:
/**
* User Repository
*
* @var \TYPO3\CMS\Extbase\Domain\Repository\FrontendUserRepository
* @inject
*/
protected $userRepository;
/**
* Den aktuell angemeldeten User auslesen
*
* @return \TYPO3\CMS\Extbase\Domain\Repository\FrontendUserRepository
*/
public function getCurrentUser() {
if ($this->currentUser == NULL && $GLOBALS['TSFE']->fe_user->user['uid'] > 0) {
$this->currentUser = $this->userRepository->findByUid($GLOBALS['TSFE']->fe_user->user['uid']);
}
return $this->currentUser;
}
这篇关于TYPO3 Extbase fe_user UID在自己的模型中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文