protected function CommerceEntityViewsData::processViewsDataForAddress in Commerce Core 8.2
Corrects the views data for address base fields.
Based on address_field_views_data().
Parameters
string $table: The table name.
\Drupal\Core\Field\FieldDefinitionInterface $field_definition: The field definition.
array $views_field: The views field data.
string $field_column_name: The field column being processed.
File
- src/
CommerceEntityViewsData.php, line 288
Class
- CommerceEntityViewsData
- Provides improvements to core's generic views integration for entities.
Namespace
Drupal\commerceCode
protected function processViewsDataForAddress($table, FieldDefinitionInterface $field_definition, array &$views_field, $field_column_name) {
$handlers_by_property = [
'country_code' => 'country',
'administrative_area' => 'subdivision',
'locality' => 'subdivision',
'dependent_locality' => 'subdivision',
'postal_code' => 'standard',
'sorting_code' => 'standard',
'address_line1' => 'standard',
'address_line2' => 'standard',
'organization' => 'standard',
'given_name' => 'standard',
'additional_name' => 'standard',
'family_name' => 'standard',
];
if (!isset($handlers_by_property[$field_column_name])) {
return;
}
$views_field['field'] = [
'id' => $handlers_by_property[$field_column_name],
'field_name' => $field_definition
->getName(),
'property' => $field_column_name,
];
if ($field_column_name == 'country_code') {
$views_field['filter']['id'] = 'country';
$views_field['sort']['id'] = 'country';
}
elseif ($field_column_name == 'administrative_area') {
$views_field['filter']['id'] = 'administrative_area';
}
}