ILIAS  release_8 Revision v8.24
Renderer.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
22
24use ILIAS\UI\Renderer as RendererInterface;
26
32{
36 public function render(Component\Component $component, RendererInterface $default_renderer): string
37 {
41 $this->checkComponent($component);
42
43 $component = $this->registerSignals($component);
44 $this->bindJavaScript($component);
45 return $component->getContent();
46 }
47
51 protected function getComponentInterfaceName(): array
52 {
53 return [Component\Legacy\Legacy::class];
54 }
55
56 protected function registerSignals(Legacy $component): Component\JavaScriptBindable
57 {
58 $custom_signals = $component->getAllCustomSignals();
59
60 return $component->withAdditionalOnLoadCode(function ($id) use ($custom_signals): string {
61 $code = "";
62 foreach ($custom_signals as $custom_signal) {
63 $signal_id = $custom_signal['signal'];
64 $signal_code = $custom_signal['js_code'];
65 $code .= "$(document).on('$signal_id', function(event, signalData) { $signal_code });";
66 }
67 return $code;
68 });
69 }
70}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
getAllCustomSignals()
Get a list of all registered signals and their custom JavaScript code.
Definition: Legacy.php:94
bindJavaScript(JavaScriptBindable $component)
Bind the component to JavaScript.
checkComponent(Component $component)
Check if a given component fits this renderer and throw \LogicError if that is not the case.
Interface to be extended by components that have the possibility to bind to Javascript.
render(Component $component, Renderer $default_renderer)
Render the component if possible and delegate additional rendering to the default_renderer.
An entity that renders components to a string output.
Definition: Renderer.php:31
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Factory.php:21