public function DmSourceCreate($Type, $URL, $AuthLogin = null, $AuthPassword = null) { $source = Scalr_Model::init(Scalr_Model::DM_SOURCE); $authInfo = new stdClass(); if ($Type == Scalr_Dm_Source::TYPE_SVN) { $authInfo->login = $AuthLogin; $authInfo->password = $AuthPassword; $authType = Scalr_Dm_Source::AUTHTYPE_PASSWORD; } if (Scalr_Dm_Source::getIdByUrlAndAuth($URL, $authInfo)) { throw new Exception("Source already exists in database"); } $source->envId = $this->Environment->id; $source->url = $URL; $source->type = $Type; $source->authType = $authType; $source->setAuthInfo($authInfo); $source->save(); $response = $this->CreateInitialResponse(); $response->SourceID = $source->id; return $response; }