public function commit(array $options = array())
{
if (!($this->entityInsertions || $this->entityDeletions || $this->entityUpdates)) {
return;
// Nothing to do.
}
// Raise onFlush
if ($this->evm->hasListeners(Events::onFlush)) {
$this->evm->dispatchEvent(Events::onFlush, new Event\OnFlushEventArgs($this->xem));
}
// Execute insertions, updates, and deletes
if ($this->entityInsertions) {
foreach ($this->entityInsertions as $class) {
$classMetadata = $this->xem->getClassMetadata(get_class($class));
$this->executeInserts($classMetadata, $options);
}
}
if ($this->entityUpdates) {
foreach ($this->entityUpdates as $class) {
$classMetadata = $this->xem->getClassMetadata(get_class($class));
$this->executeUpdates($classMetadata, $options);
}
}
if ($this->entityDeletions) {
foreach ($this->entityDeletions as $class) {
$classMetadata = $this->xem->getClassMetadata(get_class($class));
$this->executeDeletions($classMetadata, $options);
}
}
// Clear up
$this->entityInsertions = $this->entityUpdates = $this->entityDeletions = $this->entityChangeSets = $this->scheduledForDirtyCheck = array();
}