You are here

protected function CRMFeedsContactProcessor::entityLoad in CRM Core 7

Same name and namespace in other branches
  1. 8.3 modules/crm_core_contact/legacy/CRMFeedsContactProcessor.inc \CRMFeedsContactProcessor::entityLoad()
  2. 8 modules/crm_core_contact/legacy/CRMFeedsContactProcessor.inc \CRMFeedsContactProcessor::entityLoad()
  3. 8.2 modules/crm_core_contact/legacy/CRMFeedsContactProcessor.inc \CRMFeedsContactProcessor::entityLoad()

Loads an existing contact.

If the update existing method is not FEEDS_UPDATE_EXISTING, only the contact table will be loaded, foregoing the crm_core_contact_load API for better performance.

File

modules/crm_core_contact/includes/CRMFeedsContactProcessor.inc, line 49
Class definition of CRMFeedsContactProcessor.

Class

CRMFeedsContactProcessor
Creates contacts from feed items.

Code

protected function entityLoad(FeedsSource $source, $contact_id) {
  if ($this->config['update_existing'] == FEEDS_UPDATE_EXISTING) {
    $contact = crm_core_contact_load($contact_id, NULL, TRUE);
  }
  else {

    // We're replacing the existing contact. Only save the absolutely necessary.
    $contact = db_query("SELECT created, contact_id, vid, type FROM {crm_core_contact} WHERE contact_id = :contact_id", array(
      ':contact_id' => $contact_id,
    ))
      ->fetchObject();
    $contact->uid = $this->config['author'];
  }

  // Populate properties that are set by contact_object_prepare().
  if ($this->config['update_existing'] == FEEDS_UPDATE_EXISTING) {
    $contact->log = 'Updated by CRMFeedsContactProcessor';
  }
  else {
    $contact->log = 'Replaced by CRMFeedsContactProcessor';
  }
  return $contact;
}