我做了一个类Appointment
与expertises
属性和另一个subExpertises
同类型的extbase扩展。
这是他们看起来像在Appointment
类(subExpertises
是相同的):调用未定义的方法getPosition() - 为什么和修复
/**
*
* @param \Domain\Model\Appointment $appointment
* @return void
*/
public function bookAction(\Domain\Model\Appointment $appointment) {
//empty all expertises of appointment - then fill them with the selected from lawyer
$appointment->setExpertises(new \TYPO3\CMS\Extbase\Persistence\ObjectStorage());
$appointment->setSubExpertises(new \TYPO3\CMS\Extbase\Persistence\ObjectStorage());
//add all checked expertises of lawyer to appointment
foreach ($appointment->getLawyer()->getExpertises() as $expertise) {
if ($expertise->getChecked()) {
$appointment->addExpertise($expertise);
}
foreach ($expertise->getSubExpertises() as $subExpertise) {
if ($subExpertise->getChecked()) {
$appointment->addSubExpertise($subExpertise);
}
}
}
$this->appointmentRepository->update($appointment);
}
:
/**
* expertises
*
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<...\Domain\Model\Expertise>
*/
protected $expertises = NULL;
/**
* Adds an expertise
*
* @param ...\Domain\Model\Expertise $expertise
* @return void
*/
public function addExpertise(...\Domain\Model\Expertise $expertise) {
$this->expertises->attach($expertise);
}
我流体的形式编辑后任命执行在我的控制器此代码时得到一个错误
这是错误:
Fatal error: Call to undefined method \Domain\Model\Expertise::getPosition() in /var/www/typo3_src/typo3_src-6.2.25/typo3/sysext/extbase/Classes/Persistence/Generic/Backend.php on line 453
现在看来,TYPO3认为Expertise
是ObjectStorage
型的,因为它试图调用getPosition()
,但我不知道为什么它这是否和我应该为了成功地挽救我Appointment
对象与新Expertises
改变。
我试着调试约会对象,但我找不到问题 - 对我来说似乎没关系,它只是表明expertises
和subExpertises
已被修改。
...你有不同的专门知识拼写,singluar属性,复数的方法。 – j4k3
我再次检查了我的文本,但它很好 - 道具是objectStorage所以复数'expertises'和'subExpertises'类名是'Expertise'和'addExpertise'只添加一个,所以它应该是单数 –