You are here

function salesforce_api_fieldmap_objects_load in Salesforce Suite 5.2

Same name and namespace in other branches
  1. 6.2 salesforce_api/salesforce_api.module \salesforce_api_fieldmap_objects_load()
  2. 7 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

$type: Specify a type to filter the return value to objects of that type.

$name: Specify an object name to filter the return value to that object alone. If this parameter is supplied, you must specify the correct type as well.

Return value

An array of all objects sorted by type with no arguments. Otherwise an array of objects filtered as specified by the parameters.

10 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
salesforce_api_fieldmap_edit_form in salesforce_api/salesforce_api.admin.inc
salesforce_api_fieldmap_edit_form_submit in salesforce_api/salesforce_api.admin.inc
salesforce_api_fieldmap_export_create in salesforce_api/salesforce_api.module
Creates an object for export to Salesforce based on the supplied source object and fieldmap.

... See full list

File

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

Code

function salesforce_api_fieldmap_objects_load($type = NULL, $name = 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($name)) {

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

      // If no object was specified, return all objects of the specified type or
      // FALSE if the type does not exist
      if (isset($objects[$type])) {
        return $objects[$type];
      }
      else {
        return FALSE;
      }
    }
  }
  return $objects;
}