function commerce_line_item_field_views_data in Commerce Core 7
Implements hook_field_views_data().
File
- modules/
line_item/ commerce_line_item.module, line 1602 - Defines the core Commerce line item entity and API functions interact with line items on orders.
Code
function commerce_line_item_field_views_data($field) {
$data = field_views_field_default_views_data($field);
// Build an array of bundles the field appears on.
$bundles = array();
foreach ($field['bundles'] as $entity => $entity_bundles) {
$bundles[] = $entity . ' (' . implode(', ', $entity_bundles) . ')';
}
$replacements = array(
'!field_name' => $field['field_name'],
'@bundles' => implode(', ', $bundles),
);
foreach ($data as $table_name => $table_data) {
foreach ($table_data as $field_name => $field_data) {
if (isset($field_data['filter']['field_name']) && $field_name != 'delta') {
$data[$table_name][$field_name]['relationship'] = array(
'title' => t('Referenced line items'),
'label' => t('Line items referenced by !field_name', $replacements),
'help' => t('Relate this entity to line items referenced by its !field_name value.', $replacements) . '<br />' . t('Appears in: @bundles.', $replacements),
'base' => 'commerce_line_item',
'base field' => 'line_item_id',
'handler' => 'views_handler_relationship',
);
}
}
}
return $data;
}