Пример #1
0
 /**
  * {@inheritdoc}
  */
 protected function performExecution(callable $callback)
 {
     $trans = false;
     if ($this->executionDepth == 0) {
         if ($this->handleTransactions) {
             $this->debug('BEGIN transaction');
             $this->conn->beginTransaction();
         }
         $trans = true;
     }
     try {
         $chain = new ExecutionInterceptorChain(function () use($callback) {
             return parent::performExecution($callback);
         }, $this->executionDepth, $this->interceptors);
         $result = $chain->performExecution($this->executionDepth);
         if ($trans) {
             if ($this->handleTransactions) {
                 $this->debug('COMMIT transaction');
                 $this->conn->commit();
             }
         }
     } catch (\Exception $e) {
         if ($trans) {
             if ($this->handleTransactions) {
                 $this->debug('ROLL BACK transaction');
                 $this->conn->rollBack();
             }
         }
         throw $e;
     } finally {
         if ($trans) {
             $this->executions = [];
             $this->jobs = [];
         }
     }
     // Schedule jobs after commit to DB, ensures consistent state in DB and failed scheduling attempts can be repeated.
     if ($trans) {
         if ($this->jobExecutor !== NULL) {
             $this->jobExecutor->syncScheduledJobs();
         }
     }
     return $result;
 }