Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. UrlHelper.php

function UrlHelper::getRelativePath

File

vendor/symfony/http-foundation/UrlHelper.php, line 59

Class

UrlHelper
A helper service for manipulating URLs within and outside the request scope.

Namespace

Symfony\Component\HttpFoundation

Code

public function getRelativePath(string $path) : string {
    if (str_contains($path, '://') || str_starts_with($path, '//')) {
        return $path;
    }
    if (null === ($request = $this->requestStack
        ->getMainRequest())) {
        return $path;
    }
    return $request->getRelativeUriForPath($path);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal