我正在尝试绕过替代方法,但出现错误:
通知:未定义的属性:EventPositionModel :: $ parent
我这样打电话:
$newEventPosition = new EventPositionModel;
$newEventPosition::parent->createRecord($accessUser, $fieldValues);
//also tried
$newEventPosition->parent::createRecord($accessUser, $fieldValues);
对象已设置。
我也尝试过$newEventPosition->parent->createRecord
这些类是:
class EventPositionModel extends Model {
public function createRecord($accessUser, $fieldValues){
//we need to know if we are creating for one or all days
$recordCreated = false;
if (!empty($fieldValues['all_days'])){
// we need to loop the scheduled days and add the position
$eventSchedule = new EventScheduleModel;
$eventScheduleDays = $eventSchedule->getAllChildRecords();
foreach($eventScheduleDays as $scheduleDay){
$fieldValues['event_schedule_id'] = $scheduleDay['event_scheduleID'];
// Because I need to return a JSON array to the API caller I need to create seperate instances of the same model for each record created at this point.
$newEventPosition = new EventPositionModel;
if ($newEventPosition::parent::createRecord($accessUser, $fieldValues)){
$this->record['newPositions'] = $newEventPosition->record;
};
}
}
else{
if (parent::createRecord($accessUser, $fieldValues)){
//do some stuff....
}
}
}
}
class Model{
public function createRecord($accessUser, $fieldValues){
//Do a LOT of stuff
}
}