18 declare(strict_types=1);
   120         if ($name === 
'' || empty($namespace)) {
   121             throw new \InvalidArgumentException(
"Parameter name or namespace not set");
   124         $parameter = implode(self::SEPARATOR, $namespace) . self::SEPARATOR . $name;
   126             throw new \ilException(
"Parameter '" . $parameter . 
"' already reserved in URL");
   130         $clone = clone $this;
   131         $clone->params[$parameter] = ($initial_value) ?? 
'';
   132         $clone->tokens[$parameter] = 
$token;
   141         foreach ($names as $name) {
   142             list($builder, 
$token) = $builder->acquireParameter($namespace, $name);
   145         array_unshift($tokens, $builder);
   155         $clone = clone $this;
   156         unset($clone->params[$token->
getName()]);
   157         unset($clone->tokens[$token->
getName()]);
   168         $clone = clone $this;
   169         $clone->params[$token->
getName()] = $value;
   185         foreach ($tokens as 
$token) {
   186             $token_render[] = 
'["' . $token->getName() . 
'",' . $token->render() . 
']';
   188         $output = 
'new Map([' . implode(
',', $token_render) . 
'])';
   204         $output = 
'new il.UI.core.URLBuilder(new URL("' . $this->
buildURI() . 
'"), ' . $this->
renderTokens($tokens) . 
')';
   226         $params = array_merge($this->uri->getParameters(), 
$this->params);
   227         $query = (! empty($params)) ? 
'?' . http_build_query($params) : 
'';
   228         $query = preg_replace(
'/%5B[0-9]+%5D/simU', 
'%5B%5D', $query);
   237         if ($this->fragment !== null) {
   238             return ($this->fragment !== 
'') ? 
'#' . $this->fragment : 
'';
   240         $fragment = ($this->uri->getFragment()) ? 
'#' . $this->uri->getFragment() : 
'';
   249         return array_key_exists($name, $this->params);
   260         if (! in_array($token, $this->tokens)
   261         || $this->tokens[$token->
getName()]->getToken() !== $token->
getToken()) {
   262             throw new \DomainException(
"Token for '" . $token->
getName() . 
"' is not valid");
   265             throw new \ilException(
"Parameter '" . $token->
getName() . 
"' does not exist in URL");
   276         if (! (strlen((
string) $uri) <= self::URL_MAX_LENGTH)) {
   277             throw new \LengthException(
"The final URL is longer than " . self::URL_MAX_LENGTH . 
" and will not be valid.");
 if($err=$client->getError()) $namespace
 
string $fragment
Stores the URL fragment/hash (#) (always changeable due to its usage) 
 
getName()
Get the full name of the token including its namespace. 
 
URI $uri
Base URI for the URLBuilder. 
 
parameterExists(string $name)
Check if parameter was already acquired. 
 
buildFragment()
Create the fragment/hash part of the URL. 
 
buildURI()
Get a URI representation of the full URL including query string and fragment/hash. 
 
const URL_MAX_LENGTH
A maximum length of 2048 characters should be safe to use in most browsers, even though longer URLs w...
 
acquireParameters(array $namespace, string ... $names)
 
const SEPARATOR
Separator for parts of a parameter's namespace. 
 
withFragment(?string $fragment)
Change the fragment/hash part of the URL. 
 
getToken()
Get the token hash value. 
 
renderObject(array $tokens)
Renders a Javascript URLBuilder object with changeable parameters for all given tokens. 
 
renderTokens(array $tokens)
Renders a Javascript Map of all given tokens. 
 
buildQuery()
Create the query part of the URL from all parameters Claimed parameters overwrite base parameters in ...
 
The scope of this class is split ilias-conform URI's into components. 
 
checkLength(URI $uri)
Check the full length of the URI against URL_MAX_LENGTH. 
 
withParameter(URLBuilderToken $token, string|array $value)
Change an acquired parameter's value if the supplied token is valid. 
 
withURI(URI $uri)
Changes the base URI of the Builder. 
 
array $tokens
Stores all generated tokens for acquired parameters. 
 
deleteParameter(URLBuilderToken $token)
Delete an acquired parameter if the supplied token is valid. 
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
acquireParameter(array $namespace, string $name, ?string $initial_value=null)
Add a new parameter with a namespace and get its token for subsequent changes. 
 
array $params
Stores all acquired parameters These always take precedence over existing parameters in the base URI...
 
checkToken(URLBuilderToken $token)
Check if a token is valid.