public function RoomsUnitController::create in Rooms - Drupal Booking for Hotels, B&Bs and Vacation Rentals 7
Creates a bookable unit.
Parameters
array $values: The properties for the new unit type.
Return value
RoomsUnit A unit object with all default fields initialized.
Overrides EntityAPIController::create
File
- modules/
rooms_unit/ rooms_unit.module, line 793 - Manage units - Units are things that can be booked on a nightly basis (e.g. rooms - but also villas bungalows, etc).
Class
- RoomsUnitController
- The Controller for RoomsUnit entities
Code
public function create(array $values = array()) {
$unit_type = rooms_unit_type_load($values['type'], TRUE);
// Add values that are specific to our Room.
$values += array(
'unit_id' => '',
'is_new' => TRUE,
'title' => '',
'created' => '',
'changed' => '',
'base_price' => isset($unit_type->data['base_price']) ? $unit_type->data['base_price'] : 0,
'min_sleeps' => isset($unit_type->data['min_sleeps']) ? $unit_type->data['min_sleeps'] : 0,
'max_sleeps' => isset($unit_type->data['max_sleeps']) ? $unit_type->data['max_sleeps'] : 0,
'min_children' => isset($unit_type->data['min_children']) ? $unit_type->data['min_children'] : 0,
'max_children' => isset($unit_type->data['max_children']) ? $unit_type->data['max_children'] : 0,
'data' => array(
'cot_surcharge' => isset($unit_type->data['cot_surcharge']) ? $unit_type->data['cot_surcharge'] : 0,
),
);
$unit = parent::create($values);
return $unit;
}