本文整理匯總了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;
}
示例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;
}
示例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());
}
示例4: httpsRedirect
private function httpsRedirect(UriInterface $uri) : ResponseInterface
{
return new Response('php://memory', 307, ['Location' => strval($uri->withScheme('https')->withPort(443))]);
}
示例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');
}