/**
  * Commits new objects and changes to objects in the current persistence
  * session into the backend
  *
  * @return void
  * @author Robert Lemke <*****@*****.**>
  * @author Karsten Dambekalns <*****@*****.**>
  * @api
  */
 public function persistAll()
 {
     $aggregateRootObjects = new \SplObjectStorage();
     $deletedEntities = new \SplObjectStorage();
     // fetch and inspect objects from all known repositories
     $repositoryClassNames = $this->reflectionService->getAllImplementationClassNamesForInterface('F3\\FLOW3\\Persistence\\RepositoryInterface');
     foreach ($repositoryClassNames as $repositoryClassName) {
         $repository = $this->objectManager->getObject($repositoryClassName);
         $aggregateRootObjects->addAll($repository->getAddedObjects());
         $deletedEntities->addAll($repository->getRemovedObjects());
     }
     $aggregateRootObjects->addAll($this->persistenceSession->getReconstitutedObjects());
     // hand in only aggregate roots, leaving handling of subobjects to
     // the underlying storage layer
     $this->backend->setAggregateRootObjects($aggregateRootObjects);
     $this->backend->setDeletedEntities($deletedEntities);
     $this->backend->commit();
     // this needs to unregister more than just those, as at least some of
     // the subobjects are supposed to go away as well...
     // OTOH those do no harm, changes to the unused ones should not happen,
     // so all they do is eat some memory.
     foreach ($deletedEntities as $deletedEntity) {
         $this->persistenceSession->unregisterReconstitutedObject($deletedEntity);
     }
 }