geocoder.api.php in Geocoder 7
Same filename and directory in other branches
File
geocoder.api.phpView source
<?php
/**
* @file
* geocoder.api.php
*/
/**
* Implements hook_entity_property_info_alter().
*
* Give Users a virtual property that contains all relevant address information
* from multiple sources.
*/
function hook_entity_property_info_alter(&$info) {
$info['user']['bundles']['user']['properties']['full_address'] = array(
'type' => 'text',
'label' => 'Full adress (from other fields)',
'getter callback' => 'YOURMOD_user_full_address',
);
}
/**
* Entity property callback for user.full_address.
*
* Field_address is a text field, and when combined with a variable makes the
* full address.
*/
function hook_user_full_address($entity, $options, $field, $entity_type, $property) {
return $entity->field_address[LANGUAGE_NONE][0]['value'] . ', ' . variable_get('YOURMOD_global_country', 'Zimbabwe');
}
/**
* Implements hook_geocoder_geocode_values_alter().
*
* Alter the source values before geocode them.
*/
function hook_geocoder_geocode_values_alter(&$source_field_values, $field_info, $handler_settings, $field_instance) {
foreach ($source_field_values as $key => $value) {
$source_field_values[$key]['administrative_area'] = 'Ciudad de Buenos Aires';
}
}
Functions
Name | Description |
---|---|
hook_entity_property_info_alter | Implements hook_entity_property_info_alter(). |
hook_geocoder_geocode_values_alter | Implements hook_geocoder_geocode_values_alter(). |
hook_user_full_address | Entity property callback for user.full_address. |