You are here

function facetapi_map_bundle in Facet API 7

Same name and namespace in other branches
  1. 6.3 facetapi.callbacks.inc \facetapi_map_bundle()
  2. 7.2 facetapi.callbacks.inc \facetapi_map_bundle()

Maps bundle machine names to their human friendly label.

Parameters

array $values: An array of indexed values being mapped.

array $options: An associative array of map options containing:

  • entities: An array of entities that $values are bundles for.

Return value

array An array mapping the indexed values to human readable values.

1 string reference to 'facetapi_map_bundle'
facetapi_facetapi_facet_info in ./facetapi.facetapi.inc
Implements hook_facetapi_facet_info().

File

./facetapi.callbacks.inc, line 20
Callbacks referenced in hook implementations.

Code

function facetapi_map_bundle(array $values, array $options) {
  if (empty($options['entities'])) {
    $options['entities'] = array(
      'node',
    );
  }
  foreach ($options['entities'] as $entity_type) {
    if ($info = entity_get_info($entity_type)) {
      foreach ($info['bundles'] as $bundle_name => $bundle_info) {
        $names[$bundle_name] = $bundle_info['label'];
      }
    }
  }
  return array_intersect_key($names, array_flip($values));
}