Ignore:
Timestamp:
06/15/12 16:30:56 (12 years ago)
Author:
gustavo
Message:

Ticket #2766 - Preparativos para fazer o merge com o trunk da comunidade

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sandbox/2.4.1-3/prototype/api/controller.php

    r6357 r6526  
    4545require_once(ROOTPATH.'/api/config.php'); 
    4646use prototype\api\Config as Config; 
    47  
    4847/** 
    4948TODO list: 
     
    181180        public static function rollback( $URI, $criteria = false ) 
    182181        { 
     182            if( isset( $URI['service'] ) ) 
     183                unset( self::$tx[ $URI['service'] ] ); 
     184 
     185            self::$txID--; 
     186 
    183187            return self::call( 'rollback', $URI, false, $criteria ); 
    184188        } 
     
    485489 
    486490                    if( $return === false ) 
    487                 return( false ); 
     491                        return( false ); 
    488492 
    489493                    if( isset($return) ) 
     
    530534            return( $URI ); 
    531535        } 
     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        } 
    532551 
    533552        //TODO: Compatibilizar as configs relativas aos modulos, adicionando os mesmos nas options passadas 
     
    544563 
    545564                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 ) ); 
    549566 
    550567                if( $params && !$params['service'] ) 
     
    568585 
    569586                    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 ) ); 
    571588                } 
    572589 
     
    608625                if( isset($params['URI']['service']) ) 
    609626                    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 ) ); 
    611628 
    612629                if( isset($URI['concept']) ) 
     
    618635                if( isset( $TX ) ) 
    619636                { 
    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 ); 
    627639                    if( isset($commit) && $commit ) 
    628640                    { 
     
    636648            catch( Exception $e ) 
    637649            { 
    638                 if( !self::fallback( $e ) ) 
     650                if( !self::fallback( $e, $URI ) ) 
    639651                    self::closeAll(); 
    640652 
     
    645657        } 
    646658 
    647         public static function fallback( $exception ) 
     659        public static function fallback( $exception, $URI ) 
    648660        { 
    649661            $code = $exception->getCode(); 
     
    652664                { 
    653665                        $fn = self::$fallbackHandlers[ $code ]; 
    654                         return $fn( $exception ); 
     666                        return $fn( $exception, $URI ); 
    655667                } 
    656668 
     
    717729                      $URI['id'] = $result['id']; 
    718730 
    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']; 
    721738 
    722739                foreach( $postpone as $linkTarget => $dt ) 
     
    763780            catch( Exception $e ) 
    764781            { 
    765                 if( !self::fallback( $e ) ) 
     782                if( !self::fallback( $e, $URI ) ) 
    766783                    self::closeAll(); 
    767784 
Note: See TracChangeset for help on using the changeset viewer.