示例#1
0
 /**
  * Commit transaction
  *
  * Commit transaction, or throw exceptions if no transactions has been started.
  *
  * @throws RuntimeException If no transaction has been started
  */
 public function commit()
 {
     try {
         $this->persistenceHandler->commit();
         --$this->transactionDepth;
         if ($this->transactionDepth === 0) {
             $queueCountDown = count($this->commitEventsQueue);
             foreach ($this->commitEventsQueue as $eventsQueue) {
                 --$queueCountDown;
                 if (empty($eventsQueue)) {
                     continue;
                 }
                 $eventCountDown = count($eventsQueue);
                 foreach ($eventsQueue as $event) {
                     --$eventCountDown;
                     // event expects a boolean param, if true it means it is last event (for commit use)
                     $event($queueCountDown === 0 && $eventCountDown === 0);
                 }
             }
             $this->commitEventsQueue = array();
         }
     } catch (Exception $e) {
         throw new RuntimeException($e->getMessage(), 0, $e);
     }
 }