You are here

public function BatUnitController::getReferencedIds in Booking and Availability Management Tools for Drupal 7

File

modules/bat_unit/bat_unit.module, line 1171

Class

BatUnitController
The Controller for BatUnit entities.

Code

public function getReferencedIds($unit_type, $ids = array()) {
  $query = db_select('bat_units', 'n')
    ->fields('n', array(
    'unit_id',
    'type_id',
    'type',
    'name',
  ));
  if (!empty($ids)) {
    $query
      ->condition('unit_id', $ids, 'IN');
  }
  $query
    ->condition('type_id', $unit_type);
  $bat_units = $query
    ->execute()
    ->fetchAll();
  $units = array();
  foreach ($bat_units as $unit) {
    $units[] = array(
      'id' => $unit->unit_id,
      'name' => $unit->name,
      'type_id' => $unit_type,
    );
  }
  return $units;
}