CRM-19784: Encapsulated interactions with geocoding providers. Adopts an
[civicrm-core.git] / CRM / Core / BAO / Address.php
index a3ca4343e130849098fc48ad5de155427c1c09f2..801d8a041e0751ea636b83364d109c7f49e16de2 100644 (file)
@@ -1340,4 +1340,24 @@ SELECT is_primary,
     return CRM_Core_PseudoConstant::get(__CLASS__, $fieldName, $params, $context);
   }
 
+  /**
+   * Add data from the configured geocoding provider.
+   *
+   * Generally this means latitude & longitude data.
+   *
+   * @param array $params
+   * @return bool
+   *   TRUE if params could be passed to a provider, else FALSE.
+   */
+  public static function addGeocoderData(&$params) {
+    try {
+      $provider = CRM_Utils_GeocodeProvider::getConfiguredProvider();
+    }
+    catch (CRM_Core_Exception $e) {
+      return FALSE;
+    }
+    $provider::format($params);
+    return TRUE;
+  }
+
 }