You are here

function civicrm_entity_action_load_contact in CiviCRM Entity 7

Same name and namespace in other branches
  1. 7.2 civicrm_entity.module \civicrm_entity_action_load_contact()

Parameters

$user:

Return value

mixed

Throws

CiviCRM_API3_Exception

1 call to civicrm_entity_action_load_contact()
civicrm_entity_action_load_create_contact in ./civicrm_entity.module

File

./civicrm_entity.module, line 854
Implement CiviCRM entities as a Drupal Entity.

Code

function civicrm_entity_action_load_contact($user) {
  if (!civicrm_initialize()) {
    return;
  }
  $contact_id = civicrm_api3('uf_match', 'getvalue', array(
    'uf_id' => $user->uid,
    'return' => 'contact_id',
    'domain_id' => CRM_Core_Config::domainID(),
  ));
  $entities = entity_load('civicrm_contact', array(
    $contact_id,
  ));
  return array(
    'civicrm_contact' => reset($entities),
  );
}