Changeset View
Changeset View
Standalone View
Standalone View
src/applications/repository/storage/PhabricatorRepository.php
Show First 20 Lines • Show All 1,891 Lines • ▼ Show 20 Lines | /* -( Repository URI Management )------------------------------------------ */ | ||||
/** | /** | ||||
* Retrieve the service URI for the device hosting this repository. | * Retrieve the service URI for the device hosting this repository. | ||||
* | * | ||||
* See @{method:newConduitClient} for a general discussion of interacting | * See @{method:newConduitClient} for a general discussion of interacting | ||||
* with repository services. This method provides lower-level resolution of | * with repository services. This method provides lower-level resolution of | ||||
* services, returning raw URIs. | * services, returning raw URIs. | ||||
* | * | ||||
* @param PhabricatorUser Viewing user. | * @param PhabricatorUser Viewing user. | ||||
* @param bool `true` to throw if a remote URI would be returned. | * @param map<string, wild> Constraints on selectable services. | ||||
* @param list<string> List of allowable protocols. | |||||
* @return string|null URI, or `null` for local repositories. | * @return string|null URI, or `null` for local repositories. | ||||
*/ | */ | ||||
public function getAlmanacServiceURI( | public function getAlmanacServiceURI( | ||||
PhabricatorUser $viewer, | PhabricatorUser $viewer, | ||||
$never_proxy, | array $options) { | ||||
array $protocols) { | |||||
PhutilTypeSpec::checkMap( | |||||
$options, | |||||
array( | |||||
'neverProxy' => 'bool', | |||||
'protocols' => 'list<string>', | |||||
)); | |||||
$never_proxy = $options['neverProxy']; | |||||
$protocols = $options['protocols']; | |||||
$cache_key = $this->getAlmanacServiceCacheKey(); | $cache_key = $this->getAlmanacServiceCacheKey(); | ||||
if (!$cache_key) { | if (!$cache_key) { | ||||
return null; | return null; | ||||
} | } | ||||
$cache = PhabricatorCaches::getMutableStructureCache(); | $cache = PhabricatorCaches::getMutableStructureCache(); | ||||
$uris = $cache->getKey($cache_key, false); | $uris = $cache->getKey($cache_key, false); | ||||
▲ Show 20 Lines • Show All 156 Lines • ▼ Show 20 Lines | /* -( Repository URI Management )------------------------------------------ */ | ||||
* @return ConduitClient|null Client, or `null` for local repositories. | * @return ConduitClient|null Client, or `null` for local repositories. | ||||
*/ | */ | ||||
public function newConduitClient( | public function newConduitClient( | ||||
PhabricatorUser $viewer, | PhabricatorUser $viewer, | ||||
$never_proxy = false) { | $never_proxy = false) { | ||||
$uri = $this->getAlmanacServiceURI( | $uri = $this->getAlmanacServiceURI( | ||||
$viewer, | $viewer, | ||||
$never_proxy, | |||||
array( | array( | ||||
'neverProxy' => $never_proxy, | |||||
'protocols' => array( | |||||
'http', | 'http', | ||||
'https', | 'https', | ||||
), | |||||
)); | )); | ||||
if ($uri === null) { | if ($uri === null) { | ||||
return null; | return null; | ||||
} | } | ||||
$domain = id(new PhutilURI(PhabricatorEnv::getURI('/')))->getDomain(); | $domain = id(new PhutilURI(PhabricatorEnv::getURI('/')))->getDomain(); | ||||
$client = id(new ConduitClient($uri)) | $client = id(new ConduitClient($uri)) | ||||
▲ Show 20 Lines • Show All 569 Lines • Show Last 20 Lines |