You are here

function sf_entity_entity_load in Salesforce Suite 7.2

Same name and namespace in other branches
  1. 7 sf_entity/sf_entity.module \sf_entity_entity_load()

Implements hook_entity_load().

File

sf_entity/sf_entity.module, line 122
Integrates fieldable entities with the Salesforce API.

Code

function sf_entity_entity_load(&$entities, $type) {
  $map =& drupal_static(__FUNCTION__ . '_map', array());
  if (empty($map)) {
    $items = salesforce_api_salesforce_fieldmap_load_all();
    foreach ($items as $item) {
      $map[$item->drupal_entity . '-' . $item->drupal_bundle] = TRUE;
    }
  }
  foreach ($entities as $entity) {
    list($oid, $vid, $bundle) = entity_extract_ids($type, $entity);
    if (isset($map[$type . '-' . $bundle])) {
      $result = salesforce_api_id_load($oid, $type, $bundle);
      $entities[$oid]->salesforce = $result;
    }
  }
}