Documentation

CRM_Dedupe_Finder
in package

The CiviCRM duplicate discovery engine is based on an algorithm designed by David Strauss <david@fourkitchens.com>.

Table of Contents

Methods

dupes()  : array<string|int, mixed>
Return a contact_id-keyed array of arrays of possible dupes (of the key contact_id) - limited to dupes of $cids if provided.
dupesByParams()  : array<string|int, mixed>
Return an array of possible dupes, based on the provided array of params, using the default rule group for the given contact type and usage.
dupesInGroup()  : array<string|int, mixed>
Return a contact_id-keyed array of arrays of possible dupes in the given group.
formatParams()  : array<string|int, mixed>
A hackish function needed to massage CRM_Contact_Form_$ctype::formRule() object into a valid $params array for dedupe
appendCustomDataFields()  : void
getTree()  : array<string|int, array<string|int, mixed>>
validateSubTypeByEntity()  : string
Validates contact subtypes and event types.

Methods

dupes()

Return a contact_id-keyed array of arrays of possible dupes (of the key contact_id) - limited to dupes of $cids if provided.

public static dupes(int $rgid[, array<string|int, mixed> $cids = [] ][, bool $checkPermissions = TRUE ]) : array<string|int, mixed>
Parameters
$rgid : int

Rule group id.

$cids : array<string|int, mixed> = []

Contact ids to limit the search to.

$checkPermissions : bool = TRUE

Respect logged in user permissions.

Tags
throws
CRM_Core_Exception
Return values
array<string|int, mixed>

Array of (cid1, cid2, weight) dupe triples

dupesByParams()

Return an array of possible dupes, based on the provided array of params, using the default rule group for the given contact type and usage.

public static dupesByParams(array<string|int, mixed> $params, string $ctype[, string $used = 'Unsupervised' ][, array<string|int, mixed> $except = [] ][, int $ruleGroupID = NULL ]) : array<string|int, mixed>

check_permission is a boolean flag to indicate if permission should be considered. default is to always check permissioning but public pages for example might not want permission to be checked for anonymous users. Refer CRM-6211. We might be breaking Multi-Site dedupe for public pages.

Parameters
$params : array<string|int, mixed>

Array of params of the form $params[$table][$field] == $value.

$ctype : string

Contact type to match against.

$used : string = 'Unsupervised'

Dedupe rule group usage ('Unsupervised' or 'Supervised' or 'General').

$except : array<string|int, mixed> = []

Array of contacts that shouldn't be considered dupes.

$ruleGroupID : int = NULL

The id of the dedupe rule we should be using.

Tags
throws
CRM_Core_Exception
Return values
array<string|int, mixed>

matching contact ids

dupesInGroup()

Return a contact_id-keyed array of arrays of possible dupes in the given group.

public static dupesInGroup(int $rgid, int $gid[, int $searchLimit = 0 ]) : array<string|int, mixed>
Parameters
$rgid : int

Rule group id.

$gid : int

Contact group id.

$searchLimit : int = 0

Limit for the number of contacts to be used for comparison. The search methodology finds all matches for the searchedContacts so this limits the number of searched contacts, not the matches found.

Tags
throws
CRM_Core_Exception
Return values
array<string|int, mixed>

array of (cid1, cid2, weight) dupe triples

formatParams()

A hackish function needed to massage CRM_Contact_Form_$ctype::formRule() object into a valid $params array for dedupe

public static formatParams(array<string|int, mixed> $fields, string $ctype) : array<string|int, mixed>
Parameters
$fields : array<string|int, mixed>

Contact structure from formRule().

$ctype : string

Contact type of the given contact.

Tags
throws
CRM_Core_Exception
Return values
array<string|int, mixed>

valid $params array for dedupe

appendCustomDataFields()

private static appendCustomDataFields(array<string|int, mixed> &$fields, array<string|int, mixed> &$flat, string $ctype) : void
Parameters
$fields : array<string|int, mixed>
$flat : array<string|int, mixed>
$ctype : string
Tags
throws
CRM_Core_Exception

getTree()

private static getTree(string $entityType, array<string|int, mixed> $subTypes, array<string|int, mixed> $params) : array<string|int, array<string|int, mixed>>

Function demonstrates just how bad code can get from 20 years of entropy.

This function takes an overcomplicated set of params and returns an overcomplicated mix of custom groups, custom fields, custom values (if passed $entityID), and other random stuff.

Parameters
$entityType : string

Of the contact whose contact type is needed.

$subTypes : array<string|int, mixed>
$params : array<string|int, mixed>
Tags
throws
CRM_Core_Exception
see
CRM_Core_BAO_CustomGroup::getAll()

for a better alternative to fetching a tree of custom groups and fields.

see
APIv4::get()

for a better alternative to fetching entity values.

Return values
array<string|int, array<string|int, mixed>>

The returned array is keyed by group id and has the custom group table fields and a subkey 'fields' holding the specific custom fields. If entityId is passed in the fields keys have a subkey 'customValue' which holds custom data if set for the given entity. This is structured as an array of values with each one having the keys 'id', 'data'

validateSubTypeByEntity()

Validates contact subtypes and event types.

private static validateSubTypeByEntity(string $entityType, string $subType) : string

Performs case-insensitive matching of strings and outputs the correct case. e.g. an input of "meeting" would output "Meeting".

For all other entities, it doesn't validate except to check the subtype is an integer.

Parameters
$entityType : string
$subType : string
Tags
throws
CRM_Core_Exception
Return values
string

        
On this page

Search results