Development

Changeset 10070

You must first sign up to be able to contribute.

Changeset 10070

Show
Ignore:
Timestamp:
07/02/08 16:53:50 (2 months ago)
Author:
francois
Message:

sfPropelFinderPlugin I18n tweaking

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfPropelFinderPlugin/lib/sfPropelFinder.php

    r10069 r10070  
    573573  } 
    574574   
    575   public function withI18n(
     575  public function withI18n($culture = null
    576576  { 
    577577    $i18nClass = $this->class.'I18n'; 
    578578    $tmp = new $i18nClass(); 
    579579    $i18nPeerClass = get_class($tmp->getPeer()); 
    580     $culture = sfContext::getInstance()->getUser()->getCulture(); 
     580    if(is_null($culture)) $culture = sfContext::getInstance()->getUser()->getCulture(); 
    581581    $this->addWithClass($this->class.'I18n'); 
    582582    $this->criteria->add(constant($i18nPeerClass.'::CULTURE'), $culture); 
  • plugins/sfPropelFinderPlugin/test/unit/sfPropelFinderTest.php

    r10068 r10070  
    6565ArticlePeer::doDeleteAll(); 
    6666 
    67 $t = new lime_test(139, new lime_output_color()); 
     67$t = new lime_test(140, new lime_output_color()); 
    6868 
    6969$t->diag('find()'); 
     
    745745$t->is($article->getContent(), 'contenu français', 'withI18n() considers the current user culture for hydration'); 
    746746 
     747sfContext::getInstance()->getUser()->setCulture('fr'); 
     748$article = sfPropelFinder::from('Article')-> 
     749  withI18n('en')-> 
     750  findOne(); 
     751$t->is($article->getContent(), 'english content', 'withI18n() accepts a culture parameter to override the user culture'); 
     752 
    747753sfContext::getInstance()->getUser()->setCulture('en'); 
    748754$finder = sfPropelFinder::from('Article')->with('I18n'); 
     
    872878$t->is(sfPropelFinder::from('Article')->where('Title', 'updated title')->count(), 1, 'set() updates only the records found based on the array of values'); 
    873879 
    874  
    875880try 
    876881{