public function getEntitiesForPersistence() { if ($this->collection !== null || $this->wasLoaded) { return iterator_to_array($this->getIterator()); } else { return $this->added + $this->toAdd; } }