You are here

public function CommerceFileLicenseEntity::set_owner in Commerce File 7

File

includes/commerce_file_license.entity.inc, line 352
Provides a base class for CommerceFileLicenseEntity.

Class

CommerceFileLicenseEntity
A Commerce File License entity class.

Code

public function set_owner($value) {
  $owner = NULL;
  if (is_numeric($value)) {

    // load value as uid
    $owner = @user_load($value);
  }
  elseif (is_object($value) && isset($value->uid)) {

    // load fresh user object for uid
    $owner = user_load($value->uid);
  }

  // Set owner if found a user object
  if (isset($owner->uid)) {
    $this->owner = $owner;
    $this->uid = $owner->uid;
  }
  else {
    throw new Exception('Commerce File License: invalid owner input provided. To set owner, provide a valid uid or user object.');
  }
  return $this->owner;
}