function views_handler_filter_entity_bundle::query
3.x views_handler_filter_entity_bundle.inc | views_handler_filter_entity_bundle::query() |
All entity types beside comment and taxonomy terms have a proper implement bundle, though these two need an additional join to node/vocab table to work as required.
Overrides views_handler_filter_in_operator::query
File
- handlers/
views_handler_filter_entity_bundle.inc, line 79 - Definition of views_handler_filter_entity_bundle
Class
- views_handler_filter_entity_bundle
- Filter class which allows to filter by certain bundles of an entity.
Code
function query() {
$this->ensure_my_table();
// Adjust the join for the comment case.
if ($this->entity_type == 'comment') {
$join = new views_join();
$def = array(
'table' => 'node',
'field' => 'nid',
'left_table' => $this->table_alias,
'left_field' => 'nid',
);
$join->definition = $def;
$join->construct();
$join->adjusted = TRUE;
$this->table_alias = $this->query->add_table('node', $this->relationship, $join);
$this->real_field = 'type';
// Replace the value to match the node type column.
foreach ($this->value as &$value) {
$value = str_replace('comment_node_', '', $value);
}
}
elseif ($this->entity_type == 'taxonomy_term') {
$join = new views_join();
$def = array(
'table' => 'taxonomy_vocabulary',
'field' => 'vid',
'left_table' => $this->table_alias,
'left_field' => 'vid',
);
$join->definition = $def;
$join->construct();
$join->adjusted = TRUE;
$this->table_alias = $this->query->add_table('taxonomy_vocabulary', $this->relationship, $join);
$this->real_field = 'machine_name';
}
else {
$entity_info = entity_get_info($this->entity_type);
$this->real_field = $entity_info['bundle keys']['bundle'];
}
parent::query();
}