function data_views_data in Data 8
Same name and namespace in other branches
- 6 data.views.inc \data_views_data()
- 7 data.views.inc \data_views_data()
Implements hook_views_data().
Dynamically create views integration for any table Data manages.
File
- ./
data.views.inc, line 12 - Views hooks and utility functions.
Code
function data_views_data() {
$data = array();
foreach (data_get_all_tables() as $table) {
/** @var \Drupal\data\Entity\TableConfigInterface $table */
if (!$table
->exists()) {
continue;
}
$table_name = $table
->id();
$data[$table_name] = [
'table' => [
'group' => t('Data: @table', [
'@table' => $table
->label(),
]),
'wizard_id' => 'data',
'base' => [
'field' => $table->table_schema[0]['name'],
'title' => $table->table_schema[0]['label'],
],
],
];
foreach ($table->table_schema as $column) {
$data[$table_name][$column['name']] = array(
'field' => array(
'id' => 'data_column',
),
'title' => $column['label'],
);
}
}
return $data;
}