当前位置: 首页>>代码示例>>PHP>>正文


PHP UriInterface::getPath方法代码示例

本文整理汇总了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;
 }
开发者ID:zendframework,项目名称:zend-expressive-helpers,代码行数:29,代码来源:ServerUrlHelper.php

示例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();
 }
开发者ID:afridlund85,项目名称:php7-api-framework,代码行数:23,代码来源:Request.php

示例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;
 }
开发者ID:tlumx,项目名称:framework,代码行数:14,代码来源:Request.php

示例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;
 }
开发者ID:cdyweb,项目名称:http-adapter,代码行数:14,代码来源:Request.php

示例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 ?: "/";
 }
开发者ID:pjdietz,项目名称:wellrested,代码行数:31,代码来源:Request.php

示例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;
 }
开发者ID:slickframework,项目名称:http,代码行数:12,代码来源:Request.php

示例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);
     }
 }
开发者ID:php-http,项目名称:client-common,代码行数:11,代码来源:BaseUriPlugin.php

示例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;
 }
开发者ID:Golpha,项目名称:Http,代码行数:20,代码来源:RequestTrait.php

示例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;
 }
开发者ID:phpixie,项目名称:http,代码行数:20,代码来源:Request.php

示例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;
 }
开发者ID:radphp,项目名称:network,代码行数:20,代码来源:Request.php

示例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;
 }
开发者ID:AWSRandall,项目名称:aws-sdk-php,代码行数:9,代码来源:UrlSigner.php

示例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);
 }
开发者ID:larabros,项目名称:elogram,代码行数:17,代码来源:UrlParserTrait.php

示例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;
 }
开发者ID:Air-Craft,项目名称:air-craft-www,代码行数:11,代码来源:S3UriParser.php

示例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.');
 }
开发者ID:hidayat365,项目名称:phpindonesia.or.id-membership2,代码行数:24,代码来源:PlatesUriExtension.php

示例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;
 }
开发者ID:slimphp,项目名称:Slim-Http,代码行数:32,代码来源:Request.php


注:本文中的Psr\Http\Message\UriInterface::getPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。