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


PHP ServerRequestInterface::withUri方法代码示例

本文整理汇总了PHP中Psr\Http\Message\ServerRequestInterface::withUri方法的典型用法代码示例。如果您正苦于以下问题:PHP ServerRequestInterface::withUri方法的具体用法?PHP ServerRequestInterface::withUri怎么用?PHP ServerRequestInterface::withUri使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Psr\Http\Message\ServerRequestInterface的用法示例。


在下文中一共展示了ServerRequestInterface::withUri方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addLanguage

 public function addLanguage(ServerRequestInterface $request, $language)
 {
     $path = $request->getUri()->getPath();
     if ($language !== $this->environment->getDefaultLanguage()) {
         $path = '/' . $language . ($path === '/' ? '' : $path);
     }
     return $request->withUri($request->getUri()->withPath($path));
 }
开发者ID:gobline,项目名称:environment,代码行数:8,代码来源:LanguageSubdirectoryResolver.php

示例2: guess

 /**
  * Guesses the base URI of the application.
  *
  * @param  Psr\Http\Message\ServerRequestInterface $request
  * @return Psr\Http\Message\ServerRequestInterface
  */
 public static function guess(\Psr\Http\Message\ServerRequestInterface $request)
 {
     $server = $request->getServerParams();
     $basename = basename($server['SCRIPT_FILENAME']);
     $position = strpos($server['SCRIPT_NAME'], $basename) - 1;
     $rootUri = substr($server['SCRIPT_NAME'], 0, $position);
     $oldPath = $request->getUri()->getPath();
     $newPath = str_replace($rootUri, '', $oldPath);
     $uri = $request->getUri()->withPath($newPath);
     return $request->withUri($uri);
 }
开发者ID:rougin,项目名称:slytherin,代码行数:17,代码来源:BaseUriGuesser.php

示例3: updatePath

 /**
  * Updates the request URI to remove the base directory.
  *
  * @param string $base The base path to remove.
  * @param \Psr\Http\Message\ServerRequestInterface $request The request to modify.
  * @return \Psr\Http\Message\ServerRequestInterface The modified request.
  */
 protected static function updatePath($base, $request)
 {
     $uri = $request->getUri();
     $path = $uri->getPath();
     if (strlen($base) > 0 && strpos($path, $base) === 0) {
         $path = substr($path, strlen($base));
     }
     if (empty($path) || $path === '/' || $path === '//' || $path === '/index.php') {
         $path = '/';
     }
     $endsWithIndex = '/webroot/index.php';
     $endsWithLength = strlen($endsWithIndex);
     if (strlen($path) >= $endsWithLength && substr($path, -$endsWithLength) === $endsWithIndex) {
         $path = '/';
     }
     return $request->withUri($uri->withPath($path));
 }
开发者ID:nrother,项目名称:cakephp,代码行数:24,代码来源:ServerRequestFactory.php

示例4: convertToProxiedRequest

 /**
  * @return \Psr\Http\Message\RequestInterface
  */
 public function convertToProxiedRequest()
 {
     $proxiedUri = $this->request->getUri()->withScheme($this->proxyUri->getScheme())->withHost($this->proxyUri->getHost())->withPath(rtrim($this->proxyUri->getPath(), '/') . $this->request->getUri()->getPath());
     if ($this->proxyUri->getPort() != null) {
         $proxiedUri = $proxiedUri->withPort($this->proxyUri->getPort());
     } else {
         $proxiedUri = $proxiedUri->withPort($proxiedUri->getScheme() === "https" ? 443 : 80);
     }
     $proxiedRequest = $this->request->withUri($proxiedUri)->withHeader("host", $this->proxyUri->getHost());
     if ($proxiedRequest->getBody()->getSize() === null && $proxiedRequest->getHeaderLine("User-Agent") == "Http_TestCase/1.0") {
         // FIXME
         // Prevents an incompatibility with PHP-VCR :
         // Without this the stream size is null and not 0 so CurlFactory#applyBody is applied and it sets a
         // CURLOPT_READFUNCTION on the request, but not a CURLOPT_INFILESIZE ; which makes VCR fails.
         // See https://github.com/guzzle/guzzle/commit/0a3065ea4639c1df8b9220bc8ca3fb529d7f8b52#commitcomment-12551295
         $proxiedRequest = $proxiedRequest->withBody(\GuzzleHttp\Psr7\stream_for());
     }
     return $proxiedRequest;
 }
