ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ILIAS\UI\URLBuilderToken Class Reference

URLBuilderToken. More...

+ Collaboration diagram for ILIAS\UI\URLBuilderToken:

Public Member Functions

 __construct (array $namespace, string $name)
 
 getToken ()
 Get the token hash value. More...
 
 getName ()
 Get the full name of the token including its namespace. More...
 
 __toString ()
 
 render ()
 Output the JS equivalent of the token as a string. More...
 

Data Fields

const TOKEN_LENGTH = 24
 

Private Member Functions

 createToken ()
 Creates a randomized string of length URLBuilderToken::TOKEN_LENGTH generated by the random_bytes() function md5() is used as a fallback on systems that don't support random_bytes() More...
 

Private Attributes

array $namespace
 
string $name
 
string $token
 

Detailed Description

URLBuilderToken.

This is a token used by Data/URLBuilder to control usage of URL parameters. See URLBuilder interface for more details.

Definition at line 29 of file URLBuilderToken.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\UI\URLBuilderToken::__construct ( array  $namespace,
string  $name 
)

Definition at line 36 of file URLBuilderToken.php.

References ILIAS\UI\URLBuilderToken\$name, and ILIAS\UI\URLBuilderToken\createToken().

37  {
38  $this->namespace = $namespace;
39  $this->name = $name;
40  $this->token = $this->createToken();
41  }
createToken()
Creates a randomized string of length URLBuilderToken::TOKEN_LENGTH generated by the random_bytes() f...
+ Here is the call graph for this function:

Member Function Documentation

◆ __toString()

ILIAS\UI\URLBuilderToken::__toString ( )

Definition at line 60 of file URLBuilderToken.php.

References ILIAS\UI\URLBuilderToken\getName().

60  : string
61  {
62  return $this->getName();
63  }
getName()
Get the full name of the token including its namespace.
+ Here is the call graph for this function:

◆ createToken()

ILIAS\UI\URLBuilderToken::createToken ( )
private

Creates a randomized string of length URLBuilderToken::TOKEN_LENGTH generated by the random_bytes() function md5() is used as a fallback on systems that don't support random_bytes()

Definition at line 70 of file URLBuilderToken.php.

References ILIAS\UI\URLBuilderToken\$token.

Referenced by ILIAS\UI\URLBuilderToken\__construct().

70  : string
71  {
72  try {
73  $token = bin2hex(random_bytes(self::TOKEN_LENGTH / 2));
74  } catch (\Throwable $t) {
75  $token = md5(uniqid((string) time(), true));
76  $token = substr($token, 0, self::TOKEN_LENGTH);
77  }
78  return $token;
79  }
+ Here is the caller graph for this function:

◆ getName()

◆ getToken()

ILIAS\UI\URLBuilderToken::getToken ( )

Get the token hash value.

Definition at line 46 of file URLBuilderToken.php.

References ILIAS\UI\URLBuilderToken\$token.

Referenced by ILIAS\UI\URLBuilder\checkToken().

46  : string
47  {
48  return $this->token;
49  }
+ Here is the caller graph for this function:

◆ render()

ILIAS\UI\URLBuilderToken::render ( )

Output the JS equivalent of the token as a string.

Used by the URLBuilder renderer.

Definition at line 85 of file URLBuilderToken.php.

85  : string
86  {
87  $namespace = [];
88  foreach ($this->namespace as $name) {
89  $namespace[] = '"' . $name . '"';
90  }
91  $output = 'new il.UI.core.URLBuilderToken([' . implode(',', $namespace) . '], "' . $this->name . '", "' . $this->token . '")';
92  return $output;
93  }

Field Documentation

◆ $name

string ILIAS\UI\URLBuilderToken::$name
private

◆ $namespace

array ILIAS\UI\URLBuilderToken::$namespace
private

Definition at line 32 of file URLBuilderToken.php.

◆ $token

string ILIAS\UI\URLBuilderToken::$token
private

◆ TOKEN_LENGTH

const ILIAS\UI\URLBuilderToken::TOKEN_LENGTH = 24

Definition at line 31 of file URLBuilderToken.php.

Referenced by ILIAS\UI\URLBuilderTokenTest\testTokenLength().


The documentation for this class was generated from the following file: