本文整理汇总了PHP中Psr\Http\Message\UriInterface::getQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP UriInterface::getQuery方法的具体用法?PHP UriInterface::getQuery怎么用?PHP UriInterface::getQuery使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Psr\Http\Message\UriInterface
的用法示例。
在下文中一共展示了UriInterface::getQuery方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRequestTarget
public function getRequestTarget()
{
if ($this->requestTarget !== null) {
return $this->requestTarget;
}
$target = $this->uri->getPath();
if ($target == null) {
$target = '/';
}
if ($this->uri->getQuery()) {
$target .= '?' . $this->uri->getQuery();
}
return $target;
}
示例2: getRequestTarget
/**
* Retrieves the message's request target.
*
* Retrieves the message's request-target either as it will appear (for
* clients), as it appeared at request (for servers), or as it was
* specified for the instance (see withRequestTarget()).
*
* In most cases, this will be the origin-form of the composed URI,
* unless a value was provided to the concrete implementation (see
* withRequestTarget() below).
*
* If no URI is available, and no request-target has been specifically
* provided, this method will return the string "/".
*
* @return string
*/
public function getRequestTarget()
{
// Use the explicitly set request target first.
if (isset($this->requestTarget)) {
return $this->requestTarget;
}
// Build the origin form from the composed URI.
$target = $this->uri->getPath();
$query = $this->uri->getQuery();
if ($query) {
$target .= "?" . $query;
}
// Return "/" if the origin form is empty.
return $target ?: "/";
}
示例3: targetFromUri
/**
* Gets the request target from current URI
*
* @return string
*/
private function targetFromUri()
{
$target = $this->uri->getPath();
$target .= '' === $this->uri->getQuery() ? '' : '?' . $this->uri->getQuery();
$target = empty($target) ? '/' : $target;
return $target;
}
示例4: 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));
}
示例5: getRequestTarget
/**
* @return string
*/
public function getRequestTarget()
{
if (isset($this->requestTarget) && $this->requestTarget !== '') {
return $this->requestTarget;
}
if (!isset($this->uri)) {
return '/';
}
$target = $this->uri->getPath();
if ($this->uri->getQuery() !== '') {
$target .= '?' . $this->uri->getQuery();
}
if ($target === '') {
$target = '/';
}
return $target;
}
示例6: getRequestTarget
/**
* @inheritdoc
*/
public function getRequestTarget()
{
if ($this->requestTarget !== null) {
return $this->requestTarget;
}
$this->requireUri();
if ($this->uri === null) {
return '/';
}
$target = $this->uri->getPath();
$query = $this->uri->getQuery();
if ($query !== '') {
$target .= '?' . $query;
}
$this->requestTarget = $target;
return $this->requestTarget;
}
示例7: getRequestTarget
/**
* {@inheritdoc}
*/
public function getRequestTarget()
{
if ($this->requestTarget !== null) {
return $this->requestTarget;
}
if (!$this->uri instanceof UriInterface) {
return '/';
}
$this->requestTarget = $this->uri->getPath();
if (!$this->requestTarget) {
$this->requestTarget = '/';
}
if ($this->uri->getQuery()) {
$this->requestTarget .= '?' . $this->uri->getQuery();
}
return $this->requestTarget;
}
示例8: 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;
}
示例9: 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;
}
示例10: 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;
}
示例11: getQueryParam
/**
* Get a query parameter from a PSR-7 UriInterface
*
* @param UriInterface $uri
* @param string $param
*
* @return string|array|null
*/
public function getQueryParam(UriInterface $uri, $param)
{
if (!($query = $uri->getQuery())) {
return null;
}
parse_str($query, $params);
if (!array_key_exists($param, $params)) {
return null;
}
return $params[$param];
}
示例12: getRequestTarget
/**
* {@inheritdoc}
*/
public function getRequestTarget()
{
if ($this->requestTarget) {
return $this->requestTarget;
}
$target = $this->uri->getPath();
$target = $target ? $target : '/';
$query = $this->uri->getQuery();
$target .= $query ? '?' . $query : '';
return $target;
}
示例13: getQueryParams
/**
* Retrieve query string arguments.
*
* Retrieves the deserialized query string arguments, if any.
*
* Note: the query params might not be in sync with the URI or server
* params. If you need to ensure you are only getting the original
* values, you may need to parse the query string from `getUri()->getQuery()`
* or from the `QUERY_STRING` server param.
*
* @return array
*/
public function getQueryParams()
{
if ($this->queryParams) {
return $this->queryParams;
}
if ($this->uri === null) {
return [];
}
parse_str($this->uri->getQuery(), $this->queryParams);
// <-- URL decodes data
return $this->queryParams;
}
示例14: 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;
}
示例15: resolve
/**
* Converts the relative URI into a new URI that is resolved against the base URI.
*
* @param UriInterface $base Base URI
* @param UriInterface $rel Relative URI
*
* @return UriInterface
* @link http://tools.ietf.org/html/rfc3986#section-5.2
*/
public static function resolve(UriInterface $base, UriInterface $rel)
{
if ((string) $rel === '') {
// we can simply return the same base URI instance for this same-document reference
return $base;
}
if ($rel->getScheme() != '') {
return $rel->withPath(self::removeDotSegments($rel->getPath()));
}
if ($rel->getAuthority() != '') {
$targetAuthority = $rel->getAuthority();
$targetPath = self::removeDotSegments($rel->getPath());
$targetQuery = $rel->getQuery();
} else {
$targetAuthority = $base->getAuthority();
if ($rel->getPath() === '') {
$targetPath = $base->getPath();
$targetQuery = $rel->getQuery() != '' ? $rel->getQuery() : $base->getQuery();
} else {
if ($rel->getPath()[0] === '/') {
$targetPath = $rel->getPath();
} else {
if ($targetAuthority != '' && $base->getPath() === '') {
$targetPath = '/' . $rel->getPath();
} else {
$lastSlashPos = strrpos($base->getPath(), '/');
if ($lastSlashPos === false) {
$targetPath = $rel->getPath();
} else {
$targetPath = substr($base->getPath(), 0, $lastSlashPos + 1) . $rel->getPath();
}
}
}
$targetPath = self::removeDotSegments($targetPath);
$targetQuery = $rel->getQuery();
}
}
return new Uri(Uri::composeComponents($base->getScheme(), $targetAuthority, $targetPath, $targetQuery, $rel->getFragment()));
}