本文整理汇总了PHP中Psr\Http\Message\UriInterface类的典型用法代码示例。如果您正苦于以下问题:PHP UriInterface类的具体用法?PHP UriInterface怎么用?PHP UriInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UriInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @param UriInterface $uri Has to contain a host name and cans have a path.
* @param array $hostConfig Config for AddHostPlugin. @see AddHostPlugin::configureOptions
*/
public function __construct(UriInterface $uri, array $hostConfig = [])
{
$this->addHostPlugin = new AddHostPlugin($uri, $hostConfig);
if (rtrim($uri->getPath(), '/')) {
$this->addPathPlugin = new AddPathPlugin($uri);
}
}
示例2: setBase
public function setBase(UriInterface $uri)
{
$base = (string) $uri->withPath('')->withQuery('')->withFragment('');
if ($base and $base !== $this->base) {
$this->base = $base;
}
}
示例3: handle
/**
* @param AccessToken $accessToken
* @param UriInterface $destination
* @return Response
*/
public function handle(AccessToken $accessToken, UriInterface $destination)
{
$claims = $this->userService->getUserClaims($accessToken)->toArray();
$jwt = $this->encoderService->encode($claims);
$q = $destination->getQuery();
$q .= ($q ? '&' : '') . 'jwt=' . $jwt;
return new RedirectResponse((string) $destination->withQuery($q));
}
示例4: updateBaseUri
public function updateBaseUri(UriInterface $uri)
{
$base = (string) $uri->withPath('')->withQuery('')->withFragment('');
$oldBase = (string) $this->getClient()->getConfig('base_uri');
if ($base and $base !== $oldBase) {
$this->client = new Client(['base_uri' => $base]);
}
}
示例5: sameValueAs
/**
* {@inheritdoc}
*/
public function sameValueAs(UriInterface $url)
{
try {
return static::createFromComponents($this->schemeRegistry, static::Parse($url->__toString()))->toAscii()->normalize()->ksortQuery()->__toString() === $this->toAscii()->normalize()->ksortQuery()->__toString();
} catch (InvalidArgumentException $e) {
return false;
}
}
示例6: 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;
}
示例7: createRtmpUrl
private function createRtmpUrl(UriInterface $uri)
{
// Use a relative URL when creating Flash player URLs
$result = ltrim($uri->getPath(), '/');
if ($query = $uri->getQuery()) {
$result .= '?' . $query;
}
return $result;
}
示例8: addQueryParameters
/**
* Merges additional query parameters with current query parameters (possibly overwriting (some of) them)
*
* @param UriInterface $uri
* @param array $queryParameters Query parameters to add / overwrite
* @return UriInterface
*/
public static function addQueryParameters(UriInterface $uri, array $queryParameters)
{
$originalQuery = $uri->getQuery();
$originalQueryParameters = [];
parse_str($originalQuery, $originalQueryParameters);
$newQueryParameters = array_replace_recursive($originalQueryParameters, $queryParameters);
$newQuery = http_build_query($newQueryParameters);
$newUri = $uri->withQuery($newQuery);
return $newUri;
}
示例9: getQueryParams
/**
* Gets the query parameters as an array from a ``UriInterface`` instance.
*
* @param UriInterface $uri
* @param array $exclude
* @param array $params
*
* @return array
*/
public function getQueryParams(UriInterface $uri, $exclude = ['sig'], $params = [])
{
parse_str($uri->getQuery(), $params);
foreach ($exclude as $excludedParam) {
if (array_key_exists($excludedParam, $params)) {
unset($params[$excludedParam]);
}
}
return $params;
}
示例10: withUri
public function withUri(Psr7UriInterface $uri, $preserveHost = false)
{
$new = clone $this;
$new->uri = $uri;
$uriHost = $uri->getHost();
$requestHost = $new->getHeaderLine('Host');
if (!$preserveHost && $uriHost !== $requestHost) {
return $new->withHeader('Host', $uriHost);
}
return $new;
}
示例11: parseVirtualHosted
private function parseVirtualHosted(UriInterface $url, array $matches)
{
$result = self::$defaultResult;
$result['path_style'] = false;
// Remove trailing "." from the prefix to get the bucket
$result['bucket'] = substr($matches[1], 0, -1);
$path = $url->getPath();
// Check if a key was present, and if so, removing the leading "/"
$result['key'] = !$path || $path == '/' ? null : substr($path, 1);
return $result;
}
示例12: withUri
public function withUri(\Psr\Http\Message\UriInterface $uri, $preserveHost = false)
{
$request = clone $this;
$request->uri = $uri;
if (!$preserveHost or !$this->hasHeader('Host')) {
$host = $uri->getHost();
if ($host != '') {
$request->setHeader('Host', $host);
}
}
return $request;
}
示例13: withUri
function withUri(UriInterface $uri, $preserveHost = FALSE) : self
{
$headers = $this->headers;
$headers['HOST'] = $headers['HOST'] ?? [];
if (!$preserveHost && $uri->getHost()) {
$headers['HOST'] = [$uri->getHost()];
}
$new = clone $this;
$new->headers = $headers;
$new->headerNames['HOST'] = 'Host';
$new->uri = parse_url((string) $uri);
return $new;
}
示例14: isFiltered
public function isFiltered(UriInterface $currentUri, UriInterface $startUri)
{
/* @var $currentUri Uri */
/* @var $startUri Uri */
$startDomainElements = explode('.', $startUri->getHost());
$currentDomainElements = explode('.', $currentUri->getHost());
$startDomainLength = count($startDomainElements);
$currentDomainLength = count($currentDomainElements);
if ($currentDomainLength < $startDomainLength) {
return true;
}
return $currentUri->getHost($startDomainLength) !== $startUri->getHost($startDomainLength);
}
示例15: getSelectedValues
public function getSelectedValues(UriInterface $uri)
{
$queryParams = Psr7\parse_query($uri->getQuery());
$selectedValues = [];
foreach ($queryParams as $paramName => $params) {
if (!isset($this->paramFacets[$paramName])) {
continue;
}
$facetName = $this->paramFacets[$paramName];
$selectedValues[$facetName] = $params;
}
return $selectedValues;
}