public function doPersist() { if (!$this->isModified) { return; } $this->added += $this->toAdd; $this->removed += $this->toRemove; $this->toAdd = []; $this->toRemove = []; $this->isModified = false; $this->collection = null; }