本文整理汇总了PHP中Psr\Http\Message\UriInterface::getPath方法的典型用法代码示例。如果您正苦于以下问题:PHP UriInterface::getPath方法的具体用法?PHP UriInterface::getPath怎么用?PHP UriInterface::getPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Psr\Http\Message\UriInterface
的用法示例。
在下文中一共展示了UriInterface::getPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createUrlFromUri
/**
* @param string $specification
* @return string
*/
private function createUrlFromUri($specification)
{
preg_match('%^(?P<path>[^?#]*)(?:(?:\\?(?P<query>[^#]*))?(?:\\#(?P<fragment>.*))?)$%', (string) $specification, $matches);
$path = $matches['path'];
$query = isset($matches['query']) ? $matches['query'] : '';
$fragment = isset($matches['fragment']) ? $matches['fragment'] : '';
$uri = $this->uri->withQuery('')->withFragment('');
// Relative path
if (!empty($path) && '/' !== $path[0]) {
$path = rtrim($this->uri->getPath(), '/') . '/' . $path;
}
// Path present; set on URI
if (!empty($path)) {
$uri = $uri->withPath($path);
}
// Query present; set on URI
if (!empty($query)) {
$uri = $uri->withQuery($query);
}
// Fragment present; set on URI
if (!empty($fragment)) {
$uri = $uri->withFragment($fragment);
}
return (string) $uri;
}
示例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 MUST return the string "/".
*
* @return string
*/
public function getRequestTarget() : string
{
if ($this->target !== null) {
return $this->target;
}
return $this->uri->getPath() === '' ? '/' : $this->uri->getPath();
}
示例3: 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;
}
示例4: 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;
}
示例5: 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 ?: "/";
}
示例6: 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;
}
示例7: __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);
}
}
示例8: 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;
}
示例9: 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;
}
示例10: 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;
}
示例11: 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;
}
示例12: getPath
/**
* Gets the path from a ``UriInterface`` instance after removing the version
* prefix.
*
* @param UriInterface $uri
*
* @return string
*/
public function getPath(UriInterface $uri)
{
$path = trim($uri->getPath(), '/');
$parts = explode('/', $path);
if ($parts[0] === 'v' . Client::API_VERSION) {
unset($parts[0]);
}
return '/' . implode('/', $parts);
}
示例13: 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;
}
示例14: runUri
/**
* Perform URI check.
* @param null|integer|string $var1
* @param mixed $var2
* @param mixed $var3
* @param mixed $var4
* @return mixed
*/
public function runUri($var1 = null, $var2 = null, $var3 = null, $var4 = null)
{
if (is_null($var1)) {
return $this->uri->getPath();
}
if (is_numeric($var1) and is_null($var2)) {
return $this->parts[$var1];
}
if (is_numeric($var1) and is_string($var2)) {
return $this->checkUriSegmentMatch($var1, $var2, $var3, $var4);
}
if (is_string($var1)) {
return $this->checkUriRegexMatch($var1, $var2, $var3);
}
throw new LogicException('Invalid use of the uri function.');
}
示例15: 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 MUST return the string "/".
*
* @return string
*/
public function getRequestTarget()
{
if ($this->requestTarget) {
return $this->requestTarget;
}
if ($this->uri === null) {
return '/';
}
$path = '/' . ltrim($this->uri->getPath(), '/');
$query = $this->uri->getQuery();
if ($query) {
$path .= '?' . $query;
}
$this->requestTarget = $path;
return $this->requestTarget;
}