public function EventType::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 ConfigEntityBase::save
File
- modules/
bat_event/ src/ Entity/ EventType.php, line 111 - Contains \Drupal\bat_event\Entity\EventType.
Class
- EventType
- Defines the Event type configuration entity.
Namespace
Drupal\bat_event\EntityCode
public function save() {
$is_new = $this
->isNew();
parent::save();
if ($is_new) {
// Create all tables necessary for this Event Type.
bat_event_create_event_type_schema($this
->id());
// Create a field of type "Date range" for event dates.
bat_event_type_add_event_dates_field($this);
// Create a field of type 'Entity Reference' to reference a Bat Unit.
bat_event_type_add_target_entity_field($this);
if ($this->fixed_event_states) {
// Create a field of type 'Bat Event State Reference' to reference an Event State.
bat_event_type_add_event_state_reference($this);
}
}
}