function commerce_price_field_views_data in Commerce Core 8.2
Same name and namespace in other branches
- 7 modules/price/includes/views/commerce_price.views.inc \commerce_price_field_views_data()
Implements hook_field_views_data().
Views integration for price fields.
File
- modules/
price/ commerce_price.views.inc, line 17 - Provide Views data for the Price module.
Code
function commerce_price_field_views_data(FieldStorageConfigInterface $field_storage) {
$data = views_field_default_views_data($field_storage);
$field_name = $field_storage
->getName();
foreach ($data as $table_name => $table_data) {
if (isset($table_data[$field_name])) {
$data[$table_name][$field_name . '_number']['field'] = [
'id' => 'numeric',
'field_name' => $table_data[$field_name]['field']['field_name'],
'entity_type' => $table_data[$field_name]['field']['entity_type'],
'label' => t('number from @field_name', [
'@field_name' => $field_name,
]),
];
$data[$table_name][$field_name . '_currency_code']['field'] = [
'id' => 'standard',
'field_name' => $table_data[$field_name]['field']['field_name'],
'entity_type' => $table_data[$field_name]['field']['entity_type'],
'label' => t('currency from @field_name', [
'@field_name' => $field_name,
]),
];
$data[$table_name][$field_name . '_currency_code']['filter']['id'] = 'commerce_currency';
}
}
return $data;
}