* add 'doAuthDance()' to allow code reuse from SvnDownloader and SvnDriver

main
till 12 years ago
parent c6566825ad
commit 0d6297f235

@ -39,6 +39,11 @@ class Svn
*/ */
protected $url; protected $url;
/**
* @var bool $useCache Cache credentials.
*/
protected $useCache = false;
/** /**
* __construct * __construct
* *
@ -53,14 +58,43 @@ class Svn
$this->io = $io; $this->io = $io;
} }
/**
* doAuthDance
*
* Repositories requests credentials, let's put them in.
*
* @return \Composer\Util\Svn
* @uses self::$io
* @uses self::$hasAuth
* @uses self::$credentials
* @uses self::$useCache
*/
public function doAuthDance()
{
$this->io->write("The Subversion server ({$this->url}) requested credentials:");
$this->hasAuth = true;
$this->credentials = new \stdClass();
$this->credentials->username = $this->io->ask("Username: ");
$this->credentials->password = $this->io->askAndHideAnswer("Password: ");
$pleaseCache = $this->io->askConfirmation("Should Subversion cache these credentials? (yes/no) ", false);
if ($pleaseCache === true) {
$this->useCache = true;
}
return $this;
}
/** /**
* Return the no-auth-cache switch. * Return the no-auth-cache switch.
* *
* @return string * @return string
* @uses selfg::$useCache
* @see self::doAuthDance()
*/ */
public function getAuthCache() public function getAuthCache()
{ {
if (!$this->hasCache) { if (!$this->useCache) {
return '--no-auth-cache '; return '--no-auth-cache ';
} }
return ''; return '';

Loading…
Cancel
Save