Returns an array of all tables from the query that map to an entity type.
Includes the base table and all relationships, if eligible. Available keys for each table:
array An array of table information, keyed by table alias.
function get_entity_tables() {
// Start with the base table.
$entity_tables = array();
$base_table_data = views_fetch_data($this->view->storage
->get('base_table'));
if (isset($base_table_data['table']['entity type'])) {
$entity_tables[$this->view->storage
->get('base_table')] = array(
'base' => $this->view->storage
->get('base_table'),
'relationship_id' => 'none',
'entity_type' => $base_table_data['table']['entity type'],
'revision' => FALSE,
);
}
// Include all relationships.
foreach ($this->view->relationship as $relationship_id => $relationship) {
$table_data = views_fetch_data($relationship->definition['base']);
if (isset($table_data['table']['entity type'])) {
$entity_tables[$relationship->alias] = array(
'base' => $relationship->definition['base'],
'relationship_id' => $relationship_id,
'entity_type' => $table_data['table']['entity type'],
'revision' => FALSE,
);
}
}
// Determine which of the tables are revision tables.
foreach ($entity_tables as $table_alias => $table) {
$info = entity_get_info($table['entity_type']);
if (isset($info['revision table']) && $info['revision table'] == $table['base']) {
$entity_tables[$table_alias]['revision'] = TRUE;
}
}
return $entity_tables;
}