src/Infrastructure/DataAccess/UnitOfWork/UnitOfWork.php
public function commit()
    {
        $committed_events_map = new AggregateRootEventListMap;
        $comitted_ars = [];
        foreach ($this->tracked_aggregate_roots as $aggregate_root) {
            $event_stream = $this->tracked_aggregate_roots[$aggregate_root];
            $committed_events_list = new AggregateRootEventList;
            foreach ($aggregate_root->getUncomittedEvents() as $uncomitted_event) {
                $event_stream->push($uncomitted_event);
                $this->event_writer->write($uncomitted_event);
                $committed_events_list->push($uncomitted_event);
            }
            $aggregate_root->markAsComitted();
            $committed_events_map->setItem($aggregate_root->getIdentifier(), $committed_events_list);
            $comitted_ars[] = $aggregate_root;
        }

        foreach ($comitted_ars as $comitted_ar) {
            $this->tracked_aggregate_roots->offsetUnset($aggregate_root);
        }

        return $committed_events_map;
    }
public function commit()
    {
        $committed_events_map = new AggregateRootEventListMap;
        $comitted_ars = [];
        foreach ($this->tracked_aggregate_roots as $aggregate_root) {
            $event_stream = $this->tracked_aggregate_roots[$aggregate_root];
            $committed_events_list = new AggregateRootEventList;
            foreach ($aggregate_root->getUncomittedEvents() as $uncomitted_event) {
                $event_stream->push($uncomitted_event);
                $this->event_writer->write($uncomitted_event);
                $committed_events_list->push($uncomitted_event);
            }
            $aggregate_root->markAsComitted();
            $committed_events_map->setItem($aggregate_root->getIdentifier(), $committed_events_list);
            $comitted_ars[] = $aggregate_root;
        }

        foreach ($comitted_ars as $comitted_ar) {
            $this->tracked_aggregate_roots->offsetUnset($aggregate_root);
        }

        return $committed_events_map;
    }
public function commit ( ) { $ committed_events_map = new AggregateRootEventListMap ; $ comitted_ars = [ ] ; foreach ( $ this -> tracked_aggregate_roots as $ aggregate_root ) { $ event_stream = $ this -> tracked_aggregate_roots [ $ aggregate_root ] ; $ committed_events_list = new AggregateRootEventList ; foreach ( $ aggregate_root -> getUncomittedEvents ( ) as $ uncomitted_event ) { $ event_stream -> push ( $ uncomitted_event ) ; $ this -> event_writer -> write ( $ uncomitted_event ) ; $ committed_events_list -> push ( $ uncomitted_event ) ; } $ aggregate_root -> markAsComitted ( ) ; $ committed_events_map -> setItem ( $ aggregate_root -> getIdentifier ( ) , $ committed_events_list ) ; $ comitted_ars [ ] = $ aggregate_root ; } foreach ( $ comitted_ars as $ comitted_ar ) { $ this -> tracked_aggregate_roots -> offsetUnset ( $ aggregate_root ) ; } return $ committed_events_map ; }
Commit all changes that are pending for our tracked aggregate-roots.

@return AggregateRootEventList Returns a list of events that were actually committed.
Commit all changes that are pending for our tracked aggregate - roots .