本文整理汇总了PHP中GuzzleHttp\Psr7\Uri::withQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP Uri::withQuery方法的具体用法?PHP Uri::withQuery怎么用?PHP Uri::withQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GuzzleHttp\Psr7\Uri
的用法示例。
在下文中一共展示了Uri::withQuery方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: appendPath
public static function appendPath($url, $path)
{
$uri = new Psr7Uri($url);
$cutUrl = (string) $uri->withQuery('')->withFragment('');
if ($path === '' || $path[0] === '#') {
return $cutUrl . $path;
} else {
return rtrim($cutUrl, '/') . '/' . ltrim($path, '/');
}
}
示例2: getUri
/**
* @return \Psr\Http\Message\UriInterface
*/
public function getUri()
{
$uri = new Uri($this->serviceUri);
return $uri->withQuery(\GuzzleHttp\Psr7\build_query($this->params));
}
示例3: appendPath
public static function appendPath($url, $path)
{
$uri = new Psr7Uri($url);
$cutUrl = (string) $uri->withQuery('')->withFragment('');
return rtrim($cutUrl, '/') . '/' . ltrim($path, '/');
}
示例4: generate
/**
* @param SpeechInfoInterface $speech source of url parameters
* @return UriInterface
*/
public function generate(SpeechInfoInterface $speech)
{
$query = http_build_query(['uuid' => $speech->getUuid(), 'key' => $this->key, 'topic' => $speech->getTopic(), 'lang' => $speech->getLang()]);
$request = new Uri($this->base);
return $request->withQuery($query);
}
示例5: getAuthRequestUri
/**
* Get the URL for authentication.
*
* @param string $redirectUri
* @param string $scope
* @param null|string $state
* @param bool $preferSignup
*
* @return string
*/
public function getAuthRequestUri($redirectUri, $scope = 'global', $state = null, $preferSignup = false)
{
$uri = new Uri(vsprintf('%s/oauth/auth', [$this->endpoint]));
$query = ['scope' => $scope, 'redirect_uri' => $redirectUri, 'response_type' => static::OAUTH_RESPONSE_TYPE_CODE, 'client_id' => $this->clientId, 'access_type' => static::OAUTH_ACCESS_TYPE_OFFLINE];
if ($state) {
$query['state'] = $state;
}
if ($preferSignup) {
$query['prefer_signup'] = true;
}
return $uri->withQuery(http_build_query($query));
}
示例6: getHeaderViewData
protected function getHeaderViewData($title, Request $request = null)
{
$session = $this->get('session');
$header = new Header($title);
$header->stores = new Url($this->trans('header.stores'), '');
$header->help = new Url($this->trans('header.help'), '');
$header->callUs = new Url($this->trans('header.callUs', ['phone' => $this->config['sunrise.header.callUs']]), '');
$header->location = new ViewData();
$languages = new ViewDataCollection();
$routeParams = $request->get('_route_params');
$queryParams = \GuzzleHttp\Psr7\parse_query($request->getQueryString());
foreach ($this->config['languages'] as $language) {
$languageEntry = new ViewData();
if ($language == \Locale::getPrimaryLanguage($this->locale)) {
$languageEntry->selected = true;
}
$languageEntry->label = $this->trans('header.languages.' . $language);
$routeParams['_locale'] = $language;
$languageUri = $this->generateUrl($request->get('_route'), $routeParams);
$uri = new Uri($languageUri);
$languageEntry->value = (string) $uri->withQuery(\GuzzleHttp\Psr7\build_query($queryParams));
$languages->add($languageEntry);
}
$header->location->language = $languages;
// $countries = new ViewDataCollection();
// foreach ($this->config['countries'] as $country) {
// $countryEntry = new ViewData();
// $countryEntry->label = $this->trans('header.countries.' . $country);
// $countryEntry->value = $country;
// $countries->add($countryEntry);
// }
//
// $header->location->country = $countries;
$header->user = new ViewData();
$header->user->isLoggedIn = false;
$header->user->signIn = new Url('Login', '');
$header->miniCart = new ViewData();
$header->miniCart->totalItems = $session->get('cartNumItems', 0);
$header->navMenu = $this->getNavMenu();
return $header;
}
示例7: testQueryMustBeValid
/**
* @expectedException \InvalidArgumentException
*/
public function testQueryMustBeValid()
{
$uri = new Uri('');
$uri->withQuery(new \stdClass());
}
示例8: testDeletePatch
public function testDeletePatch()
{
$queryParams = ['test_query_key' => 'test_query_value'];
$url = new Uri('/test1/test2');
$queryStr = http_build_query($queryParams);
$url->withQuery($queryStr);
$reqHeaders = ['Content-Type' => 'application/json', 'X-Test-Header' => 'test_header_value'];
$reqOpts = ['headers' => $reqHeaders, 'query' => $queryParams];
$expRespData = ['value' => true];
$expResp = new Response(200, ['Content-Type' => 'application/json'], json_encode($expRespData));
$httpClient = $this->getMockHttpClient();
$httpClient->expects($this->once())->method('request')->with($this->equalTo('DELETE'), $this->equalTo($url->getPath()), $this->equalTo($reqOpts))->will($this->returnValue($expResp));
$client = new Client();
$client->setHttpClient($httpClient);
$data = $client->delete($url->getPath(), $queryParams, $reqHeaders);
$this->assertSame($expRespData, $data);
$this->assertSame($expResp, $client->getResponse());
}