You are here

public function ViewsData::alterFieldViewsData in Plugin 8.2

Implements hook_field_views_data_alter().

File

src/ViewsData.php, line 113

Class

ViewsData
Provides/alters Views data.

Namespace

Drupal\plugin

Code

public function alterFieldViewsData(array &$data, FieldStorageConfigInterface $field_storage) {

  // Alters Views data for configurable "plugin" fields.
  if (strpos($field_storage
    ->getType(), 'plugin:') === 0) {
    $table_name = $field_storage
      ->getTargetEntityTypeId() . '__' . $field_storage
      ->getName();
    $plugin_id_column_name = $field_storage
      ->getName() . '_plugin_id';
    $plugin_configuration_column_name = $field_storage
      ->getName() . '_plugin_configuration';

    // Skip if there is no Views data for this field.
    if (!isset($data[$table_name][$plugin_id_column_name])) {
      return;
    }
    $this
      ->alterPluginFieldData($data, $field_storage, $table_name, $plugin_id_column_name, $plugin_configuration_column_name);
  }
}