You are here

function _ws_addressfield_map_address in Web Service Data 7

Map the data values to their address field containers

Maps values to the following array keys:

  • country
  • administrative_area
  • sub_administrative_area
  • locality
  • dependent_locality
  • postal_code
  • thoroughfare
  • premise
  • sub_premise
  • organisation_name
  • name_line
  • first_name
  • last_name
  • data

Parameters

array $data [reference]: Data to parse

Return value

array Returns the structured array

1 call to _ws_addressfield_map_address()
ws_addressfield_wsfields_addressfield_data_alter in modules/ws_addressfield/ws_addressfield.module
Implements hook_wsfields_FIELD_TYPE_data_alter().

File

modules/ws_addressfield/ws_addressfield.module, line 72
Add support for addressfield to be used with web service fields

Code

function _ws_addressfield_map_address(&$data) {
  $address = array();

  // @todo replace with call to field['columns'] to get container map
  $address['country'] = isset($data['country']) ? $data['country'] : NULL;
  $address['administrative_area'] = isset($data['administrative_area']) ? $data['administrative_area'] : NULL;
  $address['sub_administrative_area'] = isset($data['sub_administrative_area']) ? $data['sub_administrative_area'] : NULL;
  $address['locality'] = isset($data['locality']) ? $data['locality'] : NULL;
  $address['dependent_locality'] = isset($data['dependent_locality']) ? $data['dependent_locality'] : NULL;
  $address['postal_code'] = isset($data['postal_code']) ? $data['postal_code'] : NULL;
  $address['thoroughfare'] = isset($data['thoroughfare']) ? $data['thoroughfare'] : NULL;
  $address['premise'] = isset($data['premise']) ? $data['premise'] : NULL;
  $address['sub_premise'] = isset($data['sub_premise']) ? $data['sub_premise'] : NULL;
  $address['organisation_name'] = isset($data['organisation_name']) ? $data['organisation_name'] : NULL;
  $address['name_line'] = isset($data['name_line']) ? $data['name_line'] : NULL;
  $address['first_name'] = isset($data['first_name']) ? $data['first_name'] : NULL;
  $address['last_name'] = isset($data['last_name']) ? $data['last_name'] : NULL;
  $address['data'] = isset($data['data']) ? $data['data'] : NULL;
  return $address;
}