Lines Matching full:base
10 * Resolves a URI reference in the context of a base URI and the opposite way.
54 * Converts the relative URI into a new URI that is resolved against the base URI.
58 public static function resolve(UriInterface $base, UriInterface $rel): UriInterface argument
61 // we can simply return the same base URI instance for this same-document reference
62 return $base;
74 $targetAuthority = $base->getAuthority();
76 $targetPath = $base->getPath();
77 $targetQuery = $rel->getQuery() != '' ? $rel->getQuery() : $base->getQuery();
82 if ($targetAuthority != '' && $base->getPath() === '') {
85 $lastSlashPos = strrpos($base->getPath(), '/');
89 … $targetPath = substr($base->getPath(), 0, $lastSlashPos + 1).$rel->getPath();
99 $base->getScheme(),
108 * Returns the target URI as a relative reference from the base URI.
112 …* (string) $target === (string) UriResolver::resolve($base, UriResolver::relativize($base, $tar…
114 …* One use-case is to use the current request URI as base URI and then generate relative links in y…
117 * $base = new Uri('http://example.com/a/b/');
118 * echo UriResolver::relativize($base, new Uri('http://example.com/a/b/c')); // prints 'c'.
119 …* echo UriResolver::relativize($base, new Uri('http://example.com/a/x/y')); // prints '../x/y'.
120 * echo UriResolver::relativize($base, new Uri('http://example.com/a/b/?q')); // prints '?q'.
121 …* echo UriResolver::relativize($base, new Uri('http://example.org/a/b/')); // prints '//examp…
126 * echo UriResolver::relativize($base, new Uri('/a/b/c')); // prints 'c' as well
128 public static function relativize(UriInterface $base, UriInterface $target): UriInterface argument
131 …&& ($base->getScheme() !== $target->getScheme() || $target->getAuthority() === '' && $base->getAut…
138 … // the target with `$target = self::resolve($base, $target);` and then try make it more relative
143 if ($target->getAuthority() !== '' && $base->getAuthority() !== $target->getAuthority()) {
152 if ($base->getPath() !== $target->getPath()) {
153 return $emptyPathUri->withPath(self::getRelativePath($base, $target));
156 if ($base->getQuery() === $target->getQuery()) {
157 …// Only the target fragment is left. And it must be returned even if base and target fragment are …
161 …// If the base URI has a query but the target has none, we cannot return an empty path reference a…
162 // inherit the base query component when resolving.
174 private static function getRelativePath(UriInterface $base, UriInterface $target): string argument
176 $sourceSegments = explode('/', $base->getPath());
196 if ($base->getAuthority() != '' && $base->getPath() === '') {