我维护一个TYPO3扩展,用于管理后端的前端用户。因此,我用我自己的模型扩展了FrontendUserRepository。我的扩展程序提供了CRUD操作,并且在更新现有人员的密码方面存在问题。这个想法是只更新密码,如果编辑表单中的密码字段被填充,否则(如果它留空)旧密码值保留在数据库中。TYPO3中除了一个属性以外的更新域模型6.2
现在一切工作正常使用TYPO3 4.5,但现在经过我升级到6.2,用空密码字段提交编辑表单时,一个空字符串保存到数据库中...
这是我 :
/**
* action update
*
* @param \My\Vendor\Domain\Model\Person $person
*
* @return void
*/
public function updateAction(\My\Vendor\Domain\Model\Person $person) {
// only hash and set password if not empty
if ($person->getPassword() == '') {
// if password was left empty, get current password from database
$oldPerson = $this->personRepository->findByUid($person->getUid());
$person->setPassword($oldPerson->getPassword()));
} else {
$person->setPassword(md5($person->getPassword()));
}
// save updated person to repository
$this->personRepository->update($person);
$this->flashMessageContainer->add('The person data was saved.');
$this->redirect('edit', NULL, NULL, array('person' => $person));
}
有谁知道,为什么$oldPerson->getPassword()
不从数据库密码字段返回当前值?还是有另一种方法可以在更新所有其他属性时“跳过”域模型的属性?奇怪的是,它在TYPO3 4.5工作...
感谢您的详细解答! '_getCleanProperty()'函数正在工作 – andreas