You are here

public function DeveloperApp::setOwnerId in Apigee Edge 8

Sets the entity owner's user ID.

Parameters

int $uid: The owner user id.

Return value

$this

Overrides EntityOwnerInterface::setOwnerId

2 calls to DeveloperApp::setOwnerId()
DeveloperApp::setOwner in src/Entity/DeveloperApp.php
Sets the entity owner's user entity.
DeveloperApp::__construct in src/Entity/DeveloperApp.php
DeveloperApp constructor.

File

src/Entity/DeveloperApp.php, line 190

Class

DeveloperApp
Defines the Developer app entity class.

Namespace

Drupal\apigee_edge\Entity

Code

public function setOwnerId($uid) {
  $this->drupalUserId = $uid;
  $user = User::load($uid);
  if ($user) {
    $developer = Developer::load($user
      ->getEmail());
    if ($developer) {
      $this->decorated
        ->setDeveloperId($developer
        ->uuid());
    }
    else {

      // Sanity check, probably someone called this method with invalid data.
      throw new InvalidArgumentException("Developer with {$user->getEmail()} email does not exist on Apigee Edge.");
    }
  }
  else {

    // Sanity check, probably someone called this method with invalid data.
    throw new InvalidArgumentException("User with {$uid} id does not exist.");
  }
  return $this;
}