删除的对象(deleteAction)无法恢复(restoreAction),会引发异常:
属性路径中的属性映射异常“”:找不到标识为“1”的对象。
控制器:
/**
* action delete
*
* @param \EXAPOINT\Exacallmanagement\Domain\Model\Calls $calls
* @return void
*/
public function deleteAction(\EXAPOINT\Exacallmanagement\Domain\Model\Calls $calls) {
$this->callsRepository->remove($calls);
$this->flashMessageContainer->add('Call gelöscht.');
$this->redirect('list');
}
/**
* action restore
*
* @param \EXAPOINT\Exacallmanagement\Domain\Model\Calls $calls
* @return void
*/
public function restoreAction(\EXAPOINT\Exacallmanagement\Domain\Model\Calls $calls) {
$calls->setDeleted(0);
$this->callsRepository->update($calls);
$this->redirect('list');
}
型号:
/**
* @var \integer
*/
protected $deleted;
/**
* @return integer $deleted
*/
public function getDeleted() {
return $this->deleted;
}
/**
* @param integer $deleted
* @return void
*/
public function setDeleted($deleted) {
$this->deleted = $deleted;
}
问题的根源是存储库没有“看到”已删除对象的事实吗?什么是最好的方式?
答案 0 :(得分:3)
如果属性映射器无法处理已删除的对象,只需将uid传递给restoreAction,然后
确保在TCA中配置了已删除的字段:
'deleted' => array(
'exclude' => 1,
'label' => 'deleted',
'config' => array(
'type' => 'check',
),
),
你不必将它添加到任何类型,但如果我没记错的话,字段本身必须像这样配置。
答案 1 :(得分:1)
必须配置存储库以查找由于enableFields而通常被忽略的实体。在您的存储库中,尝试类似:
public function initializeObject() {
$defaultQuerySettings = $this->objectManager->get('Tx_Extbase_Persistence_Typo3QuerySettings');
$defaultQuerySettings->setRespectEnableFields(FALSE);
$this->setDefaultQuerySettings($defaultQuerySettings);
}
答案 2 :(得分:0)
除了现有的答案:这个问题众所周知,而且即将改变TYPO3 6.2。您可以关注此问题并测试Extbase补丁here。