mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-29 02:02:41 +01:00
Replace "URI->setQueryParams()" after initialization with a constructor argument
Summary: Ref T13250. See D20149. In a number of cases, we use `setQueryParams()` immediately after URI construction. To simplify this slightly, let the constructor take parameters, similar to `HTTPSFuture`. Test Plan: See inlines. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13250 Differential Revision: https://secure.phabricator.com/D20151
This commit is contained in:
parent
eb73cb68ff
commit
4c12420162
13 changed files with 83 additions and 92 deletions
|
@ -67,19 +67,13 @@ abstract class AlmanacController
|
||||||
$is_builtin = isset($builtins[$key]);
|
$is_builtin = isset($builtins[$key]);
|
||||||
$is_persistent = (bool)$property->getID();
|
$is_persistent = (bool)$property->getID();
|
||||||
|
|
||||||
$delete_uri = id(new PhutilURI($delete_base))
|
$params = array(
|
||||||
->setQueryParams(
|
'key' => $key,
|
||||||
array(
|
'objectPHID' => $object->getPHID(),
|
||||||
'key' => $key,
|
);
|
||||||
'objectPHID' => $object->getPHID(),
|
|
||||||
));
|
|
||||||
|
|
||||||
$edit_uri = id(new PhutilURI($edit_base))
|
$delete_uri = new PhutilURI($delete_base, $params);
|
||||||
->setQueryParams(
|
$edit_uri = new PhutilURI($edit_base, $params);
|
||||||
array(
|
|
||||||
'key' => $key,
|
|
||||||
'objectPHID' => $object->getPHID(),
|
|
||||||
));
|
|
||||||
|
|
||||||
$delete = javelin_tag(
|
$delete = javelin_tag(
|
||||||
'a',
|
'a',
|
||||||
|
|
|
@ -218,11 +218,11 @@ final class PhabricatorAuthOneTimeLoginController
|
||||||
|
|
||||||
$request->setTemporaryCookie(PhabricatorCookies::COOKIE_HISEC, 'yes');
|
$request->setTemporaryCookie(PhabricatorCookies::COOKIE_HISEC, 'yes');
|
||||||
|
|
||||||
return (string)id(new PhutilURI($panel_uri))
|
$params = array(
|
||||||
->setQueryParams(
|
'key' => $key,
|
||||||
array(
|
);
|
||||||
'key' => $key,
|
|
||||||
));
|
return (string)new PhutilURI($panel_uri, $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
$providers = id(new PhabricatorAuthProviderConfigQuery())
|
$providers = id(new PhabricatorAuthProviderConfigQuery())
|
||||||
|
|
|
@ -80,11 +80,6 @@ final class PhabricatorDuoFuture
|
||||||
$host = $this->apiHostname;
|
$host = $this->apiHostname;
|
||||||
$host = phutil_utf8_strtolower($host);
|
$host = phutil_utf8_strtolower($host);
|
||||||
|
|
||||||
$uri = id(new PhutilURI(''))
|
|
||||||
->setProtocol('https')
|
|
||||||
->setDomain($host)
|
|
||||||
->setPath($path);
|
|
||||||
|
|
||||||
$data = $this->parameters;
|
$data = $this->parameters;
|
||||||
$date = date('r');
|
$date = date('r');
|
||||||
|
|
||||||
|
@ -109,11 +104,19 @@ final class PhabricatorDuoFuture
|
||||||
$signature = new PhutilOpaqueEnvelope($signature);
|
$signature = new PhutilOpaqueEnvelope($signature);
|
||||||
|
|
||||||
if ($http_method === 'GET') {
|
if ($http_method === 'GET') {
|
||||||
$uri->setQueryParams($data);
|
$uri_data = $data;
|
||||||
$data = array();
|
$body_data = array();
|
||||||
|
} else {
|
||||||
|
$uri_data = array();
|
||||||
|
$body_data = $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
$future = id(new HTTPSFuture($uri, $data))
|
$uri = id(new PhutilURI('', $uri_data))
|
||||||
|
->setProtocol('https')
|
||||||
|
->setDomain($host)
|
||||||
|
->setPath($path);
|
||||||
|
|
||||||
|
$future = id(new HTTPSFuture($uri, $body_data))
|
||||||
->setHTTPBasicAuthCredentials($this->integrationKey, $signature)
|
->setHTTPBasicAuthCredentials($this->integrationKey, $signature)
|
||||||
->setMethod($http_method)
|
->setMethod($http_method)
|
||||||
->addHeader('Accept', 'application/json')
|
->addHeader('Accept', 'application/json')
|
||||||
|
|
|
@ -81,12 +81,12 @@ abstract class DiffusionView extends AphrontView {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($details['external'])) {
|
if (isset($details['external'])) {
|
||||||
$href = id(new PhutilURI('/diffusion/external/'))
|
$params = array(
|
||||||
->setQueryParams(
|
'uri' => idx($details, 'external'),
|
||||||
array(
|
'id' => idx($details, 'hash'),
|
||||||
'uri' => idx($details, 'external'),
|
);
|
||||||
'id' => idx($details, 'hash'),
|
|
||||||
));
|
$href = new PhutilURI('/diffusion/external/', $params);
|
||||||
$tip = pht('Browse External');
|
$tip = pht('Browse External');
|
||||||
} else {
|
} else {
|
||||||
$href = $this->getDiffusionRequest()->generateURI(
|
$href = $this->getDiffusionRequest()->generateURI(
|
||||||
|
|
|
@ -111,15 +111,15 @@ final class DivinerSymbolRemarkupRule extends PhutilRemarkupRule {
|
||||||
// Here, we're generating comment text or something like that. Just
|
// Here, we're generating comment text or something like that. Just
|
||||||
// link to Diviner and let it sort things out.
|
// link to Diviner and let it sort things out.
|
||||||
|
|
||||||
$href = id(new PhutilURI('/diviner/find/'))
|
$params = array(
|
||||||
->setQueryParams(
|
'book' => $ref->getBook(),
|
||||||
array(
|
'name' => $ref->getName(),
|
||||||
'book' => $ref->getBook(),
|
'type' => $ref->getType(),
|
||||||
'name' => $ref->getName(),
|
'context' => $ref->getContext(),
|
||||||
'type' => $ref->getType(),
|
'jump' => true,
|
||||||
'context' => $ref->getContext(),
|
);
|
||||||
'jump' => true,
|
|
||||||
));
|
$href = new PhutilURI('/diviner/find/', $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: This probably is not the best place to do this. Move it somewhere
|
// TODO: This probably is not the best place to do this. Move it somewhere
|
||||||
|
|
|
@ -81,13 +81,13 @@ final class HeraldNewController extends HeraldController {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$errors && $done) {
|
if (!$errors && $done) {
|
||||||
$uri = id(new PhutilURI('edit/'))
|
$params = array(
|
||||||
->setQueryParams(
|
'content_type' => $content_type,
|
||||||
array(
|
'rule_type' => $rule_type,
|
||||||
'content_type' => $content_type,
|
'targetPHID' => $target_phid,
|
||||||
'rule_type' => $rule_type,
|
);
|
||||||
'targetPHID' => $target_phid,
|
|
||||||
));
|
$uri = new PhutilURI('edit/', $params);
|
||||||
$uri = $this->getApplicationURI($uri);
|
$uri = $this->getApplicationURI($uri);
|
||||||
return id(new AphrontRedirectResponse())->setURI($uri);
|
return id(new AphrontRedirectResponse())->setURI($uri);
|
||||||
}
|
}
|
||||||
|
@ -126,13 +126,13 @@ final class HeraldNewController extends HeraldController {
|
||||||
->addHiddenInput('step', 2)
|
->addHiddenInput('step', 2)
|
||||||
->appendChild($rule_types);
|
->appendChild($rule_types);
|
||||||
|
|
||||||
|
$params = array(
|
||||||
|
'content_type' => $content_type,
|
||||||
|
'step' => '0',
|
||||||
|
);
|
||||||
|
|
||||||
$cancel_text = pht('Back');
|
$cancel_text = pht('Back');
|
||||||
$cancel_uri = id(new PhutilURI('new/'))
|
$cancel_uri = new PhutilURI('new/', $params);
|
||||||
->setQueryParams(
|
|
||||||
array(
|
|
||||||
'content_type' => $content_type,
|
|
||||||
'step' => 0,
|
|
||||||
));
|
|
||||||
$cancel_uri = $this->getApplicationURI($cancel_uri);
|
$cancel_uri = $this->getApplicationURI($cancel_uri);
|
||||||
$title = pht('Create Herald Rule: %s',
|
$title = pht('Create Herald Rule: %s',
|
||||||
idx($content_type_map, $content_type));
|
idx($content_type_map, $content_type));
|
||||||
|
@ -173,14 +173,14 @@ final class HeraldNewController extends HeraldController {
|
||||||
->setValue($request->getStr('objectName'))
|
->setValue($request->getStr('objectName'))
|
||||||
->setLabel(pht('Object')));
|
->setLabel(pht('Object')));
|
||||||
|
|
||||||
|
$params = array(
|
||||||
|
'content_type' => $content_type,
|
||||||
|
'rule_type' => $rule_type,
|
||||||
|
'step' => 1,
|
||||||
|
);
|
||||||
|
|
||||||
$cancel_text = pht('Back');
|
$cancel_text = pht('Back');
|
||||||
$cancel_uri = id(new PhutilURI('new/'))
|
$cancel_uri = new PhutilURI('new/', $params);
|
||||||
->setQueryParams(
|
|
||||||
array(
|
|
||||||
'content_type' => $content_type,
|
|
||||||
'rule_type' => $rule_type,
|
|
||||||
'step' => 1,
|
|
||||||
));
|
|
||||||
$cancel_uri = $this->getApplicationURI($cancel_uri);
|
$cancel_uri = $this->getApplicationURI($cancel_uri);
|
||||||
$title = pht('Create Herald Rule: %s',
|
$title = pht('Create Herald Rule: %s',
|
||||||
idx($content_type_map, $content_type));
|
idx($content_type_map, $content_type));
|
||||||
|
|
|
@ -65,11 +65,11 @@ final class PhabricatorOwnersDetailController
|
||||||
|
|
||||||
$commit_views = array();
|
$commit_views = array();
|
||||||
|
|
||||||
$commit_uri = id(new PhutilURI('/diffusion/commit/'))
|
$params = array(
|
||||||
->setQueryParams(
|
'package' => $package->getPHID(),
|
||||||
array(
|
);
|
||||||
'package' => $package->getPHID(),
|
|
||||||
));
|
$commit_uri = new PhutilURI('/diffusion/commit/', $params);
|
||||||
|
|
||||||
$status_concern = DiffusionCommitAuditStatus::CONCERN_RAISED;
|
$status_concern = DiffusionCommitAuditStatus::CONCERN_RAISED;
|
||||||
|
|
||||||
|
|
|
@ -134,13 +134,13 @@ final class PhortuneCartCheckoutController
|
||||||
|
|
||||||
$account_id = $account->getID();
|
$account_id = $account->getID();
|
||||||
|
|
||||||
|
$params = array(
|
||||||
|
'merchantID' => $merchant->getID(),
|
||||||
|
'cartID' => $cart->getID(),
|
||||||
|
);
|
||||||
|
|
||||||
$payment_method_uri = $this->getApplicationURI("{$account_id}/card/new/");
|
$payment_method_uri = $this->getApplicationURI("{$account_id}/card/new/");
|
||||||
$payment_method_uri = new PhutilURI($payment_method_uri);
|
$payment_method_uri = new PhutilURI($payment_method_uri, $params);
|
||||||
$payment_method_uri->setQueryParams(
|
|
||||||
array(
|
|
||||||
'merchantID' => $merchant->getID(),
|
|
||||||
'cartID' => $cart->getID(),
|
|
||||||
));
|
|
||||||
|
|
||||||
$form = id(new AphrontFormView())
|
$form = id(new AphrontFormView())
|
||||||
->setUser($viewer)
|
->setUser($viewer)
|
||||||
|
|
|
@ -348,12 +348,14 @@ final class PhortunePayPalPaymentProvider extends PhortunePaymentProvider {
|
||||||
->setRawPayPalQuery('SetExpressCheckout', $params)
|
->setRawPayPalQuery('SetExpressCheckout', $params)
|
||||||
->resolve();
|
->resolve();
|
||||||
|
|
||||||
$uri = new PhutilURI('https://www.sandbox.paypal.com/cgi-bin/webscr');
|
$params = array(
|
||||||
$uri->setQueryParams(
|
'cmd' => '_express-checkout',
|
||||||
array(
|
'token' => $result['TOKEN'],
|
||||||
'cmd' => '_express-checkout',
|
);
|
||||||
'token' => $result['TOKEN'],
|
|
||||||
));
|
$uri = new PhutilURI(
|
||||||
|
'https://www.sandbox.paypal.com/cgi-bin/webscr',
|
||||||
|
$params);
|
||||||
|
|
||||||
$cart->setMetadataValue('provider.checkoutURI', (string)$uri);
|
$cart->setMetadataValue('provider.checkoutURI', (string)$uri);
|
||||||
$cart->save();
|
$cart->save();
|
||||||
|
|
|
@ -273,8 +273,7 @@ abstract class PhortunePaymentProvider extends Phobject {
|
||||||
$app = PhabricatorApplication::getByClass('PhabricatorPhortuneApplication');
|
$app = PhabricatorApplication::getByClass('PhabricatorPhortuneApplication');
|
||||||
$path = $app->getBaseURI().'provider/'.$id.'/'.$action.'/';
|
$path = $app->getBaseURI().'provider/'.$id.'/'.$action.'/';
|
||||||
|
|
||||||
$uri = new PhutilURI($path);
|
$uri = new PhutilURI($path, $params);
|
||||||
$uri->setQueryParams($params);
|
|
||||||
|
|
||||||
if ($local) {
|
if ($local) {
|
||||||
return $uri;
|
return $uri;
|
||||||
|
|
|
@ -820,8 +820,6 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
|
||||||
return $uri;
|
return $uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
$uri = new PhutilURI($uri);
|
|
||||||
|
|
||||||
if (isset($params['lint'])) {
|
if (isset($params['lint'])) {
|
||||||
$params['params'] = idx($params, 'params', array()) + array(
|
$params['params'] = idx($params, 'params', array()) + array(
|
||||||
'lint' => $params['lint'],
|
'lint' => $params['lint'],
|
||||||
|
@ -830,11 +828,7 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
|
||||||
|
|
||||||
$query = idx($params, 'params', array()) + $query;
|
$query = idx($params, 'params', array()) + $query;
|
||||||
|
|
||||||
if ($query) {
|
return new PhutilURI($uri, $query);
|
||||||
$uri->setQueryParams($query);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $uri;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateURIIndex() {
|
public function updateURIIndex() {
|
||||||
|
|
|
@ -1541,8 +1541,7 @@ abstract class PhabricatorEditEngine
|
||||||
$config_uri = $config->getCreateURI();
|
$config_uri = $config->getCreateURI();
|
||||||
|
|
||||||
if ($parameters) {
|
if ($parameters) {
|
||||||
$config_uri = (string)id(new PhutilURI($config_uri))
|
$config_uri = (string)new PhutilURI($config_uri, $parameters);
|
||||||
->setQueryParams($parameters);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$specs[] = array(
|
$specs[] = array(
|
||||||
|
|
|
@ -99,8 +99,8 @@ abstract class PhabricatorTypeaheadDatasource extends Phobject {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDatasourceURI() {
|
public function getDatasourceURI() {
|
||||||
$uri = new PhutilURI('/typeahead/class/'.get_class($this).'/');
|
$params = $this->newURIParameters();
|
||||||
$uri->setQueryParams($this->newURIParameters());
|
$uri = new PhutilURI('/typeahead/class/'.get_class($this).'/', $params);
|
||||||
return phutil_string_cast($uri);
|
return phutil_string_cast($uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,8 +109,8 @@ abstract class PhabricatorTypeaheadDatasource extends Phobject {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$uri = new PhutilURI('/typeahead/browse/'.get_class($this).'/');
|
$params = $this->newURIParameters();
|
||||||
$uri->setQueryParams($this->newURIParameters());
|
$uri = new PhutilURI('/typeahead/browse/'.get_class($this).'/', $params);
|
||||||
return phutil_string_cast($uri);
|
return phutil_string_cast($uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue