function TaxonomyTermController::buildQuery

Overrides DrupalDefaultEntityController::buildQuery

File

modules/taxonomy/taxonomy.module, line 1251

Class

TaxonomyTermController
Controller class for taxonomy terms.

Code

protected function buildQuery($ids, $conditions = array(), $revision_id = FALSE) {
    $query = parent::buildQuery($ids, $conditions, $revision_id);
    $query->addTag('translatable');
    $query->addTag('taxonomy_term_access');
    // When name is passed as a condition use LIKE.
    if (isset($conditions['name'])) {
        $query_conditions =& $query->conditions();
        foreach ($query_conditions as $key => $condition) {
            if (is_array($condition) && $condition['field'] == 'base.name') {
                $query_conditions[$key]['operator'] = 'LIKE';
                $query_conditions[$key]['value'] = db_like($query_conditions[$key]['value']);
            }
        }
    }
    // Add the machine name field from the {taxonomy_vocabulary} table.
    $query->innerJoin('taxonomy_vocabulary', 'v', 'base.vid = v.vid');
    $query->addField('v', 'machine_name', 'vocabulary_machine_name');
    return $query;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.