Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fix: port PR #241 from Propel

  • Loading branch information...
commit fdca1999b3f303e81d516d00a984dfdb1206818d 1 parent 99034da
Kévin Gomez K-Phoen authored willdurand committed
2  src/Propel/Generator/Behavior/I18n/I18nBehaviorObjectBuilderModifier.php
@@ -209,7 +209,7 @@ public function objectFilter(&$script, $builder)
209 209 $pattern = '/public function add' . $i18nTablePhpName . '.*[\r\n]\s*\{/';
210 210 $addition = "
211 211 if (\$l && \$locale = \$l->get$localeColumnName()) {
212   - \$this->set$localeColumnName(\$locale);
  212 + \$this->set{$localeColumnName}(\$locale);
213 213 \$this->currentTranslations[\$locale] = \$l;
214 214 }";
215 215 $replacement = "\$0$addition";
24 tests/Propel/Tests/Generator/Behavior/I18n/I18nBehaviorObjectBuilderModifierTest.php
@@ -76,6 +76,16 @@ public function setUp()
76 76 <reference local="movie_id" foreign="id" />
77 77 </foreign-key>
78 78 </table>
  79 +
  80 + <table name="i18n_behavior_test_local_column">
  81 + <column name="id" primaryKey="true" type="INTEGER" autoIncrement="true" />
  82 + <column name="foo" type="INTEGER" />
  83 + <column name="bar" type="VARCHAR" size="100" />
  84 + <behavior name="i18n">
  85 + <parameter name="i18n_columns" value="bar" />
  86 + <parameter name="locale_column" value="my_lang" />
  87 + </behavior>
  88 + </table>
79 89 </database>
80 90 EOF;
81 91 QuickBuilder::buildSchema($schema);
@@ -389,4 +399,18 @@ public function testI18nWithRelations2()
389 399 $count = \MovieI18nQuery::create()->count();
390 400 $this->assertEquals(0, $count, '0 i18n movies');
391 401 }
  402 +
  403 + public function testUseLocalColumnParameter()
  404 + {
  405 + $o = new \I18nBehaviorTestLocalColumn();
  406 + $translation1 = new \I18nBehaviorTestLocalColumnI18n();
  407 + $translation1->setMyLang('en_EN');
  408 + $o->addI18nBehaviorTestLocalColumnI18n($translation1);
  409 + $translation2 = new \I18nBehaviorTestLocalColumnI18n();
  410 + $translation2->setMyLang('fr_FR');
  411 + $o->addI18nBehaviorTestLocalColumnI18n($translation2);
  412 + $o->save();
  413 + $this->assertEquals($translation1, $o->getTranslation('en_EN'));
  414 + $this->assertEquals($translation2, $o->getTranslation('fr_FR'));
  415 + }
392 416 }

0 comments on commit fdca199

Please sign in to comment.
Something went wrong with that request. Please try again.