You are here

function hook_search_api_views_field_handler_mapping_alter in Search API 8

Alter the mapping of property types to their default Views field handlers.

This is used in the Search API Views integration to create Search API-specific field handlers for all properties of datasources and some entity types.

In addition to the definition returned here, for Field API fields, the "field_name" will be set to the field's machine name.

Parameters

array $mapping: An associative array with property data types as the keys and Views field handler definitions as the values (that is, just the inner "field" portion of Views data definition items). In some cases the value might also be NULL instead, to indicate that properties of this type shouldn't have field handlers. The data types in the keys might also contain asterisks (*) as wildcard characters. Data types with wildcards will be matched only if no specific type exists, and longer type patterns will be tried before shorter ones. The "*" mapping therefore is the default if no other match could be found.

Deprecated

in search_api:8.x-1.14 and is removed from search_api:2.0.0. Please use the "search_api.mapping_views_field_handlers" event instead.

See also

https://www.drupal.org/node/3059866

File

./search_api.api.php, line 255
Hooks provided by the Search API module.

Code

function hook_search_api_views_field_handler_mapping_alter(array &$mapping) {
  $mapping['field_item:string_long'] = [
    'id' => 'example_field',
  ];
  $mapping['example_property_type'] = [
    'id' => 'example_field',
    'some_option' => 'foo',
  ];
}