public function FieldHandlerBase::match in CRM Core 8.3
Same name and namespace in other branches
- 8 modules/crm_core_match/src/Plugin/crm_core_match/field/FieldHandlerBase.php \Drupal\crm_core_match\Plugin\crm_core_match\field\FieldHandlerBase::match()
- 8.2 modules/crm_core_match/src/Plugin/crm_core_match/field/FieldHandlerBase.php \Drupal\crm_core_match\Plugin\crm_core_match\field\FieldHandlerBase::match()
Executes the match query.
@code array( $contact_id => array( $rule_id => $core, ), ); @end
Parameters
\Drupal\crm_core_contact\ContactInterface $contact: The contact entity to find matches for.
string $property: The name of the property.
Return value
array An array containing the found matches. The first level keys are the contact ids found as matches. The second level key is the rule id responsible for the match containing its score as value.
Overrides FieldHandlerInterface::match
2 methods override FieldHandlerBase::match()
- DateFieldHandler::match in modules/
crm_core_match/ src/ Plugin/ crm_core_match/ field/ DateFieldHandler.php - @todo Update to new query API.
- NameFieldHandler::match in modules/
crm_core_match/ src/ Plugin/ crm_core_match/ field/ NameFieldHandler.php - Executes the match query.
File
- modules/
crm_core_match/ src/ Plugin/ crm_core_match/ field/ FieldHandlerBase.php, line 157
Class
- FieldHandlerBase
- Class FieldHandlerBase.
Namespace
Drupal\crm_core_match\Plugin\crm_core_match\fieldCode
public function match(ContactInterface $contact, $property = 'value') {
$ids = [];
$field = $this->field
->getName();
$needle = $contact
->get($field)->{$property};
$query = $this->entityTypeManager
->getStorage('crm_core_individual')
->getQuery();
if (!empty($needle)) {
$query
->condition('type', $contact
->bundle());
if ($contact
->id()) {
$query
->condition('individual_id', $contact
->id(), '<>');
}
if ($field instanceof FieldConfigInterface) {
$field .= '.' . $property;
}
$query
->condition($field, $needle, $this
->getOperator($property));
$ids = $query
->execute();
}
// Get the score for this field/propery.
$score = [
$this->field
->getName() . '.' . $property => $this
->getScore($property),
];
// Returning an array holding the score as value and the contact id as key.
return array_fill_keys($ids, $score);
}