You are here

function salesforce_mapping_property_fieldmap_options in Salesforce Suite 7.3

Return all possible Drupal properties for a given entity type.

Parameters

string $entity_type: Name of entity whose properties to list.

bool $include_entities: Choose whether or not to include properties of the given entity type that are themselves also entities.

Return value

array List of entities that can be used as an #options list.

1 call to salesforce_mapping_property_fieldmap_options()
salesforce_mapping_related_entity_fieldmap_options in modules/salesforce_mapping/includes/salesforce_mapping.fieldmap_type.inc
Return all possible Drupal properties of type entity for a given entity type.
1 string reference to 'salesforce_mapping_property_fieldmap_options'
salesforce_mapping_salesforce_mapping_fieldmap_type in modules/salesforce_mapping/includes/salesforce_mapping.fieldmap_type.inc
Implements hook_salesforce_mapping_fieldmap_type().

File

modules/salesforce_mapping/includes/salesforce_mapping.fieldmap_type.inc, line 70
Data and callbacks for fieldmap types.

Code

function salesforce_mapping_property_fieldmap_options($entity_type, $entity_bundle = NULL, $include_entities = FALSE) {
  $options = array(
    '' => t('-- Select --'),
  );
  $properties = entity_get_all_property_info($entity_type);
  if (isset($entity_bundle)) {
    $info = entity_get_property_info($entity_type);
    $properties = $info['properties'];
    if (isset($info['bundles'][$entity_bundle])) {
      $properties += $info['bundles'][$entity_bundle]['properties'];
    }
  }
  else {
    $properties = entity_get_all_property_info($entity_type);
  }
  foreach ($properties as $key => $property) {
    $type = isset($property['type']) ? entity_property_extract_innermost_type($property['type']) : 'text';
    $is_entity = $type == 'entity' || (bool) entity_get_info($type);

    // Leave entities out of this.
    if ($is_entity && $include_entities || !$is_entity && !$include_entities) {
      if (isset($property['field']) && $property['field'] && !empty($property['property info'])) {
        foreach ($property['property info'] as $sub_key => $sub_prop) {
          $options[$property['label']][$key . ':' . $sub_key] = $sub_prop['label'];
          if (isset($sub_prop['required']) && $sub_prop['required']) {
            $options[$property['label']][$key . ':' . $sub_key] .= '*';
          }
        }
      }
      else {
        $options[$key] = $property['label'];
        if (isset($property['required']) && $property['required']) {
          $options[$key] .= '*';
        }
      }
    }
  }
  return $options;
}