Term::_save PHP Method

_save() protected method

Save new/updated term data
protected _save ( array $data, integer $vocabularyId, integer $taxonomyId = null )
$data array Term data
$vocabularyId integer Vocabulary Id
$taxonomyId integer Taxonomy Id
    protected function _save($data, $vocabularyId, $taxonomyId = null)
    {
        $added = false;
        $termId = $this->saveAndGetId($data);
        if (!$this->isInVocabulary($termId, $vocabularyId, $taxonomyId)) {
            $this->setScopeForTaxonomy($vocabularyId);
            $dataToPersist = array('parent_id' => $data['Taxonomy']['parent_id'], 'term_id' => $termId, 'vocabulary_id' => $vocabularyId);
            if (!is_null($taxonomyId)) {
                $dataToPersist['id'] = $taxonomyId;
            }
            $added = $this->Taxonomy->save($dataToPersist);
        }
        return $added;
    }