public function CommerceLicenseRemoteExample::synchronize in Commerce License 7
Implements CommerceLicenseSynchronizableInterface::synchronize().
Overrides CommerceLicenseRemoteBase::synchronize
File
- modules/
commerce_license_example/ plugins/ license_type/ CommerceLicenseRemoteExample.class.php, line 54
Class
- CommerceLicenseRemoteExample
- Remote example license type.
Code
public function synchronize() {
// The license is being activated.
if ($this->status == COMMERCE_LICENSE_PENDING) {
// Simulate a 2s delay in synchronization, as if the service call was done.
sleep(2);
// Imagine that the service call returned an api key. Set it.
$this->wrapper->cle_api_key = sha1($this->license_id);
}
elseif ($this->status == COMMERCE_LICENSE_EXPIRED) {
// The license was just expired. Do something.
}
elseif ($this->status == COMMERCE_LICENSE_REVOKED) {
// The license was just revoked. Do something.
}
// Alternatively, set COMMERCE_LICENSE_SYNC_FAILED if the sync failed,
// or COMMERCE_LICENSE_SYNC_FAILED_RETRY if the sync failed and should
// be retried.
$this->wrapper->sync_status = COMMERCE_LICENSE_SYNCED;
$this
->save();
}