public function commit($entity = null)
    {
        if ($this->evm->hasListeners(Events::preFlush)) {
            $this->evm->dispatchEvent(Events::preFlush, new Event\PreFlushEventArgs($this->sm));
        }

        //TODO: single/array entity commit handling
        $this->commitRemoved();
        $this->commitPersisted();

        //Force refresh of updated indexes
        if ($entity === true) {
            $client = $this->sm->getClient();
            foreach (array_unique($this->updatedIndexes) as $index) {
                $client->refreshIndex($index);
            }
        }

        $this->clear();

        if ($this->evm->hasListeners(Events::postFlush)) {
            $this->evm->dispatchEvent(Events::postFlush, new Event\PostFlushEventArgs($this->sm));
        }
    }
public function commit($entity = null)
    {
        if ($this->evm->hasListeners(Events::preFlush)) {
            $this->evm->dispatchEvent(Events::preFlush, new Event\PreFlushEventArgs($this->sm));
        }

        //TODO: single/array entity commit handling
        $this->commitRemoved();
        $this->commitPersisted();

        //Force refresh of updated indexes
        if ($entity === true) {
            $client = $this->sm->getClient();
            foreach (array_unique($this->updatedIndexes) as $index) {
                $client->refreshIndex($index);
            }
        }

        $this->clear();

        if ($this->evm->hasListeners(Events::postFlush)) {
            $this->evm->dispatchEvent(Events::postFlush, new Event\PostFlushEventArgs($this->sm));
        }
    }
public function commit ( $ entity = null ) { if ( $ this -> evm -> hasListeners ( Events :: preFlush ) ) { $ this -> evm -> dispatchEvent ( Events :: preFlush , new Event \ PreFlushEventArgs ( $ this -> sm ) ) ; } //TODO: single/array entity commit handling $ this -> commitRemoved ( ) ; $ this -> commitPersisted ( ) ; //Force refresh of updated indexes if ( $ entity === true ) { $ client = $ this -> sm -> getClient ( ) ; foreach ( array_unique ( $ this -> updatedIndexes ) as $ index ) { $ client -> refreshIndex ( $ index ) ; } } $ this -> clear ( ) ; if ( $ this -> evm -> hasListeners ( Events :: postFlush ) ) { $ this -> evm -> dispatchEvent ( Events :: postFlush , new Event \ PostFlushEventArgs ( $ this -> sm ) ) ; } }
Commits the UnitOfWork, executing all operations that have been postponed
up to this point.

The operations are executed in the following order:

1) All entity inserts
2) All entity deletions

@param null|object|array $entity
Commits the UnitOfWork executing all operations that have been postponed up to this point .