public function metatag_handler_field_entity::query in Metatag 7
Heavily modified code from views_hander_field_field::query().
By default, the only columns added to the query are entity_id and entity_type. This is because other needed data is fetched by entity_load().
Overrides views_handler_field::query
File
- views/
metatag_handler_field_entity.inc, line 76 - Main handler for Metatag data.
Class
- metatag_handler_field_entity
- Class metatag_handler_entity.
Code
public function query() {
parent::query();
$base_table = $this
->get_base_table();
$base_table_alias = isset($this->relationship) ? $this->relationship : $base_table;
$entity_type = _metatag_entity_type_from_table($base_table);
$entity_info = entity_get_info($entity_type);
$this->entity_id_alias = $this->query
->add_field($base_table_alias, $entity_info['entity keys']['id']);
// The alias needs to be unique, so we use both the field table and the
// entity type.
// @todo Probably not necessary for this use case?
$entity_type_alias = $this->table_alias . '_' . $entity_type . '_entity_type';
$this->entity_type_alias = $this->query
->add_field(NULL, "'{$entity_type}'", $entity_type_alias);
}