function views_views_data_alter

views_views_data_alter(&$data)

Implements hook_views_data_alter().

Field modules can implement hook_field_views_data_views_data_alter() to alter the views data on a per field basis. This is weirdly named so as not to conflict with the \Drupal::moduleHandler()->alter('field_views_data') in views_views_data().

File

core/modules/views/views.views.inc, line 207
Provide views data that isn't tied to any other module.

Code

function views_views_data_alter(&$data) {
  $entity_manager = \Drupal::entityManager();
  if (!$entity_manager->hasDefinition('field_storage_config')) {
    return;
  }
  /** @var \Drupal\field\FieldStorageConfigInterface $field_storage */
  foreach ($entity_manager->getStorage('field_storage_config')->loadMultiple() as $field_storage) {
    if (_views_field_get_entity_type_storage($field_storage)) {
      $function = $field_storage->getTypeProvider() . '_field_views_data_views_data_alter';
      if (function_exists($function)) {
        $function($data, $field_storage);
      }
    }
  }
}

© 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!views!views.views.inc/function/views_views_data_alter/8.1.x