You are here

function mandrill_activity_email_fieldmap_options in Mandrill 7

Same name and namespace in other branches
  1. 7.2 modules/mandrill_activity/mandrill_activity.admin.inc \mandrill_activity_email_fieldmap_options()

Return all possible Drupal properties for a given entity type.

@string $entity_type Name of entity whose properties to list. @string $entity_bundle Entity bundle to get properties for.

Return value

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

1 call to mandrill_activity_email_fieldmap_options()
mandrill_activity_entity_form in modules/mandrill_activity/mandrill_activity.admin.inc
Returns a form for a mandrill_activity_entity.

File

modules/mandrill_activity/mandrill_activity.admin.inc, line 199
Administration pages for mandrill_activity module.

Code

function mandrill_activity_email_fieldmap_options($entity_type, $entity_bundle = NULL) {
  $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'];
    }
  }
  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) {
      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'];
        }
      }
      else {
        $options[$key] = $property['label'];
      }
    }
  }
  return $options;
}