You are here

function bat_type_ids in Booking and Availability Management Tools for Drupal 7

Same name and namespace in other branches
  1. 8 modules/bat_unit/bat_unit.module \bat_type_ids()

Gets a list of Bat Types keyed by id and name in value.

1 call to bat_type_ids()
bat_facets_search_api_query_alter in modules/bat_facets/bat_facets.module
Implements hook_search_api_query_alter().

File

modules/bat_unit/bat_unit.module, line 1639

Code

function bat_type_ids($bundle = '') {
  $types = array();
  $query = new EntityFieldQuery();
  $query
    ->entityCondition('entity_type', 'bat_type');
  if ($bundle != '') {
    $query
      ->entityCondition('bundle', $bundle);
  }
  $result = $query
    ->execute();
  if (count($result) > 0) {
    $entities = entity_load('bat_type', array_keys($result['bat_type']));
    foreach ($entities as $type) {
      $wrapper = entity_metadata_wrapper('bat_type', $type);
      $types[$wrapper->type_id
        ->value()] = $wrapper->name
        ->value();
    }
  }
  return $types;
}