Development

Changeset 5767

You must first sign up to be able to contribute.

Changeset 5767

Show
Ignore:
Timestamp:
10/30/07 19:58:41 (1 year ago)
Author:
fabien
Message:

sfPropelPlugin: added an optional culture parameter to getCurrentXXX() methods + fixed save() method for i18n objects

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/plugins/sfPropelPlugin/lib/propel/builder/SfObjectBuilder.php

    r3525 r5767  
    173173  protected $current_i18n = array(); 
    174174 
    175   public function getCurrent'.$className.'() 
    176   { 
    177     if (!isset($this->current_i18n[$this->culture])) 
    178     { 
    179       $obj = '.$className.'Peer::retrieveByPK($this->get'.$pk.'(), $this->culture); 
     175  public function getCurrent'.$className.'($culture = null) 
     176  { 
     177    if (is_null($culture)) 
     178    { 
     179      if (is_null($this->culture)) 
     180      { 
     181        throw new PropelException(sprintf(\'No culture is set for this "%s" object.\', get_class($this))); 
     182      } 
     183 
     184      $culture = $this->culture; 
     185    } 
     186 
     187    if (!isset($this->current_i18n[$culture])) 
     188    { 
     189      $obj = '.$className.'Peer::retrieveByPK($this->get'.$pk.'(), $culture); 
    180190      if ($obj) 
    181191      { 
    182         $this->set'.$className.'ForCulture($obj, $this->culture); 
     192        $this->set'.$className.'ForCulture($obj, $culture); 
    183193      } 
    184194      else 
    185195      { 
    186         $this->set'.$className.'ForCulture(new '.$className.'(), $this->culture); 
    187         $this->current_i18n[$this->culture]->set'.$culture.'($this->culture); 
    188       } 
    189     } 
    190  
    191     return $this->current_i18n[$this->culture]; 
     196        $this->set'.$className.'ForCulture(new '.$className.'(), $culture); 
     197        $this->current_i18n[$culture]->set'.$culture.'($culture); 
     198      } 
     199    } 
     200 
     201    return $this->current_i18n[$culture]; 
    192202  } 
    193203 
     
    231241    { 
    232242      $foreign_tables_i18n_table = $this->getDatabase()->getTable($foreign_table->getAttribute('i18nTable')); 
    233       $value .= ' || $this->'.$matches[2].'->getCurrent'.$foreign_tables_i18n_table->getPhpName().'()->isModified()'; 
     243      $value .= ' || ($this->'.$matches[2].'->getCulture() && $this->'.$matches[2].'->getCurrent'.$foreign_tables_i18n_table->getPhpName().'()->isModified())'; 
    234244    } 
    235245