Changeset 5514 for trunk/prototype/api/controller.php
- Timestamp:
- 02/14/12 16:52:04 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/prototype/api/controller.php
r5437 r5514 1 1 <?php 2 2 3 3 4 if( !defined( 'ROOTPATH' ) ) … … 25 26 static $includes = array(); 26 27 static $tx = array(); 28 static $isConcept = array(); 27 29 static $txID = 0; 28 30 static $wallet; … … 150 152 151 153 //TODO: Compatibilizar as configs relativas aos modulos, adicionando os mesmo nos parametros passados 152 public static function links( $concept = false ) 153 { 154 public static function links( $concept = false, $linkage = false ) 155 { 156 157 154 158 if( !isset(self::$config[ $concept ]) ) 155 159 self::$config[ $concept ] = self::loadConfig( $concept ); 156 160 157 return( isset(self::$config[ $concept ]['links']) ? 158 self::$config[ $concept ]['links'] : array() ); 159 } 160 161 public static function isConcept( $concept ) 161 $links = array(); 162 self::$isConcept[ $concept ] = array(); 163 164 if( isset(self::$config[ $concept ][ 'model.hasOne' ]) ) 165 foreach( self::$config[ $concept ][ 'model.hasOne' ] as $linkName => $linkTarget ) 166 { 167 list( $target, $link ) = explode( '.', $linkTarget ); 168 169 if( $linkage === $linkName ) 170 $return = $link; 171 172 $links[$linkName] = $target; 173 self::$isConcept[ $concept ][ $linkName ] = true; 174 } 175 if( isset(self::$config[ $concept ][ 'model.depends' ]) ) 176 foreach( self::$config[ $concept ][ 'model.depends' ] as $linkName => $linkTarget ) 177 { 178 list( $target, $link ) = explode( '.', $linkTarget ); 179 180 if( $linkage === $linkName ) 181 $return = $link; 182 183 $links[$linkName] = $target; 184 self::$isConcept[ $concept ][ $linkName ] = true; 185 } 186 if( isset(self::$config[ $concept ][ 'model.hasMany' ]) ) 187 foreach( self::$config[ $concept ][ 'model.hasMany' ] as $linkName => $linkTarget ) 188 { 189 list( $target, $link ) = explode( '.', $linkTarget ); 190 191 if( $linkage === $linkName ) 192 $return = $link; 193 194 $links[$linkName] = $target; 195 } 196 197 return( isset($return) ? $return : $links ); 198 } 199 200 public static function isConcept( $concept, $linkName ) 162 201 { 163 if( isset( self::$config[ $concept ] ) && 164 self::$config[ $concept ] ) 165 return( true ); 166 else 167 return file_exists( ROOTPATH."/config/$concept.ini" ); 202 if( !isset( self::$isConcept[ $concept ] ) ) 203 self::links( $concept ); 204 205 return( isset(self::$isConcept[ $concept ][ $linkName ]) ); 168 206 } 169 207 … … 576 614 577 615 $postpone = array(); 616 $linkNames = array(); 578 617 579 618 if( $data ) … … 585 624 if( isset( $data[$linkName] ) && is_array( $data[$linkName] ) ) 586 625 { 587 if( self::isConcept($linkName ) )626 if( self::isConcept( $URI['concept'], $linkName ) ) 588 627 $data[$linkName] = self::put( array( 'concept' => $linkTarget ), $data[$linkName], &$txIds ); 589 628 else 590 $postpone[$linkTarget] = $data[$linkName]; 629 { 630 $postpone[ $linkTarget ] = $data[$linkName]; 631 $linkNames[ $linkTarget ] = $linkName; 632 } 591 633 } 592 634 } … … 609 651 $value = array( 'id' => $value ); 610 652 611 $value[ $URI['concept']] = $URI['id'];612 653 $value[ self::links( $URI['concept'], $linkNames[ $linkTarget ] ) ] = $URI['id']; 654 613 655 self::put( array( 'concept' => $linkTarget ), $value, &$txIds ); 614 656 } … … 658 700 659 701 Controller::$cache = Controller::loadCache(); 660 ?>702 // ?>
Note: See TracChangeset
for help on using the changeset viewer.