public function commitEvent($event) { if ($this->transactionDepth !== 0) { $this->commitEventsQueue[$this->transactionCount][] = $event; } else { // event expects a boolean param, if true it means it is last event (for commit use) $event(true); } }