public static function gettermI18nsById($id, array $options = array()) { $criteria = new Criteria(); self::addtermI18nsCriteriaById($criteria, $id); return QubitTermI18n::get($criteria, $options); }
/** * Process form fields * * @param $field mixed symfony form widget * @return void */ protected function processField($field) { switch ($field->getName()) { case 'displayNote': case 'scopeNote': case 'sourceNote': $value = $filtered = $this->form->getValue($field->getName()); foreach ($this[$field->getName()] as $item) { if (isset($value[$item->id])) { $item->content = $value[$item->id]; unset($filtered[$item->id]); } else { $item->delete(); } } foreach ($filtered as $item) { $note = new QubitNote(); $note->content = $item; switch ($field->getName()) { case 'scopeNote': $note->typeId = QubitTerm::SCOPE_NOTE_ID; break; case 'sourceNote': $note->typeId = QubitTerm::SOURCE_NOTE_ID; break; case 'displayNote': $note->typeId = QubitTerm::DISPLAY_NOTE_ID; break; } $this->resource->notes[] = $note; } break; case 'name': if (!$this->resource->isProtected() && $this->resource->name != $this->form->getValue('name')) { $this->resource->name = $this->form->getValue('name'); $this->updatedLabel = true; } break; case 'narrowTerms': foreach ($this->form->getValue('narrowTerms') as $item) { if (1 > strlen($item = trim($item))) { continue; } // Test to make sure term doesn't already exist $criteria = new Criteria(); $criteria->add(QubitTerm::TAXONOMY_ID, $this->resource->taxonomyId); $criteria->addJoin(QubitTerm::ID, QubitTermI18n::ID); $criteria->add(QubitTermI18n::CULTURE, $this->context->user->getCulture()); $criteria->add(QubitTermI18n::NAME, $item); if (0 < count(QubitTermI18n::get($criteria))) { continue; } // Add term as child $term = new QubitTerm(); $term->name = $item; $term->taxonomyId = $this->resource->taxonomyId; $this->resource->termsRelatedByparentId[] = $term; } break; case 'parent': $this->resource->parentId = QubitTerm::ROOT_ID; $value = $this->form->getValue('parent'); if (isset($value)) { $params = $this->context->routing->parse(Qubit::pathInfo($value)); $this->resource->parent = $params['_sf_route']->resource; } break; case 'taxonomy': unset($this->resource->taxonomy); $value = $this->form->getValue('taxonomy'); if (isset($value)) { $params = $this->context->routing->parse(Qubit::pathInfo($value)); $this->resource->taxonomy = $params['_sf_route']->resource; } break; case 'relatedTerms': $value = $filtered = array(); foreach ($this->form->getValue('relatedTerms') as $item) { $params = $this->context->routing->parse(Qubit::pathInfo($item)); $resource = $params['_sf_route']->resource; $value[$resource->id] = $filtered[$resource->id] = $resource; } foreach ($this->relations as $item) { if (isset($value[$item->objectId])) { unset($filtered[$item->objectId]); } else { $item->delete(); } } foreach ($filtered as $item) { $relation = new QubitRelation(); $relation->object = $item; $relation->typeId = QubitTerm::TERM_RELATION_ASSOCIATIVE_ID; $this->resource->relationsRelatedBysubjectId[] = $relation; } break; case 'useFor': $value = $filtered = $this->form->getValue('useFor'); foreach ($this->useFor as $item) { if (isset($value[$item->id])) { $item->name = $value[$item->id]; unset($filtered[$item->id]); } else { $item->delete(); } } foreach ($filtered as $item) { $otherName = new QubitOtherName(); $otherName->name = $item; $otherName->typeId = QubitTerm::ALTERNATIVE_LABEL_ID; $this->resource->otherNames[] = $otherName; } break; default: return parent::processField($field); } }