function media_acquiadam_views_data_alter in Media: Acquia DAM 8
Implements hook_views_data_alter().
File
- ./
media_acquiadam.module, line 421 - Integrates Drupal with Acquia DAM.
Code
function media_acquiadam_views_data_alter(array &$data) {
// The default source_field defined in MediaSource plugin.
$source_field = Drupal::service('plugin.manager.media.source')
->createInstance('acquiadam_asset')
->defaultConfiguration()['source_field'];
// The source field table contains the media item's asset id.
$source_field_table = 'media__' . $source_field;
// The asset id.
$source_field_asset_id = $source_field . '_value';
// Grouping display in Views UI.
$data[$source_field_table]['table']['group'] = t('Acquia DAM');
// Provide a relationship between source field and asset data tables.
$data[$source_field_table]['acquiadam_source_to_asset_data'] = [
'title' => t('Asset field to data'),
'help' => t('Creates a relationship between the media source field to the asset data.'),
'relationship' => [
'base' => 'acquiadam_assets_data',
'base field' => 'asset_id',
'field' => $source_field_asset_id,
'id' => 'standard',
'label' => t('Asset data'),
],
];
}