public function CommerceFileLicenseEntity::set_state in Commerce File 7
Set state
Parameters
$value: State name
3 calls to CommerceFileLicenseEntity::set_state()
- CommerceFileLicenseEntity::allow in includes/
commerce_file_license.entity.inc - ALLOW - sets state to 'allowed' with the default status
- CommerceFileLicenseEntity::deny in includes/
commerce_file_license.entity.inc - DENY - sets state to 'denied' with the default status
- CommerceFileLicenseEntity::set_status in includes/
commerce_file_license.entity.inc - Status
File
- includes/
commerce_file_license.entity.inc, line 305 - Provides a base class for CommerceFileLicenseEntity.
Class
- CommerceFileLicenseEntity
- A Commerce File License entity class.
Code
public function set_state($value) {
$state = commerce_file_license_state_load($value);
if (empty($state)) {
throw new Exception("Invalid State: Attempted to set license state to an invalid value of '{$value}'.");
}
if (empty($state['default_status'])) {
throw new Exception("Invalid State: Attempted to set license state to '{$value}' which does not define a default status.");
}
// update state
$original_state = $this
->get_state();
$this->state = $state['name'];
// only update status if we're changing states
if ($original_state != $state['name']) {
$this->status = $state['default_status'];
}
return $this;
}