function hook_field_views_data_alter(array &
$data, \Drupal\field\FieldStorageConfigInterface
$field_storage) { $entity_type_id =
$field_storage->
getTargetEntityTypeId();
$field_name =
$field_storage->
getName();
$entity_type = \Drupal::
entityTypeManager()->
getDefinition($entity_type_id);
$pseudo_field_name = 'reverse_' .
$field_name . '_' .
$entity_type_id;
$table_mapping = \Drupal::
entityTypeManager()->
getStorage($entity_type_id)->
getTableMapping();
[$label] =
views_entity_field_label($entity_type_id,
$field_name);
$data['file_managed'
][$pseudo_field_name]['relationship'
] =
[ 'title' =>
t('@entity using @field',
['@entity' =>
$entity_type->
getLabel(), '@field' =>
$label]),
'help' =>
t('Relate each @entity with a @field set to the image.',
['@entity' =>
$entity_type->
getLabel(), '@field' =>
$label]),
'id' => 'entity_reverse',
'field_name' =>
$field_name,
'entity_type' =>
$entity_type_id,
'field table' =>
$table_mapping->
getDedicatedDataTableName($field_storage),
'field field' =>
$field_name . '_target_id',
'base' =>
$entity_type->
getBaseTable(),
'base field' =>
$entity_type->
getKey('id'
),