You are here

public function Registration::save in Entity Registration 8

Same name and namespace in other branches
  1. 8.2 src/Registration.php \Drupal\registration\Registration::save()

Save registration.

Overrides EntityContentBase::save

See also

entity_save()

File

src/Registration.php, line 193

Class

Registration
Defines the Registration entity.

Namespace

Drupal\registration

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();
}