public function CommerceLicenseBase::save in Commerce License 7
Overrides Entity::save().
Overrides Entity::save
7 calls to CommerceLicenseBase::save()
- CommerceLicenseBase::activate in includes/
plugins/ license_type/ base.inc - Implements CommerceLicenseInterface::activate().
- CommerceLicenseBase::expire in includes/
plugins/ license_type/ base.inc - Implements CommerceLicenseInterface::expire().
- CommerceLicenseBase::renew in includes/
plugins/ license_type/ base.inc - Implements CommerceLicenseInterface::renew().
- CommerceLicenseBase::revoke in includes/
plugins/ license_type/ base.inc - Implements CommerceLicenseInterface::revoke().
- CommerceLicenseBase::suspend in includes/
plugins/ license_type/ base.inc - Implements CommerceLicenseInterface::suspend().
2 methods override CommerceLicenseBase::save()
- CommerceLicenseRemoteBase::save in includes/
plugins/ license_type/ base.inc - Overrides Entity::save().
- CommerceLicenseRole::save in modules/
commerce_license_role/ plugins/ license_type/ CommerceLicenseRole.class.php - Overrides Entity::save().
File
- includes/
plugins/ license_type/ base.inc, line 343 - Abstract and interface plugin implementation.
Class
- CommerceLicenseBase
- License base class.
Code
public function save() {
$granted = FALSE;
if (!empty($this->license_id)) {
$this->original = entity_load_unchanged('commerce_license', $this->license_id);
if ($this->status > $this->original->status && $this->status == COMMERCE_LICENSE_ACTIVE) {
// The license was updated, and its status was changed to active.
$granted = TRUE;
}
}
else {
$this->wrapper->num_renewals = 0;
if ($this->status == COMMERCE_LICENSE_ACTIVE) {
// The license was created with an active status.
$granted = TRUE;
}
}
// The license was just activated, set the granted timestamp and calculate
// the expiration timestamp. Only do that if the timestamps are currently
// empty (they might be set already, for example during a migration).
if ($granted && empty($this->granted)) {
$this->granted = commerce_license_get_time();
$duration = $this->wrapper->product->commerce_license_duration
->value();
if ($duration > 0 && empty($this->expires)) {
$this->expires = $this->granted + $duration;
}
}
parent::save();
}