public function UnitIndex::getReferencedIds in Booking and Availability Management API 8
1 call to UnitIndex::getReferencedIds()
- UnitIndex::processRequest in src/
Plugin/ ServiceDefinition/ UnitIndex.php - Processes the request and returns an array of data as appropriate.
File
- src/
Plugin/ ServiceDefinition/ UnitIndex.php, line 173 - Contains \Drupal\bat_api\Plugin\ServiceDefinition\UnitIndex.php
Class
- UnitIndex
- Plugin annotation @ServiceDefinition( id = "unit_index", methods = { "GET" }, translatable = true, deriver = "\Drupal\bat_api\Plugin\Deriver\UnitIndex" )
Namespace
Drupal\bat_api\Plugin\ServiceDefinitionCode
public function getReferencedIds($unit_type, $ids = []) {
$query = $this->connection
->select('unit', 'n')
->fields('n', [
'id',
'unit_type_id',
'type',
'name',
]);
if (!empty($ids)) {
$query
->condition('id', $ids, 'IN');
}
$query
->condition('unit_type_id', $unit_type);
$bat_units = $query
->execute()
->fetchAll();
$units = [];
foreach ($bat_units as $unit) {
$units[] = [
'id' => $unit->id,
'name' => $unit->name,
'type_id' => $unit_type,
];
}
return $units;
}