You are here

public function CRMCoreContactEntity::match in CRM Core 7

Method for de-duplicating contacts.

Allows various modules to identify duplicate contact records through hook_crm_core_contact_match. This function should implement it's own contact matching scheme.

Return value

array Array of matched contact IDs.

File

modules/crm_core_contact/includes/crm_core_contact.controller.inc, line 31
Controller class for contacts.

Class

CRMCoreContactEntity
CRM Contact Entity Class.

Code

public function match() {
  $checks =& drupal_static(__FUNCTION__);
  $matches = array();
  if (!isset($checks->processed)) {
    $checks = new stdClass();
    $checks->engines = module_implements('crm_core_contact_match');
    $checks->processed = 1;
  }

  // Pass in the contact and the matches array as references.
  // This will allow various matching tools to modify the contact
  // and the list of matches.
  $values = array(
    'contact' => &$this,
    'matches' => &$matches,
  );
  foreach ($checks->engines as $module) {
    module_invoke($module, 'crm_core_contact_match', $values);
  }

  // It's up to implementing modules to handle the matching logic.
  // Most often, the match to be used should be the one
  // at the top of the stack.
  return $matches;
}