function other_view_filter_views_data_alter in OtherView Filter 8
Same name and namespace in other branches
- 7 other_view_filter.views.inc \other_view_filter_views_data_alter()
Implements hook_views_data_alter().
File
- ./
other_view_filter.views.inc, line 14 - Views hooks for Other View filter module.
Code
function other_view_filter_views_data_alter(array &$data) {
$definitions = \Drupal::entityTypeManager()
->getDefinitions();
foreach ($definitions as $definition) {
if ($definition instanceof ContentEntityType) {
$field = $definition
->getKey('id');
$table = $definition
->getDataTable();
$table = $table ? $table : $definition
->getBaseTable();
if ($field && $table && isset($data[$table])) {
$data[$table]['other_view_filter'] = [
'title' => t('Other view result'),
'help' => t('Filters this view against results of selected other view.'),
'real field' => $field,
'filter' => [
'title' => t('Other view result'),
'help' => t('Filters this view against results of selected other view.'),
'field' => $field,
'id' => 'other_views_filter',
],
];
}
}
}
if (\Drupal::moduleHandler()
->moduleExists('search_api')) {
$indexes = \Drupal::entityTypeManager()
->getStorage('search_api_index')
->loadMultiple();
foreach ($indexes as $index) {
if ($index instanceof IndexInterface) {
$table = 'search_api_index_' . $index
->id();
if (isset($data[$table])) {
$data[$table]['other_view_filter'] = [
'title' => t('Other view result'),
'help' => t('Filters this view against results of selected other view.'),
'real field' => 'search_api_id',
'filter' => [
'title' => t('Other view result'),
'help' => t('Filters this view against results of selected other view.'),
'field' => 'search_api_id',
'id' => 'other_views_filter',
],
];
}
}
}
}
}