You are here

public function EventSeriesType::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_series/src/Entity/EventSeriesType.php, line 104
Contains \Drupal\bat_event_series\Entity\EventSeriesType.

Class

EventSeriesType
Defines the Event series type configuration entity.

Namespace

Drupal\bat_event_series\Entity

Code

public function save() {
  $is_new = $this
    ->isNew();
  parent::save();
  if ($is_new) {

    // Create a field of type "Date range" for event dates.
    bat_event_series_type_add_event_dates_field($this
      ->id());

    // Create a field of type 'Entity Reference' to reference a Bat Unit.
    bat_event_series_type_add_target_entity_field($this
      ->id(), $this
      ->getTargetEntityType());

    // Create a field of type 'Bat Event State Reference' to reference an Event State.
    bat_event_series_type_add_event_state_reference($this
      ->id());
  }
}