hook_field_views_data(\Drupal\field\FieldStorageConfigInterface $field_storage)
Override the default Views data for a Field API field.
The field module's implementation of hook_views_data() invokes this for each field storage, in the module that defines the field type. It is not invoked in other modules.
If no hook implementation exists, hook_views_data() falls back to views_field_default_views_data().
Parameters
\Drupal\field\FieldStorageConfigInterface $field_storage: The field storage config entity.
Return value
array An array of views data, in the same format as the return value of hook_views_data().
See also
hook_field_views_data_views_data_alter()
Related topics
- Hooks
- Define functions that alter the behavior of Drupal core.
File
- core/modules/views/views.api.php, line 524
- Describes hooks and plugins provided by the Views module.
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | function hook_field_views_data(\Drupal\field\FieldStorageConfigInterface $field_storage ) { $data = views_field_default_views_data( $field_storage ); foreach ( $data as $table_name => $table_data ) { // Add the relationship only on the target_id field. $data [ $table_name ][ $field_storage ->getName() . '_target_id' ][ 'relationship' ] = array ( 'id' => 'standard' , 'base' => 'file_managed' , 'base field' => 'target_id' , 'label' => t( 'image from @field_name' , array ( '@field_name' => $field_storage ->getName())), ); } return $data ; } |
Please login to continue.