/** * Commit the contents of the unit of work. */ public function commit() { $this->eventDispatcher->dispatchPreFlush(); if (!($this->objectsToPersist || $this->objectsToUpdate || $this->objectsToRemove)) { return; // Nothing to do. } $objects = array_merge($this->objectsToPersist, $this->objectsToUpdate, $this->objectsToRemove); $this->eventDispatcher->dispatchPreFlushLifecycleCallbacks($objects); $this->eventDispatcher->dispatchOnFlush(); $this->persister->executePersists(); $this->persister->executeUpdates(); $this->persister->executeRemoves(); $this->eventDispatcher->dispatchPostFlush(); $this->objectsToPersist = array(); $this->objectsToUpdate = array(); $this->objectsToRemove = array(); $this->objectChangeSets = new ChangeSets(); }