當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。