You are here

public function Registration::save in Entity Registration 8.2

Same name in this branch
  1. 8.2 lib/registration.entity.inc \Registration::save()
  2. 8.2 src/Registration.php \Drupal\registration\Registration::save()
Same name and namespace in other branches
  1. 7.2 lib/registration.entity.inc \Registration::save()
  2. 7 lib/registration.entity.inc \Registration::save()

Save registration.

See also

entity_save()

File

lib/registration.entity.inc, line 190
Entity hooks and callbacks for registrations.

Class

Registration
Main class for Registration entities.

Code

public function save() {

  // Set a default state if not provided.
  $wrapper = entity_metadata_wrapper('registration', $this);
  $state = $wrapper->state
    ->value();
  if (!$state) {
    $default_state = registration_get_default_state($wrapper->type
      ->value());
    if ($default_state) {
      $this->state = $default_state
        ->identifier();
    }
  }
  $this->updated = REQUEST_TIME;
  if (!$this->registration_id && empty($this->created)) {
    $this->created = REQUEST_TIME;
  }
  return parent::save();
}