table); $this->entity_type = $table_data['table']['entity type']; } /** * Overriden to add the field for the entity id. */ function query() { $this->table_alias = $base_table = $this->view->base_table; $this->base_field = $this->view->base_field; if (!empty($this->relationship)) { foreach ($this->view->relationship as $relationship) { if ($relationship->alias == $this->relationship) { $base_table = $relationship->definition['base']; $this->table_alias = $relationship->alias; $table_data = views_fetch_data($base_table); $this->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($this->query, 'add_field')) { $this->field_alias = $this->query->add_field($this->table_alias, $this->base_field, ''); } $this->add_additional_fields(); } /** * Load the entities for all rows that are about to be displayed. */ function pre_render(&$values) { if (!empty($values)) { list($this->entity_type, $this->entities) = $this->query->get_result_entities($values, !empty($this->relationship) ? $this->relationship : NULL, $this->field_alias); } } /** * Overridden to return the entity object, or a certain property of the entity. */ function get_value($values, $field = NULL) { if (isset($this->entities[$this->view->row_index])) { $entity = $this->entities[$this->view->row_index]; // Support to get a certain part of the entity. if (isset($field) && isset($entity->{$field})) { return $entity->{$field}; } // Support to get a part of the values as the normal get_value. elseif (isset($field) && isset($values->{$this->aliases[$field]})) { return $values->{$this->aliases[$field]}; } else { return $entity; } } return FALSE; } }