Changeset 6526 for sandbox/2.4.1-3/prototype/api/controller.php
- Timestamp:
- 06/15/12 16:30:56 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/2.4.1-3/prototype/api/controller.php
r6357 r6526 45 45 require_once(ROOTPATH.'/api/config.php'); 46 46 use prototype\api\Config as Config; 47 48 47 /** 49 48 TODO list: … … 181 180 public static function rollback( $URI, $criteria = false ) 182 181 { 182 if( isset( $URI['service'] ) ) 183 unset( self::$tx[ $URI['service'] ] ); 184 185 self::$txID--; 186 183 187 return self::call( 'rollback', $URI, false, $criteria ); 184 188 } … … 485 489 486 490 if( $return === false ) 487 return( false );491 return( false ); 488 492 489 493 if( isset($return) ) … … 530 534 return( $URI ); 531 535 } 536 537 public static function finalizeCommit( $method, $params, $original, $TX = array() ) 538 { 539 if( $TX !== false ) 540 { 541 $TX['rollback'] = !!!$params['properties']; 542 543 if( $params['properties'] && is_array($params['properties']) && isset($params['properties']['id']) ) 544 $TX['id'] = $params['properties']['id']; 545 546 self::$tx[ $params['URI']['service'] ][] = array_merge( $TX, $original['URI'], array( 'service' => $params['URI']['service'], 'method' => $method ) ); 547 } 548 549 return( empty($params['properties']) ? false : $params['properties'] ); 550 } 532 551 533 552 //TODO: Compatibilizar as configs relativas aos modulos, adicionando os mesmos nas options passadas … … 544 563 545 564 if( isset($params['URI']['concept']) && !self::fire( 'before', $method, $params, $original ) ) 546 return( empty($params['properties']) ? false : $params['properties'] ); 547 548 565 return( self::finalizeCommit( $method, $params, $original ) ); 549 566 550 567 if( $params && !$params['service'] ) … … 568 585 569 586 if( !self::fire( 'before', $method, $params, $original, true ) ) 570 return( empty($params['properties']) ? false : $params['properties']);587 return( self::finalizeCommit( $method, $params, $original, isset($TX) ? $TX : false ) ); 571 588 } 572 589 … … 608 625 if( isset($params['URI']['service']) ) 609 626 if( !self::fire( 'after', $method, $params, $original, true ) ) 610 return( empty($params['properties']) ? false : $params['properties']);627 return( self::finalizeCommit( $method, $params, $original, isset($TX) ? $TX : false ) ); 611 628 612 629 if( isset($URI['concept']) ) … … 618 635 if( isset( $TX ) ) 619 636 { 620 $TX['rollback'] = !!!$params['properties']; 621 622 if( $params['properties'] && is_array($params['properties']) && isset($params['properties']['id']) ) 623 $TX['id'] = $params['properties']['id']; 624 625 self::$tx[ $params['URI']['service'] ][] = array_merge( $TX, $original['URI'], array( 'service' => $params['URI']['service'], 'method' => $method ) ); 626 637 //self::finalizeCommit( $params, $original, $method, $TX ); 638 self::finalizeCommit( $method, $params, $original, $TX ); 627 639 if( isset($commit) && $commit ) 628 640 { … … 636 648 catch( Exception $e ) 637 649 { 638 if( !self::fallback( $e ) )650 if( !self::fallback( $e, $URI ) ) 639 651 self::closeAll(); 640 652 … … 645 657 } 646 658 647 public static function fallback( $exception )659 public static function fallback( $exception, $URI ) 648 660 { 649 661 $code = $exception->getCode(); … … 652 664 { 653 665 $fn = self::$fallbackHandlers[ $code ]; 654 return $fn( $exception );666 return $fn( $exception, $URI ); 655 667 } 656 668 … … 717 729 $URI['id'] = $result['id']; 718 730 719 self::$tx[ $URI['service'] ][ count(self::$tx[ $URI['service'] ]) - 1 ]['order'] = $order; 720 self::$tx[ $URI['service'] ][ count(self::$tx[ $URI['service'] ]) - 1 ]['id'] = $URI['id']; 731 $index = count(self::$tx[ $URI['service'] ]) - 1; 732 733 self::$tx[ $URI['service'] ][ $index ]['order'] = $order; 734 self::$tx[ $URI['service'] ][ $index ]['id'] = $URI['id']; 735 736 if( !isset(self::$tx[ $URI['service'] ][ $index ]['concept']) ) 737 self::$tx[ $URI['service'] ][ $index ]['concept'] = $URI['concept']; 721 738 722 739 foreach( $postpone as $linkTarget => $dt ) … … 763 780 catch( Exception $e ) 764 781 { 765 if( !self::fallback( $e ) )782 if( !self::fallback( $e, $URI ) ) 766 783 self::closeAll(); 767 784
Note: See TracChangeset
for help on using the changeset viewer.