/** * Implementation of filterSet() to call set on Translation relationship to allow * access to I18n properties from the main object. * * @param Doctrine_Record $record * @param string $name Name of the property * @param string $value Value of the property * @return void */ public function filterSet(Doctrine_Record $record, $fieldName, $value) { $translation = $record->get('Translation'); $culture = myDoctrineRecord::getDefaultCulture(); if ($translation->contains($culture)) { $i18n = $record->get('Translation')->get($culture); } else { $i18n = $record->get('Translation')->get($culture); /* * If translation is new * populate it with i18n fallback */ if ($i18n->state() == Doctrine_Record::STATE_TDIRTY) { if ($fallback = $record->getI18nFallBack()) { $fallBackData = $fallback->toArray(); unset($fallBackData['id'], $fallBackData['lang']); $i18n->fromArray($fallBackData); } } } if (!ctype_lower($fieldName) && !$i18n->contains($fieldName)) { $underscoredFieldName = dmString::underscore($fieldName); if (strpos($underscoredFieldName, '_') !== false && $i18n->contains($underscoredFieldName)) { $fieldName = $underscoredFieldName; } } $i18n->set($fieldName, $value); return $value; }