public static function EntityFieldHandlerHelper::query in Entity API 7
Add the field for the entity ID (if necessary).
9 calls to EntityFieldHandlerHelper::query()
- entity_views_handler_field_boolean::query in views/
handlers/ entity_views_handler_field_boolean.inc - Overridden to add the field for the entity ID (if necessary).
- entity_views_handler_field_date::query in views/
handlers/ entity_views_handler_field_date.inc - Overridden to add the field for the entity ID (if necessary).
- entity_views_handler_field_duration::query in views/
handlers/ entity_views_handler_field_duration.inc - Overridden to add the field for the entity ID (if necessary).
- entity_views_handler_field_entity::query in views/
handlers/ entity_views_handler_field_entity.inc - Overridden to add the field for the entity ID (if necessary).
- entity_views_handler_field_field::query in views/
handlers/ entity_views_handler_field_field.inc - Overridden to add the field for the entity ID (if necessary).
File
- views/
handlers/ entity_views_field_handler_helper.inc, line 75 - Contains the EntityFieldHandlerHelper class.
Class
- EntityFieldHandlerHelper
- Helper class containing static implementations of common field handler methods.
Code
public static function query($handler) {
// Copied over from views_handler_field_entity::query().
// Sets table_alias (entity table), base_field (entity id field) and
// field_alias (the field's alias).
$handler->table_alias = $base_table = $handler->view->base_table;
$handler->base_field = $handler->view->base_field;
if (!empty($handler->relationship)) {
foreach ($handler->view->relationship as $relationship) {
if ($relationship->alias == $handler->relationship) {
$base_table = $relationship->definition['base'];
$handler->table_alias = $relationship->alias;
$table_data = views_fetch_data($base_table);
$handler->base_field = empty($relationship->definition['base field']) ? $table_data['table']['base']['field'] : $relationship->definition['base field'];
}
}
}
// Add the field if the query back-end implements an add_field() method,
// just like the default back-end.
if (method_exists($handler->query, 'add_field')) {
$handler->field_alias = $handler->query
->add_field($handler->table_alias, $handler->base_field, '');
}
else {
// To ensure there is an alias just set the field alias to the real field.
$handler->field_alias = $handler->real_field;
}
}