You are here

public function BatBookingController::save in Booking and Availability Management Tools for Drupal 7

Implements EntityAPIControllerInterface.

Parameters

$transaction: Optionally a DatabaseTransaction object to use. Allows overrides to pass in their transaction object.

Overrides EntityAPIController::save

File

modules/bat_booking/bat_booking.module, line 331

Class

BatBookingController
The Controller for BatBooking entities.

Code

public function save($entity, DatabaseTransaction $transaction = NULL) {
  if (isset($entity->is_new) && $entity->is_new) {
    parent::save($entity);
  }

  // Set default value for label.
  if (empty($entity->label)) {
    $booking_type = bat_booking_type_load($entity->type);
    $entity->label = $booking_type->label . ' ' . $entity->booking_id;
  }
  parent::save($entity);
}