You are here

function sarnia_views_data_alter in Sarnia 7

Implement hook_views_data().

Use a Sarnia-specific argument handler for the id field on views of Sarnia entities.

File

./sarnia.views.inc, line 53

Code

function sarnia_views_data_alter(&$data) {
  $entity_types = sarnia_entity_types();
  foreach ($entity_types as $entity_info) {
    $views_table = 'search_api_index_' . $entity_info['machine_name'];
    $data[$views_table]['table']['group'] = $entity_info['label'];
    if (!empty($data[$views_table]['id']['argument'])) {
      $data[$views_table]['id']['argument']['handler'] = 'SarniaViewsHandlerArgumentId';
      $data[$views_table]['id']['argument']['field_name'] = 'solr_document';
      $data[$views_table]['id']['argument']['solr_property'] = $entity_info['id_field'];
      $data[$views_table]['id']['argument']['search_api_index'] = $entity_info['search_api_index'];
      $data[$views_table]['id']['argument']['name table'] = $views_table;
      $data[$views_table]['id']['argument']['name field'] = 'solr_document';
    }
    $entity_views_table = 'views_entity_' . $entity_info['machine_name'];
    $data[$entity_views_table]['rendered_entity']['title'] = t('Debug output');
    $data[$entity_views_table]['rendered_entity']['help'] = t('Output a dump of all data recieved via Sarnia.');
    $data[$entity_views_table]['views_bulk_operations'] = array(
      'title' => $views_table,
      'group' => t('Bulk operations'),
      'help' => t('Provide a checkbox to select the row for bulk operations.'),
      'real field' => $entity_info['id_field'],
      'field' => array(
        'handler' => 'views_bulk_operations_handler_field_operations',
        'click sortable' => FALSE,
      ),
    );
  }
}