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


PHP Request::getRelativePath方法代码示例

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


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

示例1: findOneByRequest

 /**
  * @param HttpRequest $request
  * @return Redirection
  */
 public function findOneByRequest(HttpRequest $request)
 {
     $requestPath = preg_replace('/(\\\\|%|_)/', '\\\\$1', $request->getRelativePath());
     $query = $this->createQuery();
     $query->getQueryBuilder()->where(':requestPath LIKE e.requestPattern')->setParameter('requestPath', $requestPath);
     return $query->execute()->getFirst();
 }
开发者ID:bwaidelich,项目名称:Wwwision.Redirects,代码行数:11,代码来源:RedirectionRepository.php

示例2: sendRedirectHeaders

 /**
  * @param HttpRequest $request
  * @param Redirection $redirection
  * @return void
  */
 protected function sendRedirectHeaders(HttpRequest $request, Redirection $redirection)
 {
     if (headers_sent()) {
         return;
     }
     $sourceUriPath = $redirection->getRequestPattern();
     $targetUriPath = $redirection->getTarget();
     if (strpos($sourceUriPath, '%') !== false) {
         $sourceUriPath = preg_quote($sourceUriPath, '/');
         $sourceUriPath = str_replace('%', '(.*)', $sourceUriPath);
         $targetUriPath = preg_replace('/' . $sourceUriPath . '/', $redirection->getTarget(), $request->getRelativePath());
     }
     header($redirection->getStatusLine());
     header('Location: ' . $request->getBaseUri() . $targetUriPath);
 }
开发者ID:bwaidelich,项目名称:Wwwision.Redirects,代码行数:20,代码来源:RedirectService.php

示例3: buildRouteCacheIdentifier

 /**
  * Generates the Matching cache identifier for the given Request
  *
  * @param Request $httpRequest
  * @return string
  */
 protected function buildRouteCacheIdentifier(Request $httpRequest)
 {
     return md5(sprintf('%s_%s_%s', $httpRequest->getUri()->getHost(), $httpRequest->getRelativePath(), $httpRequest->getMethod()));
 }
开发者ID:nlx-sascha,项目名称:flow-development-collection,代码行数:10,代码来源:RouterCachingService.php

示例4: matches

 /**
  * Checks whether $routePath corresponds to this Route.
  * If all Route Parts match successfully TRUE is returned and
  * $this->matchResults contains an array combining Route default values and
  * calculated matchResults from the individual Route Parts.
  *
  * @param \TYPO3\Flow\Http\Request $httpRequest the HTTP request to match
  * @return boolean TRUE if this Route corresponds to the given $routePath, otherwise FALSE
  * @throws InvalidRoutePartValueException
  * @see getMatchResults()
  */
 public function matches(Request $httpRequest)
 {
     $routePath = $httpRequest->getRelativePath();
     $this->matchResults = null;
     if ($this->uriPattern === null) {
         return false;
     }
     if (!$this->isParsed) {
         $this->parse();
     }
     if ($this->hasHttpMethodConstraints() && !in_array($httpRequest->getMethod(), $this->httpMethods)) {
         return false;
     }
     $matchResults = array();
     $routePath = trim($routePath, '/');
     $skipOptionalParts = false;
     $optionalPartCount = 0;
     /** @var $routePart RoutePartInterface */
     foreach ($this->routeParts as $routePart) {
         if ($routePart->isOptional()) {
             $optionalPartCount++;
             if ($skipOptionalParts) {
                 if ($routePart->getDefaultValue() === null) {
                     return false;
                 }
                 continue;
             }
         } else {
             $optionalPartCount = 0;
             $skipOptionalParts = false;
         }
         if ($routePart->match($routePath) !== true) {
             if ($routePart->isOptional() && $optionalPartCount === 1) {
                 if ($routePart->getDefaultValue() === null) {
                     return false;
                 }
                 $skipOptionalParts = true;
             } else {
                 return false;
             }
         }
         $routePartValue = $routePart->getValue();
         if ($routePartValue !== null) {
             if ($this->containsObject($routePartValue)) {
                 throw new InvalidRoutePartValueException('RoutePart::getValue() must only return simple types after calling RoutePart::match(). RoutePart "' . get_class($routePart) . '" returned one or more objects in Route "' . $this->getName() . '".');
             }
             $matchResults = Arrays::setValueByPath($matchResults, $routePart->getName(), $routePartValue);
         }
     }
     if (strlen($routePath) > 0) {
         return false;
     }
     $this->matchResults = Arrays::arrayMergeRecursiveOverrule($this->defaults, $matchResults);
     return true;
 }
开发者ID:robertlemke,项目名称:flow-development-collection,代码行数:66,代码来源:Route.php


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