You are here

function salesforce_api_fieldmap_objects_load in Salesforce Suite 7.2

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 salesforce_api/salesforce_api.module \salesforce_api_fieldmap_objects_load()

Returns all or a subset of the objects defined via hook_fieldmap_objects and hook_fieldmap_objects_alter().

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.

bool $reset: Whether to reset the cache of object definitions.

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.

14 calls to salesforce_api_fieldmap_objects_load()
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
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.
salesforce_api_fieldmap_object_label in salesforce_api/salesforce_api.module
Returns the label for the object of the specified type and name. Note that both the $type and $entity parameters will be 'salesforce' in the case of Salesforce objects.

... See full list

File

salesforce_api/salesforce_api.module, line 921
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, $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($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;
}