コード例 #1
0
 /**
  * @throws BaseException
  * @return ModelAndView
  **/
 public function run(Prototyped $subject, Form $form, HttpRequest $request)
 {
     Assert::isFalse($this->running, 'command already running');
     Assert::isTrue($subject instanceof DAOConnected);
     $this->transaction = InnerTransaction::begin($subject->dao());
     try {
         $mav = $this->command->run($subject, $form, $request);
         $this->running = true;
         return $mav;
     } catch (BaseException $e) {
         $this->transaction->rollback();
         throw $e;
     }
     Assert::isUnreachable();
 }
コード例 #2
0
 public function testRollbackInt()
 {
     //setup
     $db = $this->spawnDb(array('savepointBegin' => 1, 'savepointRollback' => 1, 'inTransaction' => true));
     //execute
     $transaction = InnerTransaction::begin($db);
     $transaction->rollback();
     //test Exception on second commit
     try {
         $transaction->commit();
         $this->fail('expecting exception on second transaction commit');
     } catch (WrongStateException $e) {
         /* all ok */
     }
 }
 public function run()
 {
     Assert::isTrue(!is_null($this->dao) || !is_null($this->db), 'set first dao or db');
     Assert::isNotNull($this->function, 'set first function');
     $transaction = InnerTransaction::begin($this->dao ?: $this->db, $this->level, $this->mode);
     try {
         $result = call_user_func_array($this->function, func_get_args());
         $transaction->commit();
         return $result;
     } catch (Exception $e) {
         $transaction->rollback();
         if ($this->exceptionFunction) {
             $args = func_get_args();
             array_unshift($args, $e);
             return call_user_func_array($this->exceptionFunction, $args);
         }
         throw $e;
     }
 }