protected static function AvailabilityAgent::compareByOptionals in Rooms - Drupal Booking for Hotels, B&Bs and Vacation Rentals 7
Compares two bookable units based on the number of available options.
Parameters
array $unit_a: First unit.
array $unit_b: Second unit.
Return value
int Comparison result.
File
- modules/
rooms_booking/ includes/ rooms_booking.availability_agent.inc, line 448 - Contains the AvailabilityAgent.
Class
- AvailabilityAgent
- An AvailabilityAgent provides access to the availability functionality of Rooms and lets you query for availability, get pricing information and create products that can be bought.
Code
protected static function compareByOptionals($unit_a, $unit_b) {
$a_items = rooms_unit_get_unit_options($unit_a['unit']);
$b_items = rooms_unit_get_unit_options($unit_b['unit']);
if (count($a_items) == count($b_items)) {
return $unit_a['unit']->unit_id < $unit_b['unit']->unit_id ? 1 : -1;
}
else {
return count($a_items) < count($b_items) ? 1 : -1;
}
}