當前位置: 首頁>>代碼示例>>PHP>>正文


PHP UriInterface::withScheme方法代碼示例

本文整理匯總了PHP中Psr\Http\Message\UriInterface::withScheme方法的典型用法代碼示例。如果您正苦於以下問題:PHP UriInterface::withScheme方法的具體用法?PHP UriInterface::withScheme怎麽用?PHP UriInterface::withScheme使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Psr\Http\Message\UriInterface的用法示例。


在下文中一共展示了UriInterface::withScheme方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: buildRouteUri

 /**
  * Builds URI for provided route instance.
  *
  * @param RouteContract $route
  * @param array $variables
  * @param array $query
  * @return UriInterface
  */
 private function buildRouteUri(RouteContract $route, array $variables = [], array $query = []) : UriInterface
 {
     $uri = $this->uri->withScheme($route->getScheme() ?: $this->request->getUri()->getScheme())->withHost($route->getHost() ?: $this->request->getUri()->getHost())->withPath($route->compilePath($variables));
     if ($query) {
         $uri = $uri->withQuery(http_build_query($query));
     }
     return $uri;
 }
開發者ID:venta,項目名稱:framework,代碼行數:16,代碼來源:UrlGenerator.php

示例2: processProtoHeader

 protected function processProtoHeader(ServerRequestInterface $request, UriInterface $uri)
 {
     if ($request->hasHeader('X-Forwarded-Proto')) {
         $scheme = $request->getHeaderLine('X-Forwarded-Proto');
         if (in_array($scheme, ['http', 'https'])) {
             return $uri->withScheme($scheme);
         }
     }
     return $uri;
 }
開發者ID:akrabat,項目名稱:rka-scheme-and-host-detection-middleware,代碼行數:10,代碼來源:SchemeAndHost.php

示例3: generate

 /**
  * @param LeagueUriInterface|UriInterface $relative
  *
  * @return LeagueUriInterface|UriInterface
  */
 protected function generate($relative)
 {
     $scheme = $relative->getScheme();
     if (!empty($scheme) && $scheme != $this->uri->getScheme()) {
         return $relative;
     }
     if (!empty($relative->getAuthority())) {
         return $relative->withScheme($this->uri->getScheme());
     }
     return $this->resolveRelative($relative)->withFragment($relative->getFragment());
 }
開發者ID:burguin,項目名稱:test02,代碼行數:16,代碼來源:Resolve.php

示例4: httpsRedirect

 private function httpsRedirect(UriInterface $uri) : ResponseInterface
 {
     return new Response('php://memory', 307, ['Location' => strval($uri->withScheme('https')->withPort(443))]);
 }
開發者ID:WebspotCode,項目名稱:SpotApi,代碼行數:4,代碼來源:HstsMiddleware.php

示例5: withScheme

 /**
  * Create an UriInterface with the scheme information from `$server`. It uses `$server['HTTPS']` to determine the
  * scheme.
  *
  * @param UriInterface $uri
  * @param array        $server
  *
  * @return UriInterface
  */
 private function withScheme(UriInterface $uri, array $server) : UriInterface
 {
     if (isset($server['HTTPS'])) {
         return $uri->withScheme($server['HTTPS'] == 'on' ? 'https' : 'http');
     }
     return $uri->withScheme('http');
 }
開發者ID:opsbears,項目名稱:piccolo-web-io-standard,代碼行數:16,代碼來源:StandardInputProcessor.php


注:本文中的Psr\Http\Message\UriInterface::withScheme方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。