public function Booking::save in Booking and Availability Management Tools for Drupal 8
Saves an entity permanently.
When saving existing entities, the entity is assumed to be complete, partial updates of entities are not supported.
Return value
int Either SAVED_NEW or SAVED_UPDATED, depending on the operation performed.
Throws
\Drupal\Core\Entity\EntityStorageException In case of failures an exception is thrown.
Overrides EntityBase::save
File
- modules/
bat_booking/ src/ Entity/ Booking.php, line 184 - Contains \Drupal\bat_booking\Entity\Booking.
Class
- Booking
- Defines the Booking entity.
Namespace
Drupal\bat_booking\EntityCode
public function save() {
if ($this
->isNew()) {
parent::save();
}
// Set default value for label.
if (empty($this
->label())) {
$booking_type = bat_booking_type_load($this
->bundle());
$this
->set('label', $booking_type
->label() . ' ' . $this
->id());
}
parent::save();
}