Changeset 7391
- Timestamp:
- 02/07/08 17:05:13 (10 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/sfPropelImpersonatorPlugin/trunk/lib/sfPropelObjectPeerImpersonator.class.php
r7385 r7391 39 39 $classToIndex, 40 40 $relations, 41 $currentIndex; 41 $currentIndex, 42 $culture = null; 42 43 43 44 /** … … 275 276 } 276 277 278 public function setCulture($culture) 279 { 280 $this->culture = mysql_real_escape_string($culture); 281 } 282 283 public function getCulture() 284 { 285 if (null === $this->culture) 286 { 287 $this->setCulture(sfContext::getInstance()->getUser()->getCulture()); 288 } 289 290 return $this->culture; 291 } 292 293 public function getJoinForCulture($class, $idField) 294 { 295 return constant($class.'::'.$idField).' AND '.constant($class.'::CULTURE').'=\''.$this->getCulture().'\''; 296 } 297 277 298 /** 278 299 * Object population … … 299 320 } 300 321 301 echo '<script>console.dir('.json_encode(array(' sfPropelObjectPeerImpersonator'=>$debugRelations)).');</script>';322 echo '<script>console.dir('.json_encode(array('Propel Impersonator Debug'=>$debugRelations)).');</script>'; 302 323 echo '<pre>'; 303 324 } … … 335 356 } 336 357 for now, let's say we keep it 358 359 reason is: if we dont populate an empty propel object, propel will think we don't know it does not exists, and 360 will fetch it again from database. 361 362 maybe this could be implemented with a minimal NULL object (ok i know it looks like Doctrine_Null) 337 363 */ 338 364 … … 380 406 if (self::DEBUG && self::DEBUG_POPULATE) 381 407 { 382 echo ' <u>REVERSE</u>: '.$relation['classFrom'].' <-- '.$relation['classTo'] ."\n";408 echo ' <u>REVERSE</u>: '.$relation['classFrom'].' <-- '.$relation['classTo']; 383 409 } 384 410 … … 388 414 if ($isNewObject) 389 415 { 416 if (self::DEBUG && self::DEBUG_POPULATE) 417 { 418 echo ' (new)'; 419 } 420 390 421 $currentObject->{'init'.$foreignClass.'s'}(); 391 422 } … … 401 432 if (self::DEBUG && self::DEBUG_POPULATE) 402 433 { 403 echo ' <u>I18N</u>: '.$relation['classTo'].' <-- '.$relation['classFrom']."\n"; 404 } 405 406 if (null !== ($classToIndex = $this->getIndexByClass($relation['classTo']))) 407 { 408 $foreignObject =& $rowObjects[$classToIndex]; 409 410 $rowObjects[$index]->{'set'.$relation['classTo']}($foreignObject); 411 $foreignObject->{'set'.$relation['classTo'].'I18nForCulture'}($rowObjects[$index], $rowObjects[$index]->getCulture()); 434 echo ' <u>I18N</u>: '.$relation['classTo'].' <-- '.$relation['classFrom']; 435 } 436 437 if (null !== ($objectIndex = $this->getIndexByClass($relation['classTo']))) 438 { 439 if (self::DEBUG && self::DEBUG_POPULATE) 440 { 441 echo ' (exists)'; 442 } 443 444 $object = $rowObjects[$objectIndex]; 445 $i18nObject = $rowObjects[$index]; 446 447 $i18nObject->{'set'.$relation['classTo']}($object); 448 $object->{'set'.$relation['classTo'].'I18nForCulture'}($i18nObject, $this->getCulture()); 449 412 450 } 413 451 break; … … 419 457 if (self::DEBUG && self::DEBUG_POPULATE) 420 458 { 421 echo ' <u>NORMAL</u>: '.$relation['classFrom'].' --> '.$relation['classTo']."\n"; 422 } 423 459 echo ' <u>NORMAL</u>: '.$relation['classFrom'].' --> '.$relation['classTo']; 460 } 424 461 425 462 if (null !== ($classToIndex = $this->getIndexByClass($relation['classTo']))) 426 463 { 464 if (self::DEBUG && self::DEBUG_POPULATE) 465 { 466 echo ' (exists)'; 467 } 427 468 $foreignObject = $rowObjects[$classToIndex]; 428 469 … … 438 479 } 439 480 break; 481 } 482 483 if (self::DEBUG && self::DEBUG_POPULATE) 484 { 485 echo "\n"; 440 486 } 441 487 }