ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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.

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...

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

+ Here is the call graph for this function:

Member Function Documentation

◆ __toString()

ILIAS\UI\URLBuilderToken::__toString ( )

Definition at line 60 of file URLBuilderToken.php.

60 : string
61 {
62 return $this->getName();
63 }
getName()
Get the full name of the token including its namespace.

References ILIAS\UI\URLBuilderToken\getName().

+ 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.

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 }

References ILIAS\UI\URLBuilderToken\$token.

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

+ Here is the caller graph for this function:

◆ getName()

ILIAS\UI\URLBuilderToken::getName ( )

Get the full name of the token including its namespace.

Definition at line 55 of file URLBuilderToken.php.

55 : string
56 {
57 return implode(URLBuilder::SEPARATOR, $this->namespace) . URLBuilder::SEPARATOR . $this->name;
58 }
const SEPARATOR
Separator for parts of a parameter's namespace.
Definition: URLBuilder.php:50

References ILIAS\UI\URLBuilderToken\$name, and ILIAS\UI\URLBuilder\SEPARATOR.

Referenced by ILIAS\UI\URLBuilderToken\__toString(), and ILIAS\UI\URLBuilder\checkToken().

+ Here is the caller graph for this function:

◆ getToken()

ILIAS\UI\URLBuilderToken::getToken ( )

Get the token hash value.

Definition at line 46 of file URLBuilderToken.php.

46 : string
47 {
48 return $this->token;
49 }

References ILIAS\UI\URLBuilderToken\$token.

◆ 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 }

References ILIAS\UI\URLBuilderToken\$name, and ILIAS\UI\URLBuilderToken\$namespace.

Field Documentation

◆ $name

string ILIAS\UI\URLBuilderToken::$name
private

◆ $namespace

array ILIAS\UI\URLBuilderToken::$namespace
private

Definition at line 32 of file URLBuilderToken.php.

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

◆ $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: