/** * Commits new objects and changes to objects in the current persistence * session into the backend * * @param boolean $onlyWhitelistedObjects * @return void * @api */ public function persistAll($onlyWhitelistedObjects = false) { if ($onlyWhitelistedObjects) { foreach ($this->changedObjects as $object) { $this->throwExceptionIfObjectIsNotWhitelisted($object); } foreach ($this->removedObjects as $object) { $this->throwExceptionIfObjectIsNotWhitelisted($object); } foreach ($this->addedObjects as $object) { $this->throwExceptionIfObjectIsNotWhitelisted($object); } } // hand in only aggregate roots, leaving handling of subobjects to // the underlying storage layer // reconstituted entities must be fetched from the session and checked // for changes by the underlying backend as well! $this->backend->setAggregateRootObjects($this->addedObjects); $this->backend->setChangedEntities($this->changedObjects); $this->backend->setDeletedEntities($this->removedObjects); $this->backend->commit(); $this->addedObjects = new \SplObjectStorage(); $this->removedObjects = new \SplObjectStorage(); $this->changedObjects = new \SplObjectStorage(); $this->emitAllObjectsPersisted(); $this->hasUnpersistedChanges = false; }