You are here

function wsdata_field_views_data_alter in Web Service Data 8

Same name and namespace in other branches
  1. 2.0.x modules/wsdata_field/wsdata_field.module \wsdata_field_views_data_alter()

Implements hook_views_data_alter().

File

modules/wsdata_field/wsdata_field.module, line 150
Main module file for wsdata_field.

Code

function wsdata_field_views_data_alter(array &$data) {
  $wsfield_configs = \Drupal::service('entity_type.manager')
    ->getStorage('wsfield_config')
    ->loadMultiple();
  foreach ($wsfield_configs as $wsfield_config) {

    // Load the field name to generate the views fields.
    $field_name = $wsfield_config
      ->id();
    $data['node'][$field_name] = [
      'title' => $field_name,
      'help' => t('WSdata field.'),
      'field' => [
        'title' => $field_name,
        'id' => 'wsdata_field_views',
      ],
    ];
  }
}