ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
LoggingJavaScriptBinding Class Reference
+ Inheritance diagram for LoggingJavaScriptBinding:
+ Collaboration diagram for LoggingJavaScriptBinding:

Public Member Functions

 createId ()
 Create a fresh unique id. More...
 
 addOnLoadCode ($code)
 
 getOnLoadCodeAsync ()
 Get all the registered on-load javascript code for the async context, e.g. More...
 
 clearOnLoadCodeAsync ()
 Clears all JavaScript code currently registered for the async context. More...
 
- Public Member Functions inherited from ILIAS\UI\Implementation\Render\JavaScriptBinding
 createId ()
 Create a fresh unique id. More...
 
 addOnLoadCode (string $code)
 Add some JavaScript-statements to the on-load handler of the page. More...
 
 getOnLoadCodeAsync ()
 Get all the registered on-load javascript code for the async context, e.g. More...
 
 clearOnLoadCodeAsync ()
 Clears all JavaScript code currently registered for the async context. More...
 

Data Fields

array $on_load_code = array()
 
array $ids = array()
 

Private Attributes

int $count = 0
 

Detailed Description

Definition at line 208 of file Base.php.

Member Function Documentation

◆ addOnLoadCode()

LoggingJavaScriptBinding::addOnLoadCode (   $code)

Definition at line 222 of file Base.php.

222 : void
223 {
224 $this->on_load_code[] = $code;
225 }

◆ clearOnLoadCodeAsync()

LoggingJavaScriptBinding::clearOnLoadCodeAsync ( )

Clears all JavaScript code currently registered for the async context.

This is necessary because rendering can register JavaScript as a side effect, even when the rendered output is not required by the current async endpoint.

This is caused by ILIAS treating controllers as independent layers, meaning a controller cannot reliably determine what has been executed before it, while each layer may contribute parts of the page. This causes unnecessary rendering and JavaScript registration. This method prevents said JavaScript from leaking into the async response.

This is a reminder that we want proper routing inside ILIAS: https://docu.ilias.de/go/wiki/wpage_8780_1357

Implements ILIAS\UI\Implementation\Render\JavaScriptBinding.

Definition at line 232 of file Base.php.

232 : void
233 {
234 $this->on_load_code = [];
235 }

◆ createId()

LoggingJavaScriptBinding::createId ( )

Create a fresh unique id.

This MUST return a new id on every call.

Implements ILIAS\UI\Implementation\Render\JavaScriptBinding.

Definition at line 214 of file Base.php.

214 : string
215 {
216 $this->count++;
217 $id = "id_" . $this->count;
218 $this->ids[] = $id;
219 return $id;
220 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

References $count, and $id.

◆ getOnLoadCodeAsync()

LoggingJavaScriptBinding::getOnLoadCodeAsync ( )

Get all the registered on-load javascript code for the async context, e.g.

return all code inside <script> tags

Implements ILIAS\UI\Implementation\Render\JavaScriptBinding.

Definition at line 227 of file Base.php.

227 : string
228 {
229 return "";
230 }

Field Documentation

◆ $count

int LoggingJavaScriptBinding::$count = 0
private

Definition at line 212 of file Base.php.

Referenced by createId().

◆ $ids

array LoggingJavaScriptBinding::$ids = array()

Definition at line 211 of file Base.php.

◆ $on_load_code

array LoggingJavaScriptBinding::$on_load_code = array()

Definition at line 210 of file Base.php.


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