コード例 #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;
     }
 }
コード例 #2
0
 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;
     }
 }