所以我有一所学校,每所学校都有多个上课时间表,每个时间表都有详细信息:
school (document)
-- bell schedule (embedded document)
---- bell schedule details (embedded document)
当我克隆学校对象并打印学校时,它会在克隆中返回正确的对象。但是,当我尝试坚持学校时,它没有正确保存详细信息。我需要做些什么才能使其正常工作吗?我需要设置一个标志吗?
我想做的是:
$school2 = clone $school1;
$dm->persist($school2);
$dm->flush();
---- classes ----
/**
* @MongoDB\Document(collection="schools")
*/
class School
{
/**
* @MongoDB\EmbedMany
*/
protected $bell_schedules = array();
public function addBellSchedules(BellSchedule $bellSchedules)
{
$this->bell_schedules[] = $bellSchedules;
}
public function getBellSchedules()
{
return $this->bell_schedules;
}
public function setBellSchedules(\Doctrine\Common\Collections\ArrayCollection $bell_schedules)
{
$this->bell_schedules = $bell_schedules;
return $this;
}
}
/**
* @MongoDB\EmbeddedDocument
*/
class BellSchedule
{
/**
* @MongoDB\EmbedMany
*/
private $bell_schedule_details
public function getBellScheduleDetails()
{
return $this->bell_schedule_details;
}
public function setBellScheduleDetails(\Doctrine\Common\Collections\ArrayCollection $bell_schedule_details)
{
$this->bell_schedule_details = $bell_schedule_details;
return $this;
}
}
/**
* @MongoDB\EmbeddedDocument
*/
class BellScheduleDetail
{
private $period;
private $label;
}