コード例 #1
0
 public function testDefaultConstruction()
 {
     $message = 'imamessagestring';
     $e = new TransactionException($message);
     $this->assertEquals('Error occured during transaction', $e->getTitle());
     $this->assertEquals('alert-error', $e->getAlertType());
     $this->assertEquals(0, $e->getCode());
     $this->assertEquals(null, $e->getPrevious());
 }
 private function storeMatch($subject, $method, $pattern)
 {
     foreach ($pattern['conn'] as $connectionName) {
         if (isset($this->cache[$subject][$method][$connectionName])) {
             throw TransactionException::duplicateConnectionMatch($connectionName, $pattern);
         }
         $this->cache[$subject][$method][$connectionName] = array('isolation' => $pattern['isolation'], 'propagation' => $pattern['propagation'], 'noRollbackFor' => $pattern['noRollbackFor'], 'subrequest' => $pattern['subrequest']);
     }
 }
コード例 #3
0
ファイル: Transaction.php プロジェクト: devster/ika
 /**
  * Roll back the Transaction
  *
  * It will execute the `down`action of the succeeded commands
  * or all if no exception has been thrown during the begin method.
  *
  * @param  mixed $offset Allows to set the starting command
  *
  * @return mixed Returns the result of the last hook/command
  */
 public function rollback($offset = null)
 {
     $this->_init();
     $previous_return = null;
     $commands = array_reverse($this->commands, true);
     $offset = $offset ?: $this->offset_error;
     $start_rollback = is_null($offset) ? true : false;
     foreach ($commands as $index => $command) {
         if (!$start_rollback && $offset == $index) {
             $start_rollback = true;
             continue;
         }
         try {
             if (!$command->isEnabled() || !$start_rollback) {
                 continue;
             }
             // pre hook
             $previous_return = $this->executeHooks(self::HOOK_PRE, self::DIRECTION_DOWN, $previous_return, $command);
             $previous_return = $command->runDown($previous_return);
             // post hook
             $previous_return = $this->executeHooks(self::HOOK_POST, self::DIRECTION_DOWN, $previous_return, $command);
         } catch (\Exception $e) {
             $ie = new TransactionException($e->getMessage(), $e->getCode());
             $ie->setCommand($command);
             $ie->setDirection(self::DIRECTION_DOWN);
             throw $ie;
         }
         if ($this->offset_start == $index) {
             break;
         }
     }
     return $previous_return;
 }
コード例 #4
0
 public function __construct($message = null, \Exception $previous = null, $code = 0)
 {
     parent::__construct(404, $message, $previous, $code);
 }