Term::_findByVocabulary PHP Méthode

_findByVocabulary() protected méthode

protected _findByVocabulary ( $state, $query, $results = [] )
    protected function _findByVocabulary($state, $query, $results = array())
    {
        static $termsId = null;
        if (empty($query['vocabulary_id'])) {
            trigger_error(__d('croogo', '"vocabulary_id" key not found'));
        }
        if ($state == 'before') {
            $vocabularyAlias = $this->Vocabulary->field('alias', array('Vocabulary.id' => $query['vocabulary_id']));
            $termsId = $this->Vocabulary->Taxonomy->getTree($vocabularyAlias, array('key' => 'id', 'value' => 'title'));
            $defaultQuery = array('conditions' => array($this->escapeField() => array_keys($termsId)));
            return array_merge_recursive($defaultQuery, (array) $query);
        }
        $ordered = array_keys($termsId);
        $terms = array();
        foreach ($results as $tempTerm) {
            $term = $tempTerm;
            $id = $term[$this->alias][$this->primaryKey];
            $term[$this->alias]['indent'] = substr_count($termsId[$id], '_');
            $position = array_search($id, $ordered);
            $terms[$position] = $term;
        }
        ksort($terms);
        $termsId = null;
        return $terms;
    }