You are here

function salesforce_api_fieldmap_objects_load in Salesforce Suite 6.2

Same name and namespace in other branches
  1. 5.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.

16 calls to salesforce_api_fieldmap_objects_load()
drush_sf_import in sf_import/sf_import.drush.inc
Import data from Salesforce
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 787
Defines an API that enables modules to interact with the Salesforce server.

Code

function salesforce_api_fieldmap_objects_load($type = NULL, $name = NULL, $reset = FALSE) {
  static $objects = array();

  // If we have not yet cached the object definitions...
  if ($reset || 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;
}