You are here

function rolereference_field_views_data in Role Reference 7

Implements hook_field_views_data().

In addition to the default field information we add the relationship for views to connect back to the role table.

File

./rolereference.module, line 223

Code

function rolereference_field_views_data($field) {
  $data = field_views_field_default_views_data($field);
  $storage = $field['storage']['details']['sql'];
  foreach ($storage as $age => $table_data) {
    $table = key($table_data);
    $columns = current($table_data);
    $id_column = $columns['rid'];
    if (isset($data[$table])) {
      $data[$table][$id_column]['relationship'] = array(
        'base' => 'role',
        'field' => $columns['rid'],
        'base field' => 'rid',
        'label' => $field['field_name'],
      );
    }
  }
  return $data;
}