开发者ID:jvelo,项目名称:proxy-factory,代码行数:22,代码来源:ProxyFactory.php

示例5: withUri

 /**
  * {@inheritdoc}
  */
 public function withUri(UriInterface $uri, $preserveHost = false)
 {
     return new static($this->wrapped->withUri($uri, $preserveHost));
 }
开发者ID:Mosaic,项目名称:Mosaic,代码行数:7,代码来源:Request.php

示例6: withUri

 /**
  * {@inheritDoc}
  */
 public function withUri(UriInterface $uri, $preserveHost = false)
 {
     return new self($this->app, $this->psrRequest->withUri($uri, $preserveHost));
 }
开发者ID:tonis-io,项目名称:tonis,代码行数:7,代码来源:Request.php

示例7: __invoke

 /**
  * Execute the middleware.
  *
  * @param ServerRequestInterface $request
  * @param ResponseInterface      $response
  * @param callable               $next
  *
  * @return ResponseInterface
  */
 public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next)
 {
     return $next($request->withUri(self::getRealUri($request), true), $response);
 }
开发者ID:corporateanon,项目名称:cisco-twitter,代码行数:13,代码来源:ProxiedHttpsSupport.php

示例8: stripRouteFromPath

 /**
  * Strip the route from the request path
  *
  * @param ServerRequestInterface $request
  * @param string $route
  * @return ServerRequestInterface
  */
 private function stripRouteFromPath(ServerRequestInterface $request, $route)
 {
     $this->removed = $route;
     $uri = $request->getUri();
     $path = $this->getTruncatedPath($route, $uri->getPath());
     $new = $uri->withPath($path);
     // Root path of route is treated differently
     if ($path === '/' && '/' === substr($uri->getPath(), -1)) {
         $this->removed .= '/';
     }
     return $request->withUri($new);
 }
开发者ID:fabiocarneiro,项目名称:zend-stratigility,代码行数:19,代码来源:Next.php

示例9: withUri

 /**
  * Allow mutating the URI
  *
  * {@inheritdoc}
  */
 public function withUri(UriInterface $uri, $preserveHost = false)
 {
     $new = $this->psrRequest->withUri($uri, $preserveHost);
     return new self($new, $this->originalRequest);
 }
开发者ID:michaelmoussa,项目名称:zend-stratigility,代码行数:10,代码来源:Request.php

示例10: filterRequest

 /**
  * Filters the request base URI to filter development and debugging stuff.
  *
  * @param Request         $request Request to be filtered
  * @param array|\stdClass $filters ArrayAccess filters
  *
  * @author Benjamin Carl <opensource@clickalicious.de>
  *
  * @return Request Filtered and prepared request instance
  * @static
  */
 protected static function filterRequest(Request $request, $filters)
 {
     $tmp = [];
     foreach ($filters as $filter) {
         $tmp[] = $filter;
     }
     $filter = new \Doozr_Filter($tmp);
     return $request->withUri($request->getUri()->withPath($filter->apply($request->getUri()->getPath())));
 }
开发者ID:clickalicious,项目名称:doozr,代码行数:20,代码来源:Kernel.php

示例11: withUri

 /**
  * @inheritDoc
  */
 public function withUri(UriInterface $uri, $preserveHost = false)
 {
     $self = clone $this;
     $self->serverRequest = $this->serverRequest->withUri($uri, $preserveHost);
     return $self;
 }
开发者ID:superbull,项目名称:super,代码行数:9,代码来源:Request.php


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