当前位置: 首页>>代码示例>>PHP>>正文


PHP Uri::withQuery方法代码示例

本文整理汇总了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, '/');
     }
 }
开发者ID:vladislavl-hyuna,项目名称:crmapp,代码行数:10,代码来源:Uri.php

示例2: getUri

 /**
  * @return \Psr\Http\Message\UriInterface
  */
 public function getUri()
 {
     $uri = new Uri($this->serviceUri);
     return $uri->withQuery(\GuzzleHttp\Psr7\build_query($this->params));
 }
开发者ID:spalax,项目名称:keywordtool-client,代码行数:8,代码来源:Request.php

示例3: appendPath

 public static function appendPath($url, $path)
 {
     $uri = new Psr7Uri($url);
     $cutUrl = (string) $uri->withQuery('')->withFragment('');
     return rtrim($cutUrl, '/') . '/' . ltrim($path, '/');
 }
开发者ID:hitechdk,项目名称:Codeception,代码行数:6,代码来源:Uri.php

示例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);
 }
开发者ID:zloesabo,项目名称:speechkit-php,代码行数:10,代码来源:UrlGenerator.php

示例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));
 }
开发者ID:sellerlabs,项目名称:slapp-client-php,代码行数:22,代码来源:Client.php

示例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;
 }
开发者ID:sphereio,项目名称:commercetools-sunrise-php,代码行数:41,代码来源:SunriseController.php

示例7: testQueryMustBeValid

 /**
  * @expectedException \InvalidArgumentException
  */
 public function testQueryMustBeValid()
 {
     $uri = new Uri('');
     $uri->withQuery(new \stdClass());
 }
开发者ID:kirill-konshin,项目名称:psr7,代码行数:8,代码来源:UriTest.php

示例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());
 }
开发者ID:flemeur,项目名称:bhapi-php-client,代码行数:18,代码来源:ClientTest.php


注:本文中的GuzzleHttp\Psr7\Uri::withQuery方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。