function taxonomy_entity_query_alter
taxonomy_entity_query_alter($query)
Implements hook_entity_query_alter().
Converts EntityFieldQuery instances on taxonomy terms that have an entity condition on term bundles (vocabulary machine names). Since the vocabulary machine name is not present in the {taxonomy_term_data} table itself, we have to convert the bundle condition into a property condition of vocabulary IDs to match against {taxonomy_term_data}.vid.
File
- modules/taxonomy/taxonomy.module, line 2038
- Enables the organization of content into categories.
Code
function taxonomy_entity_query_alter($query) { $conditions = &$query->entityConditions; // Alter only taxonomy term queries with bundle conditions. if (isset($conditions['entity_type']) && $conditions['entity_type']['value'] == 'taxonomy_term' && isset($conditions['bundle'])) { // Convert vocabulary machine names to vocabulary IDs. $vocabulary_data = taxonomy_vocabulary_get_names(); $vids = array(); if (is_array($conditions['bundle']['value'])) { foreach ($conditions['bundle']['value'] as $vocabulary_machine_name) { $vids[] = $vocabulary_data[$vocabulary_machine_name]->vid; } } else { $vocabulary_machine_name = $conditions['bundle']['value']; $vids = $vocabulary_data[$vocabulary_machine_name]->vid; } $query->propertyCondition('vid', $vids, $conditions['bundle']['operator']); unset($conditions['bundle']); } }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!taxonomy!taxonomy.module/function/taxonomy_entity_query_alter/7.x