function FileViewsHooks::fieldViewsData
Implements hook_field_views_data().
Views integration for file fields. Adds a file relationship to the default field data.
See also
views_field_default_views_data()
File
-
core/
modules/ file/ src/ Hook/ FileViewsHooks.php, line 21
Class
- FileViewsHooks
- Hook implementations for file.
Namespace
Drupal\file\HookCode
public function fieldViewsData(FieldStorageConfigInterface $field_storage) : array {
$data = views_field_default_views_data($field_storage);
foreach ($data as $table_name => $table_data) {
// Add the relationship only on the fid field.
$data[$table_name][$field_storage->getName() . '_target_id']['relationship'] = [
'id' => 'standard',
'base' => 'file_managed',
'entity type' => 'file',
'base field' => 'fid',
'label' => t('file from @field_name', [
'@field_name' => $field_storage->getName(),
]),
];
}
return $data;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.