/**
  * Get ssh2 connection
  *
  * @param Repository $repoObject
  * @return Resource
  */
 protected static function getSftpResource($repoObject)
 {
     if (isset(self::$sftpResource) && self::$resourceRepoId == $repoObject->getId()) {
         return self::$sftpResource;
     }
     $callbacks = array('disconnect' => "disconnectedSftp", 'ignore' => "ignoreSftp", 'debug' => "debugSftp", 'macerror' => "macerrorSftp");
     $remote_serv = $repoObject->getOption("SERV");
     $remote_port = $repoObject->getOption("PORT");
     $credentials = AJXP_Safe::tryLoadingCredentialsFromSources(array(), $repoObject);
     $remote_user = $credentials["user"];
     $remote_pass = $credentials["password"];
     $connection = ssh2_connect($remote_serv, intval($remote_port), array(), $callbacks);
     ssh2_auth_password($connection, $remote_user, $remote_pass);
     self::$sftpResource = ssh2_sftp($connection);
     self::$resourceRepoId = $repoObject->getId();
     return self::$sftpResource;
 }
 /**
  * Get ssh2 connection
  *
  * @param Repository $repoObject
  * @return Resource
  */
 protected static function getSftpResource($repoObject)
 {
     if (isset(self::$sftpResource)) {
         return self::$sftpResource;
     }
     $callbacks = array('disconnect' => "disconnectedSftp", 'ignore' => "ignoreSftp", 'debug' => "debugSftp", 'macerror' => "macerrorSftp");
     $remote_serv = $repoObject->getOption("SERV");
     $remote_port = $repoObject->getOption("PORT");
     $remote_user = $repoObject->getOption("USER");
     $remote_pass = $repoObject->getOption("PASS");
     $connection = ssh2_connect($remote_serv, intval($remote_port), array(), $callbacks);
     ssh2_auth_password($connection, $remote_user, $remote_pass);
     self::$sftpResource = ssh2_sftp($connection);
     return self::$sftpResource;
 }