function file_field_views_data

file_field_views_data(FieldStorageConfigInterface $field_storage)

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/file.views.inc, line 18
Provide views data for file.module.

Code

function file_field_views_data(FieldStorageConfigInterface $field_storage) {
  $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'] = array(
      'id' => 'standard',
      'base' => 'file_managed',
      'entity type' => 'file',
      'base field' => 'fid',
      'label' => t('file from @field_name', array('@field_name' => $field_storage->getName())),
    );
  }

  return $data;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!file!file.views.inc/function/file_field_views_data/8.1.x