Neos\Flow\Http\Request::getRelativePath PHP Метод

getRelativePath() публичный Метод

Returns the request's path relative to the $baseUri
public getRelativePath ( ) : string
Результат string
    public function getRelativePath()
    {
        $baseUriLength = strlen($this->getBaseUri()->getPath());
        if ($baseUriLength >= strlen($this->getUri()->getPath())) {
            return '';
        }
        return substr($this->getUri()->getPath(), $baseUriLength);
    }

Usage Example

Пример #1
0
 /**
  * Searches for a matching redirect for the given HTTP response
  *
  * @param Request $httpRequest
  * @return Response|null
  * @api
  */
 public function buildResponseIfApplicable(Request $httpRequest)
 {
     try {
         $redirect = $this->redirectStorage->getOneBySourceUriPathAndHost($httpRequest->getRelativePath(), $httpRequest->getBaseUri()->getHost());
         if ($redirect === null) {
             return null;
         }
         if (isset($this->featureSwitch['hitCounter']) && $this->featureSwitch['hitCounter'] === true) {
             $this->redirectStorage->incrementHitCount($redirect);
         }
         return $this->buildResponse($httpRequest, $redirect);
     } catch (\Exception $exception) {
         // Throw exception if it's a \Neos\RedirectHandler\Exception (used for custom exception handling)
         if ($exception instanceof Exception) {
             throw $exception;
         }
         // skip triggering the redirect if there was an error accessing the database (wrong credentials, ...)
         return null;
     }
 }
All Usage Examples Of Neos\Flow\Http\Request::getRelativePath