You are here

function salesforce_api_fieldmap_objects_load in Salesforce Suite 7

Same name and namespace in other branches
  1. 5.2 salesforce_api/salesforce_api.module \salesforce_api_fieldmap_objects_load()
  2. 6.2 salesforce_api/salesforce_api.module \salesforce_api_fieldmap_objects_load()
  3. 7.2 salesforce_api/salesforce_api.module \salesforce_api_fieldmap_objects_load()

Returns all or a subset of the objects defined via hook_sf_fieldmap().

Parameters

(string) $type: valid values: 'drupal' or 'salesforce' Specify a type to filter the return value to objects of that type.

(string) $entity: valid values: if $type == 'salesforce', this should also be 'salesforce' if $type == 'drupal', this should be a valid entity name Specify an entity name to filter the return value to that entity alone. If this parameter is supplied, you must specify a type.

(string) $bundle: Specify a bundle name to further filter the return value by bundle. If this parameter is supplied, you must specify an entity.

Return value

Return value structure depends on the arguments provided. If no arguments, all fieldmap objects will be returned. If $type is specified, only objects of that type will be returned, etc.

9 calls to salesforce_api_fieldmap_objects_load()
DrupalSalesforce::retrieve in salesforce_api/salesforce.class.inc
Retrieves an object from Salesforce with standard fields and any data in fields defined in the fieldmap object.
salesforce_api_fieldmap_add_form in salesforce_api/salesforce_api.admin.inc
Displays the form to add a fieldmap.
salesforce_api_fieldmap_edit_form in salesforce_api/salesforce_api.admin.inc
Displays the edit form for adding field associations to a fieldmap.
salesforce_api_fieldmap_edit_form_submit in salesforce_api/salesforce_api.admin.inc
FAPI submit handler for fieldmap editor
salesforce_api_fieldmap_export_create in salesforce_api/salesforce_api.module
Creates an object for export to Salesforce based on the supplied Drupal object and fieldmap.

... See full list

File

salesforce_api/salesforce_api.module, line 550
Defines an API that enables modules to interact with the Salesforce server.

Code

function salesforce_api_fieldmap_objects_load($type = NULL, $entity = NULL, $bundle = NULL) {
  static $objects = array();

  // If we have not yet cached the object definitions...
  if (empty($objects)) {

    // Find all the Drupal objects defined by hook_sf_fieldmap().
    $objects['drupal'] = module_invoke_all('fieldmap_objects', 'drupal');

    // Get all the Salesforce objects defined by hook_sf_fieldmap().
    $objects['salesforce'] = module_invoke_all('fieldmap_objects', 'salesforce');

    // Allow other modules to modify the object definitions.
    foreach (module_implements('fieldmap_objects_alter') as $module) {
      $function = $module . '_fieldmap_objects_alter';
      $function($objects);
    }
  }

  // If a particular object type was specified...
  if (!empty($type)) {

    // And a particular object was specified...
    if (!empty($entity)) {

      // Return that object definition if it exists or FALSE if it does not.
      if (!empty($bundle)) {
        if (isset($objects[$type][$entity][$bundle])) {
          return $objects[$type][$entity][$bundle];
        }
        else {
          return FALSE;
        }
      }
      else {
        if (isset($objects[$type][$entity])) {
          return $objects[$type][$entity];
        }
        else {
          return FALSE;
        }
      }
    }
    else {
      if (isset($objects[$type])) {
        return $objects[$type];
      }
      else {
        return FALSE;
      }
    }
  }
  return $objects;
}