function civicrm_entity_civicrm_contact_label_callback in CiviCRM Entity 7.2
Same name and namespace in other branches
- 7 civicrm_entity.module \civicrm_entity_civicrm_contact_label_callback()
Label callback for civicrm_contact entity type.
drupal_alter('civicrm_entity_' . $entity, $, $alterable2, $context);
_type
Parameters
$entity:
Return value
null|string
File
- ./
civicrm_entity.module, line 2771
Code
function civicrm_entity_civicrm_contact_label_callback($entity, $entity_type) {
$label = isset($entity->display_name) ? $entity->display_name : '';
$contact_label_setting = variable_get('civicrm_entity_contact_label_format', 'legacy');
if ($contact_label_setting == 'legacy') {
// drupal_alter('civicrm_entity_contact_label', $label, $entity);
if (isset($entity->email) && !empty($entity->email)) {
$label = t('!label <!email>', [
'!label' => $label,
'!email' => $entity->email,
]);
}
elseif (isset($entity->phone) && !empty($entity->phone)) {
$label = t('!label <!phone>', [
'!label' => $label,
'!phone' => $entity->phone,
]);
}
elseif (isset($entity->im) && !empty($entity->im)) {
$label = t('!label <!im>', [
'!label' => $label,
'!im' => $entity->im,
]);
}
}
elseif ($contact_label_setting == 'display_name_email' && !empty($entity->email)) {
$label = t('!label <!email>', [
'!label' => $label,
'!email' => $entity->email,
]);
}
elseif ($contact_label_setting == 'display_name_phone' && !empty($entity->phone)) {
$label = t('!label <!phone>', [
'!label' => $label,
'!phone' => $entity->phone,
]);
}
elseif ($contact_label_setting == 'display_name_im' && !empty($entity->im)) {
$label = t('!label <!im>', [
'!label' => $label,
'!im' => $entity->im,
]);
}
return $label;
}