You are here

public function UserSaveHandler::getRemoteEntityId in Services Client 7.2

Override get remote id. This allows to sync users by name.

Throws

ServicesClientConnectionResponseException

Overrides EventHandler::getRemoteEntityId

File

include/event.inc, line 1373

Class

UserSaveHandler

Code

public function getRemoteEntityId() {
  if (!empty($this->config['user_sync_by_name'])) {
    $entity = $this
      ->getEntity();
    $name = isset($entity->original->name) ? $entity->original->name : $entity->name;
    $result = $this
      ->getConnection()
      ->index('user', 'uid,name', array(
      'name' => $name,
    ));
    if (!empty($result[0]['uid'])) {
      return $result[0]['uid'];
    }
  }
  else {
    return parent::getRemoteEntityId();
  }
}