ILIAS
release_5-3 Revision v5.3.23-19-g915713cf615
|
Resolves a URI reference in the context of a base URI and the opposite way. More...
Static Public Member Functions | |
static | removeDotSegments ($path) |
Removes dot segments from a path and returns the new path. More... | |
static | resolve (UriInterface $base, UriInterface $rel) |
Converts the relative URI into a new URI that is resolved against the base URI. More... | |
static | relativize (UriInterface $base, UriInterface $target) |
Returns the target URI as a relative reference from the base URI. More... | |
Private Member Functions | |
__construct () | |
Static Private Member Functions | |
static | getRelativePath (UriInterface $base, UriInterface $target) |
Resolves a URI reference in the context of a base URI and the opposite way.
https://tools.ietf.org/html/rfc3986#section-5
Definition at line 13 of file UriResolver.php.
|
private |
Definition at line 215 of file UriResolver.php.
|
staticprivate |
Definition at line 182 of file UriResolver.php.
References $i, Psr\Http\Message\UriInterface\getAuthority(), and Psr\Http\Message\UriInterface\getPath().
|
static |
Returns the target URI as a relative reference from the base URI.
This method is the counterpart to resolve():
(string) $target === (string) UriResolver::resolve($base, UriResolver::relativize($base, $target))
One use-case is to use the current request URI as base URI and then generate relative links in your documents to reduce the document size or offer self-contained downloadable document archives.
$base = new Uri('http://example.com/a/b/'); echo UriResolver::relativize($base, new Uri('http://example.com/a/b/c')); // prints 'c'. echo UriResolver::relativize($base, new Uri('http://example.com/a/x/y')); // prints '../x/y'. echo UriResolver::relativize($base, new Uri('http://example.com/a/b/?q')); // prints '?q'. echo UriResolver::relativize($base, new Uri('http://example.org/a/b/')); // prints '//example.org/a/b/'.
This method also accepts a target that is already relative and will try to relativize it further. Only a relative-path reference will be returned as-is.
echo UriResolver::relativize($base, new Uri('/a/b/c')); // prints 'c' as well
UriInterface | $base | Base URI |
UriInterface | $target | Target URI |
Definition at line 137 of file UriResolver.php.
References $target, Psr\Http\Message\UriInterface\getAuthority(), Psr\Http\Message\UriInterface\getPath(), Psr\Http\Message\UriInterface\getQuery(), Psr\Http\Message\UriInterface\getScheme(), GuzzleHttp\Psr7\Uri\isRelativePathReference(), and Psr\Http\Message\UriInterface\withScheme().
|
static |
Removes dot segments from a path and returns the new path.
string | $path |
Definition at line 23 of file UriResolver.php.
References $path, and $results.
Referenced by GuzzleHttp\Psr7\UriNormalizer\normalize(), and GuzzleHttp\Psr7\Uri\removeDotSegments().
|
static |
Converts the relative URI into a new URI that is resolved against the base URI.
UriInterface | $base | Base URI |
UriInterface | $rel | Relative URI |
Definition at line 62 of file UriResolver.php.
References $base, GuzzleHttp\Psr7\Uri\composeComponents(), Psr\Http\Message\UriInterface\getAuthority(), Psr\Http\Message\UriInterface\getFragment(), Psr\Http\Message\UriInterface\getPath(), Psr\Http\Message\UriInterface\getQuery(), Psr\Http\Message\UriInterface\getScheme(), and Psr\Http\Message\UriInterface\withPath().
Referenced by GuzzleHttp\Psr7\Uri\isSameDocumentReference(), and GuzzleHttp\Psr7\Uri\resolve().