You are here

function microdata_get_mapping in Microdata 7

Returns the mapping for fields and properties of a particular bundle.

Parameters

string $entity_type: An entity type.

string $bundle_type: A bundle name.

Return value

array The mapping corresponding to the requested entity/bundle pair or an empty array.

Related topics

8 calls to microdata_get_mapping()
microdata_bundle_mapping_form in ./microdata.admin.inc
Form builder helper function.
microdata_entity_load in ./microdata.module
Implements hook_entity_load().
microdata_form_field_ui_field_edit_form_alter in includes/microdata.form_alter.inc
Implements hook_form_FORM_ID_alter().
microdata_form_node_type_form_alter in includes/microdata.form_alter.inc
Implements hook_form_FORM_ID_alter().
microdata_form_taxonomy_form_vocabulary_alter in includes/microdata.form_alter.inc
Implements hook_form_FORMID_alter().

... See full list

1 string reference to 'microdata_get_mapping'
microdata_entity_info_alter in ./microdata.module
Implements hook_entity_info_alter().

File

./microdata.module, line 636

Code

function microdata_get_mapping($entity_type, $bundle_type) {
  global $language;
  $mappings =& drupal_static(__FUNCTION__);

  // hook_entity_info() includes translated strings, so each language is cached
  // separately.
  $langcode = $language->language;
  if (!isset($mappings[$entity_type][$bundle_type])) {

    // Check if the persistent cache has the data.
    if ($cache = cache_get("microdata_get_mapping:{$langcode}")) {
      $mappings = $cache->data;
    }
    if (!isset($mappings[$entity_type][$bundle_type])) {

      // Retrieves the bundle-specific mapping from the entity info.
      $entity_info = entity_get_info($entity_type);

      // Set the defaults here - because entity_get_info() could trigger a
      // static cache clear, which would make setting a default previously
      // obsolete.
      // @see microdata_entity_info_alter()
      $mappings[$entity_type][$bundle_type] = array();
      if (!empty($entity_info['bundles'][$bundle_type]['microdata_mapping'])) {
        $mappings[$entity_type][$bundle_type] = $entity_info['bundles'][$bundle_type]['microdata_mapping'];
      }
      _microdata_prepare_mapping($mappings[$entity_type][$bundle_type], $entity_type, $bundle_type);

      // Set the persistent cache.
      cache_set("microdata_get_mapping:{$langcode}", $mappings);
    }
  }
  return $mappings[$entity_type][$bundle_type];
}