function fullcalendar_legend_get_type_bundle in FullCalendar 7.2
Finds the bundle of a given date field.
Parameters
array $fields: An array of results from field_info_field(), keyed by field name.
Return value
array Array of bundles.
File
- fullcalendar_legend/
fullcalendar_legend.module, line 165 - Adds a legend of event types.
Code
function fullcalendar_legend_get_type_bundle($fields) {
$types = array();
// Recurse through each field, finding out its bundle and entity type.
// Array is keyed first by field name.
foreach ($fields as $field_name => $field) {
// Then by entity type.
foreach ($field['bundles'] as $entity_type => $bundles) {
$entity_info = entity_get_info($entity_type);
// And finally by bundle name.
foreach ($bundles as $bundle) {
if (!isset($types[$bundle])) {
// @todo Find a generic way to process all entity types.
switch ($entity_type) {
case 'node':
case 'taxonomy_term':
case 'user':
$types[$bundle]['entity_type'] = $entity_type;
$types[$bundle]['field_name'] = $field_name;
$types[$bundle]['bundle'] = $bundle;
$types[$bundle]['label'] = $entity_info['bundles'][$bundle]['label'];
break;
}
}
}
}
}
return $types;
}