|
Revision 14472, 1.8 kB
(checked in by Jonathan.Wage, 4 years ago)
|
[1.2] sfDoctrinePlugin: fixes issue where i18n doesn't fall back to default culture (fixes #5458)
|
| Line | |
|---|
| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
class sfDoctrineRecordI18nFilter extends Doctrine_Record_Filter |
|---|
| 21 |
{ |
|---|
| 22 |
public function init() |
|---|
| 23 |
{ |
|---|
| 24 |
} |
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
* Implementation of filterSet() to call set on Translation relationship to allow |
|---|
| 28 |
* access to I18n properties from the main object. |
|---|
| 29 |
* |
|---|
| 30 |
* @param Doctrine_Record $record |
|---|
| 31 |
* @param string $name Name of the property |
|---|
| 32 |
* @param string $value Value of the property |
|---|
| 33 |
* @return void |
|---|
| 34 |
*/ |
|---|
| 35 |
public function filterSet(Doctrine_Record $record, $name, $value) |
|---|
| 36 |
{ |
|---|
| 37 |
return $record['Translation'][sfDoctrineRecord::getDefaultCulture()][$name] = $value; |
|---|
| 38 |
} |
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
* Implementation of filterGet() to call get on Translation relationship to allow |
|---|
| 42 |
* access to I18n properties from the main object. |
|---|
| 43 |
* |
|---|
| 44 |
* @param Doctrine_Record $record |
|---|
| 45 |
* @param string $name Name of the property |
|---|
| 46 |
* @param string $value Value of the property |
|---|
| 47 |
* @return void |
|---|
| 48 |
*/ |
|---|
| 49 |
public function filterGet(Doctrine_Record $record, $name) |
|---|
| 50 |
{ |
|---|
| 51 |
$culture = sfDoctrineRecord::getDefaultCulture(); |
|---|
| 52 |
if (isset($record['Translation'][$culture])) |
|---|
| 53 |
{ |
|---|
| 54 |
return $record['Translation'][$culture][$name]; |
|---|
| 55 |
} else { |
|---|
| 56 |
$defaultCulture = sfConfig::get('sf_default_culture'); |
|---|
| 57 |
return $record['Translation'][$defaultCulture][$name]; |
|---|
| 58 |
} |
|---|
| 59 |
} |
|---|
| 60 |
} |
|---|