protected function setTerm($name, $application, $values) { $object = Doctrine::getTable('SnsTerm')->findOneByNameAndApplication($name, $application); if (!$object) { $object = new SnsTerm(); $object->name = $name; $object->application = $application; } foreach ($values as $key => $value) { if (!$object->Translation[$key]->value) { $object->Translation[$key]->value = $value; } } $object->save(); }
public function set($name, $value, $culture = '', $application = '') { if (!$culture) { $culture = $this->culture; } if (!$application) { $application = $this->application; } if (!$culture || !$application) { return false; } $term = $this->createQuery()->andWhere('name = ?', $name)->andWhere('application = ?', $application)->andWhere('id IN (SELECT id FROM SnsTermTranslation WHERE lang = ?)', $culture)->fetchOne(); if (!$term) { $term = new SnsTerm(); $term->setName($name); $term->setLang($culture); $term->setApplication($application); } $term->setValue($value); return $term->save(); }