You are here

function sf_prematch_sf_find_match in Salesforce Suite 7.2

Same name and namespace in other branches
  1. 6.2 sf_prematch/sf_prematch.module \sf_prematch_sf_find_match()
  2. 7 sf_prematch/sf_prematch.module \sf_prematch_sf_find_match()

Implements hook_sf_find_match().

Parameters

string $action:

stdClass $object:

array $map:

File

sf_prematch/sf_prematch.module, line 151
Extends Salesforce API module so checks for an existing match for an object before creating a new one.

Code

function sf_prematch_sf_find_match($action, $entity_name, $bundle_name, $object, $map) {
  if (is_object($map)) {
    $fieldmap_name = $map->name;
  }
  else {
    $fieldmap_name = $map;
  }
  $match_by = sf_prematch_match_by_load($fieldmap_name);
  if ($match_by['primary_field'] == '') {
    return;
  }
  require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'sf_prematch') . '/sf_prematch.main.inc';
  $map = salesforce_api_salesforce_fieldmap_load($fieldmap_name);
  switch ($action) {
    case 'export':
      $result = sf_prematch_export($entity_name, $bundle_name, $object, $map, $match_by);
      break;
    case 'import':
      $result = sf_prematch_import($entity_name, $bundle_name, $object, $map, $match_by);
      break;
    default:
      $result = NULL;
      break;
  }
  return $result;
}