geocoder.api.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /**
  3. * @file
  4. * geocoder.api.php
  5. */
  6. /**
  7. * Implements hook_entity_property_info_alter().
  8. *
  9. * Give Users a virtual property that contains all relevant address information
  10. * from multiple sources.
  11. */
  12. function hook_entity_property_info_alter(&$info) {
  13. $info['user']['bundles']['user']['properties']['full_address'] = array(
  14. 'type' => 'text',
  15. 'label' => 'Full adress (from other fields)',
  16. 'getter callback' => 'YOURMOD_user_full_address',
  17. );
  18. }
  19. /**
  20. * Entity property callback for user.full_address.
  21. *
  22. * Field_address is a text field, and when combined with a variable makes the
  23. * full address.
  24. */
  25. function hook_user_full_address($entity, $options, $field, $entity_type, $property) {
  26. return $entity->field_address[LANGUAGE_NONE][0]['value'] . ', ' . variable_get('YOURMOD_global_country', 'Zimbabwe');
  27. }
  28. /**
  29. * Implements hook_geocoder_geocode_values_alter().
  30. *
  31. * Alter the source values before geocode them.
  32. */
  33. function hook_geocoder_geocode_values_alter(&$source_field_values, $field_info, $handler_settings, $field_instance) {
  34. foreach ($source_field_values as $key => $value) {
  35. $source_field_values[$key]['administrative_area'] = 'Ciudad de Buenos Aires';
  36. }
  37. }