Closed (fixed)
Project:
Geocoder
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
11 Jun 2012 at 23:49 UTC
Updated:
12 Jul 2012 at 23:51 UTC
Jump to comment: Most recent file
Currently the geocoder widget includes fairly complex handling of field values. This handling is embedded in a hook implementation. Other modules however may have a use for geocoder's handling.
Pull the relevant code into a new function.
Needs review.
n/a
Introduces new function, geocoder_widget_get_field_value(), that returns the field value for a geocoded field.
Sample code:
if ($field_value = geocoder_widget_get_field_value($entity_type, $entity, $field_instance)) {
$values = reset($field_value[LANGUAGE_NONE]);
}
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | geocoder-reuse-1627906-5.patch | 856 bytes | nedjo |
| #1 | geocode-reuse-1627906-1.patch | 7.92 KB | nedjo |
Comments
Comment #1
nedjoComment #2
phayes commentedJust looking at the code it looks good. Still need to apply and test.
Comment #3
nedjoWrote this because I needed it for #1627940: Add optional geocoding to map input widget.
A potentially confusing detail of the patch comes from the fact that the original function had three possible outcomes: do nothing, unset the existing field value, and assign a new field value. To handle all three, the new helper function returns one of three different values:
What each of these values means is not particularly intuitive. At the least, the return value should be documented in the phpdocs.
Comment #4
phayes commentedCommitted. Thanks Nedjo
Comment #5
nedjoMissed a variable in the new function that was set in the original one.
Comment #6
phayes commentedCommited.